Jan Altensen | e0dd329 | 2020-02-01 06:21:33 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The LineageOS 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.0-service.exynos" |
| 18 | |
| 19 | #include <android-base/logging.h> |
| 20 | #include <hidl/HidlTransportSupport.h> |
| 21 | #include <utils/Errors.h> |
| 22 | |
| 23 | #include "Power.h" |
| 24 | |
| 25 | using android::hardware::configureRpcThreadpool; |
| 26 | using android::hardware::joinRpcThreadpool; |
| 27 | |
| 28 | using android::hardware::power::V1_0::IPower; |
| 29 | using android::hardware::power::V1_0::implementation::Power; |
| 30 | |
| 31 | using android::OK; |
| 32 | using android::sp; |
| 33 | using android::status_t; |
| 34 | |
| 35 | int main() { |
| 36 | sp<Power> power = new Power(); |
| 37 | status_t status = 0; |
| 38 | |
| 39 | configureRpcThreadpool(1, true); |
| 40 | |
| 41 | status = power->IPower::registerAsService(); |
| 42 | if (status != OK) { |
| 43 | LOG(ERROR) << "Could not register service (IPower) for Power HAL"; |
| 44 | goto shutdown; |
| 45 | } |
| 46 | |
| 47 | status = power->ILineagePower::registerAsService(); |
| 48 | if (status != OK) { |
| 49 | LOG(ERROR) << "Could not register service (ILineagePower) for Power HAL"; |
| 50 | goto shutdown; |
| 51 | } |
| 52 | |
| 53 | LOG(INFO) << "Power HAL service is Ready."; |
| 54 | joinRpcThreadpool(); |
| 55 | |
| 56 | shutdown: |
| 57 | // In normal operation, we don't expect the thread pool to shutdown |
| 58 | LOG(ERROR) << "Power HAL failed to join thread pool."; |
| 59 | return 1; |
| 60 | } |