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 android::base::SetDefaultTag(kThermalLogTag.data()); 36 37 auto svc = ndk::SharedRefBase::make<Thermal>(); 38 const auto svcName = std::string() + svc->descriptor + "/" + THERMAL_INSTANCE_NAME; 39 LOG(INFO) << "Pixel Thermal AIDL Service starting..." + svcName; 40 ABinderProcess_setThreadPoolMaxThreadCount(0); 41 42 auto svcBinder = svc->asBinder(); 43 binder_status_t status = AServiceManager_addService(svcBinder.get(), svcName.c_str()); 44 if (status != STATUS_OK) { 45 LOG(ERROR) << "Pixel Thermal AIDL Service failed to start: " << status << "."; 46 return EXIT_FAILURE; 47 } 48 LOG(INFO) << "Pixel Thermal HAL AIDL Service started."; 49 ABinderProcess_joinThreadPool(); 50 return EXIT_FAILURE; // should not reach 51 } 52