blob: 80649f5c5e35342be61a05c6ffded270d8aa7407 [file] [log] [blame]
Vinay Kalia7b3d7a02018-11-01 11:57:40 -07001/*
2 * Copyright (C) 2018 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.stats@1.0-service"
18
19#include <android/log.h>
20#include <hidl/HidlTransportSupport.h>
21
22#include "PowerStats.h"
23
24using android::OK;
25using android::sp;
26using android::status_t;
27
28// libhwbinder:
29using android::hardware::configureRpcThreadpool;
30using android::hardware::joinRpcThreadpool;
31
32// Generated HIDL files
33using android::hardware::power::stats::V1_0::IPowerStats;
34using android::hardware::power::stats::V1_0::implementation::PowerStats;
35
36int main(int /* argc */, char** /* argv */) {
37 ALOGI("power.stats service 1.0 is starting.");
38
39 android::sp<IPowerStats> service = new PowerStats();
40 if (service == nullptr) {
41 ALOGE("Can not create an instance of power.stats HAL Iface, exiting.");
42 return 1;
43 }
44
45 configureRpcThreadpool(1, true /*callerWillJoin*/);
46
47 status_t status = service->registerAsService();
48 if (status != OK) {
49 ALOGE("Could not register service for power.stats HAL Iface (%d), exiting.", status);
50 return 1;
51 }
52
53 ALOGI("power.stats service is ready");
54 joinRpcThreadpool();
55
56 // In normal operation, we don't expect the thread pool to exit
57 ALOGE("power.stats service is shutting down");
58 return 1;
59}