Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
dianlujitao | 5ec3773 | 2018-01-18 21:24:30 +0800 | [diff] [blame] | 3 | * Copyright (C) 2017-2018 The LineageOS Project |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "android.hardware.power@1.1-service-qti" |
| 19 | |
dianlujitao | 5ec3773 | 2018-01-18 21:24:30 +0800 | [diff] [blame] | 20 | // #define LOG_NDEBUG 0 |
| 21 | |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 22 | #include <android/log.h> |
| 23 | #include <hidl/HidlTransportSupport.h> |
| 24 | #include <hardware/power.h> |
Vinay Verma | 9e84f10 | 2018-09-14 11:25:46 +0530 | [diff] [blame] | 25 | #ifdef ARCH_ARM_32 |
| 26 | #include <hwbinder/ProcessState.h> |
| 27 | #endif |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 28 | #include "Power.h" |
| 29 | |
| 30 | using android::sp; |
| 31 | using android::status_t; |
| 32 | using android::OK; |
| 33 | |
| 34 | // libhwbinder: |
| 35 | using android::hardware::configureRpcThreadpool; |
| 36 | using android::hardware::joinRpcThreadpool; |
| 37 | |
| 38 | // Generated HIDL files |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 39 | using android::hardware::power::V1_1::implementation::Power; |
| 40 | |
| 41 | int main() { |
Vinay Verma | 9e84f10 | 2018-09-14 11:25:46 +0530 | [diff] [blame] | 42 | #ifdef ARCH_ARM_32 |
| 43 | android::hardware::ProcessState::initWithMmapSize((size_t)16384); |
| 44 | #endif |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 45 | |
| 46 | status_t status; |
dianlujitao | 5ec3773 | 2018-01-18 21:24:30 +0800 | [diff] [blame] | 47 | android::sp<Power> service = nullptr; |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 48 | |
| 49 | ALOGI("Power HAL Service 1.1 for QCOM is starting."); |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 50 | |
| 51 | service = new Power(); |
| 52 | if (service == nullptr) { |
| 53 | ALOGE("Can not create an instance of Power HAL Iface, exiting."); |
| 54 | |
| 55 | goto shutdown; |
| 56 | } |
| 57 | |
| 58 | configureRpcThreadpool(1, true /*callerWillJoin*/); |
| 59 | |
dianlujitao | 5ec3773 | 2018-01-18 21:24:30 +0800 | [diff] [blame] | 60 | status = service->registerAsSystemService(); |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 61 | if (status != OK) { |
| 62 | ALOGE("Could not register service for Power HAL Iface (%d).", status); |
| 63 | goto shutdown; |
| 64 | } |
| 65 | |
| 66 | ALOGI("Power Service is ready"); |
| 67 | joinRpcThreadpool(); |
| 68 | //Should not pass this line |
| 69 | |
| 70 | shutdown: |
| 71 | // In normal operation, we don't expect the thread pool to exit |
| 72 | |
| 73 | ALOGE("Power Service is shutting down"); |
| 74 | return 1; |
| 75 | } |