1 /* 2 * Copyright (C) 2018 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 <hidl/HidlTransportSupport.h> 18 #include "Thermal.h" 19 20 using ::android::OK; 21 using ::android::status_t; 22 23 // libhwbinder: 24 using ::android::hardware::configureRpcThreadpool; 25 using ::android::hardware::joinRpcThreadpool; 26 27 // Generated HIDL files: 28 using ::android::hardware::thermal::V2_0::IThermal; 29 using ::android::hardware::thermal::V2_0::implementation::Thermal; 30 shutdown()31static int shutdown() { 32 LOG(ERROR) << "Pixel Thermal HAL Service is shutting down."; 33 return 1; 34 } 35 main(int,char **)36int main(int /* argc */, char ** /* argv */) { 37 status_t status; 38 android::sp<IThermal> service = nullptr; 39 40 LOG(INFO) << "Pixel Thermal HAL Service 2.0 starting..."; 41 42 service = new Thermal(); 43 if (service == nullptr) { 44 LOG(ERROR) << "Error creating an instance of Thermal HAL. Exiting..."; 45 return shutdown(); 46 } 47 48 configureRpcThreadpool(1, true /* callerWillJoin */); 49 50 status = service->registerAsService(); 51 if (status != OK) { 52 LOG(ERROR) << "Could not register service for ThermalHAL (" << status << ")"; 53 return shutdown(); 54 } 55 56 LOG(INFO) << "Pixel Thermal HAL Service 2.0 started successfully."; 57 joinRpcThreadpool(); 58 // We should not get past the joinRpcThreadpool(). 59 return shutdown(); 60 } 61