blob: b5862e8378fdbfd8f4bf8823a888fe4a5ab0e2ba [file] [log] [blame]
Alessandro Astone8011ada2021-03-30 11:34:38 +02001/*
2 * Copyright (C) 2021 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 "vendor.lineage.powershare@1.0-service.pixel"
18
19#include <android-base/logging.h>
20#include <binder/ProcessState.h>
21#include <hidl/HidlTransportSupport.h>
22
23#include "PowerShare.h"
24
25using android::hardware::configureRpcThreadpool;
26using android::hardware::joinRpcThreadpool;
27using android::sp;
28using android::status_t;
29using android::OK;
30
31using ::vendor::lineage::powershare::pixel::PowerShare;
32
33int main() {
34 sp<PowerShare> powerShare;
35 status_t status;
36
37 LOG(INFO) << "PowerShare HAL service is starting.";
38
39 powerShare = new PowerShare();
40 if (powerShare == nullptr) {
41 LOG(ERROR) << "Can not create an instance of PowerShare HAL, exiting.";
42 goto shutdown;
43 }
44
45 configureRpcThreadpool(1, true /*callerWillJoin*/);
46
47 status = powerShare->registerAsService();
48 if (status != OK) {
49 LOG(ERROR) << "Could not register service for PowerShare HAL (" << status << ")";
50 goto shutdown;
51 }
52
53 LOG(INFO) << "PowerShare HAL service is ready.";
54 joinRpcThreadpool();
55 // Should not pass this line
56
57shutdown:
58 // In normal operation, we don't expect the thread pool to shutdown
59 LOG(ERROR) << "PowerShare HAL service is shutting down.";
60 return 1;
61}