1 /* 2 * Copyright (C) 2017 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 17 #define LOG_TAG "android.hardware.power@1.1-service.hikey-common" 18 19 #include <android/log.h> 20 #include <hidl/HidlTransportSupport.h> 21 #include <hardware/power.h> 22 #include "Power.h" 23 24 using android::sp; 25 using android::status_t; 26 using android::OK; 27 28 // libhwbinder: 29 using android::hardware::configureRpcThreadpool; 30 using android::hardware::joinRpcThreadpool; 31 32 // Generated HIDL files 33 using android::hardware::power::V1_1::IPower; 34 using android::hardware::power::V1_1::implementation::Power; 35 main()36int main() { 37 38 status_t status; 39 android::sp<IPower> service = nullptr; 40 41 ALOGI("Power HAL Service 1.1 for HiKey-common is starting."); 42 43 service = new Power(); 44 if (service == nullptr) { 45 ALOGE("Can not create an instance of Power HAL Iface, exiting."); 46 47 goto shutdown; 48 } 49 50 configureRpcThreadpool(1, true /*callerWillJoin*/); 51 52 status = service->registerAsService(); 53 if (status != OK) { 54 ALOGE("Could not register service for Power HAL Iface (%d).", status); 55 goto shutdown; 56 } 57 58 ALOGI("Power Service is ready"); 59 joinRpcThreadpool(); 60 //Should not pass this line 61 62 shutdown: 63 // In normal operation, we don't expect the thread pool to exit 64 65 ALOGE("Power Service is shutting down"); 66 return 1; 67 } 68