blob: d43b6524279f541a3cb121924827fd79a465100a [file] [log] [blame]
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
dianlujitao5ec37732018-01-18 21:24:30 +08003 * Copyright (C) 2017-2018 The LineageOS Project
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -07004 *
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
dianlujitao5ec37732018-01-18 21:24:30 +080020// #define LOG_NDEBUG 0
21
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070022#include <android/log.h>
23#include <hidl/HidlTransportSupport.h>
24#include <hardware/power.h>
Vinay Verma9e84f102018-09-14 11:25:46 +053025#ifdef ARCH_ARM_32
26#include <hwbinder/ProcessState.h>
27#endif
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070028#include "Power.h"
29
30using android::sp;
31using android::status_t;
32using android::OK;
33
34// libhwbinder:
35using android::hardware::configureRpcThreadpool;
36using android::hardware::joinRpcThreadpool;
37
38// Generated HIDL files
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070039using android::hardware::power::V1_1::implementation::Power;
40
41int main() {
Vinay Verma9e84f102018-09-14 11:25:46 +053042#ifdef ARCH_ARM_32
43 android::hardware::ProcessState::initWithMmapSize((size_t)16384);
44#endif
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070045
46 status_t status;
dianlujitao5ec37732018-01-18 21:24:30 +080047 android::sp<Power> service = nullptr;
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070048
49 ALOGI("Power HAL Service 1.1 for QCOM is starting.");
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070050
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
dianlujitao5ec37732018-01-18 21:24:30 +080060 status = service->registerAsSystemService();
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070061 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
70shutdown:
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}