1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include <android-base/logging.h> 17 #include <android/binder_manager.h> 18 #include <android/binder_process.h> 19 20 #include "Thermal.h" 21 22 constexpr std::string_view kThermalLogTag("pixel-thermal"); 23 24 using ::android::OK; 25 using ::android::status_t; 26 27 // Generated AIDL files: 28 using Thermal = ::aidl::android::hardware::thermal::implementation::Thermal; 29 30 #if !defined(THERMAL_INSTANCE_NAME) 31 #define THERMAL_INSTANCE_NAME "default" 32 #endif 33 main(int,char **)34int main(int /* argc */, char ** /* argv */) { 35 // ignore broken pipe signal to avoid Thermal HAL being killed when dumpsys timeout 36 signal(SIGPIPE, SIG_IGN); 37 android::base::SetDefaultTag(kThermalLogTag.data()); 38 39 auto svc = ndk::SharedRefBase::make<Thermal>(); 40 const auto svcName = std::string() + svc->descriptor + "/" + THERMAL_INSTANCE_NAME; 41 LOG(INFO) << "Pixel Thermal AIDL Service starting..." + svcName; 42 ABinderProcess_setThreadPoolMaxThreadCount(0); 43 44 auto svcBinder = svc->asBinder(); 45 binder_status_t status = AServiceManager_addService(svcBinder.get(), svcName.c_str()); 46 if (status != STATUS_OK) { 47 LOG(ERROR) << "Pixel Thermal AIDL Service failed to start: " << status << "."; 48 return EXIT_FAILURE; 49 } 50 LOG(INFO) << "Pixel Thermal HAL AIDL Service started."; 51 ABinderProcess_joinThreadPool(); 52 return EXIT_FAILURE; // should not reach 53 } 54