blob: bad1adf107f926d483bfd4b4145cf83819b66096 [file] [log] [blame]
Ruchi Kandoi49ceebe2016-09-29 17:46:57 -07001/*
2 * Copyright (C) 2016 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.0-service"
18#include <utils/Log.h>
19
20#include <iostream>
21#include <unistd.h>
22
23#include <android/hardware/power/1.0/IPower.h>
24
25#include <hidl/IServiceManager.h>
26#include <hwbinder/IPCThreadState.h>
27#include <hwbinder/ProcessState.h>
28#include <utils/Errors.h>
29#include <utils/StrongPointer.h>
30
31using android::sp;
32
33using android::hardware::IPCThreadState;
34using android::hardware::ProcessState;
35
36using android::hardware::power::V1_0::IPower;
37
38int main() {
39 const char instance[] = "power";
40 android::sp<IPower> service = IPower::getService(instance, true);
41 if (service.get() == nullptr) {
42 ALOGE("IPower::getService returned NULL, exiting");
43 return -1;
44 }
45 LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
46 service->registerAsService(instance);
47
48 ProcessState::self()->setThreadPoolMaxThreadCount(0);
49 ProcessState::self()->startThreadPool();
50 IPCThreadState::self()->joinThreadPool();
51}