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