blob: d45a2ef65de1c383b546ebafd27f9a01c3cab060 [file] [log] [blame]
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -07001/*
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 Alahari0a344f42023-04-26 17:16:51 -070019/* Changes from Qualcomm Innovation Center are provided under the following license:
20
21Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
22SPDX-License-Identifier: BSD-3-Clause-Clear */
23
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070024#define LOG_TAG "thermal_hal"
25
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070026#include "thermal.h"
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070027#include <android-base/logging.h>
28#include <android/binder_manager.h>
29#include <android/binder_process.h>
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070030
31using ::android::OK;
32using ::android::status_t;
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070033using aidl::android::hardware::thermal::Thermal;
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070034
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070035int main() {
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070036
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070037 LOG(INFO) << "Thermal HAL Service AIDL starting...";
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070038
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070039 ABinderProcess_setThreadPoolMaxThreadCount(0);
40 std::shared_ptr<Thermal> therm = ndk::SharedRefBase::make<Thermal>();
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070041
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070042 const std::string instance = std::string() + Thermal::descriptor + "/default";
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070043
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070044 if(therm){
45 binder_status_t status =
46 AServiceManager_addService(therm->asBinder().get(), instance.c_str());
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070047
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070048 CHECK(status == STATUS_OK);
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070049 }
50
Bavyasritha Alahari0a344f42023-04-26 17:16:51 -070051 LOG(INFO) << "Thermal HAL Service AIDL started successfully.";
52 ABinderProcess_joinThreadPool();
53 return EXIT_FAILURE; // should not reach
Ram Chandrasekardac8f7d2020-06-10 12:23:28 -070054}