Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, The Linux Foundation. All rights reserved. |
| 3 | * Not a contribution |
| 4 | * Copyright (C) 2018 The Android Open Source Project |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 19 | /* Changes from Qualcomm Innovation Center are provided under the following license: |
| 20 | |
| 21 | Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. |
| 22 | SPDX-License-Identifier: BSD-3-Clause-Clear */ |
| 23 | |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 24 | #define LOG_TAG "thermal_hal" |
| 25 | |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 26 | #include "thermal.h" |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 27 | #include <android-base/logging.h> |
| 28 | #include <android/binder_manager.h> |
| 29 | #include <android/binder_process.h> |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 30 | |
| 31 | using ::android::OK; |
| 32 | using ::android::status_t; |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 33 | using aidl::android::hardware::thermal::Thermal; |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 34 | |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 35 | int main() { |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 36 | |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 37 | LOG(INFO) << "Thermal HAL Service AIDL starting..."; |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 38 | |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 39 | ABinderProcess_setThreadPoolMaxThreadCount(0); |
| 40 | std::shared_ptr<Thermal> therm = ndk::SharedRefBase::make<Thermal>(); |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 41 | |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 42 | const std::string instance = std::string() + Thermal::descriptor + "/default"; |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 43 | |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 44 | if(therm){ |
| 45 | binder_status_t status = |
| 46 | AServiceManager_addService(therm->asBinder().get(), instance.c_str()); |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 47 | |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 48 | CHECK(status == STATUS_OK); |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Bavyasritha Alahari | 0a344f4 | 2023-04-26 17:16:51 -0700 | [diff] [blame] | 51 | LOG(INFO) << "Thermal HAL Service AIDL started successfully."; |
| 52 | ABinderProcess_joinThreadPool(); |
| 53 | return EXIT_FAILURE; // should not reach |
Ram Chandrasekar | dac8f7d | 2020-06-10 12:23:28 -0700 | [diff] [blame] | 54 | } |