• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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@1.3-service.pixel-libperfmgr"
18 
19 #include <android/log.h>
20 #include <hidl/HidlTransportSupport.h>
21 
22 #include "Power.h"
23 
24 using android::OK;
25 using android::sp;
26 using android::status_t;
27 
28 // libhwbinder:
29 using android::hardware::configureRpcThreadpool;
30 using android::hardware::joinRpcThreadpool;
31 
32 // Generated HIDL files
33 using android::hardware::power::V1_3::IPower;
34 using android::hardware::power::V1_3::implementation::Power;
35 
main(int,char **)36 int main(int /* argc */, char ** /* argv */) {
37     ALOGI("Power HAL Service 1.3 for Pixel is starting.");
38 
39     android::sp<IPower> service = new Power();
40     if (service == nullptr) {
41         ALOGE("Can not create an instance of Power 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 HAL Iface (%d), exiting.", status);
50         return 1;
51     }
52 
53     ALOGI("Power Service is ready");
54     joinRpcThreadpool();
55 
56     // In normal operation, we don't expect the thread pool to exit
57     ALOGE("Power Service is shutting down");
58     return 1;
59 }
60