blob: bfa98b35ac70677f7fc412bdb5f88001ba08b6fd [file] [log] [blame]
Andreas Schneiderccd5c4c2020-05-25 17:10:35 +02001/*
2 * Copyright (C) 2020 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 "vibrator@1.3-samsung"
18
19#include <android-base/logging.h>
20#include <android/hardware/vibrator/1.3/IVibrator.h>
21#include <hidl/HidlSupport.h>
22#include <hidl/HidlTransportSupport.h>
23#include <utils/Errors.h>
24#include <utils/StrongPointer.h>
25
26#include "Vibrator.h"
27
28using android::hardware::configureRpcThreadpool;
29using android::hardware::joinRpcThreadpool;
30using android::hardware::vibrator::V1_3::IVibrator;
31using android::hardware::vibrator::V1_3::implementation::Vibrator;
32
33using android::OK;
34using android::sp;
35using android::status_t;
36
37int main() {
38 status_t status;
39 sp<IVibrator> vibrator;
40
41 LOG(INFO) << "Vibrator HAL service is starting.";
42
43 vibrator = new Vibrator();
44 if (vibrator == nullptr) {
45 LOG(ERROR) << "Can not create an instance of Vibrator HAL IVibrator, "
46 "exiting.";
47 goto shutdown;
48 }
49
50 configureRpcThreadpool(1, true);
51
52 status = vibrator->registerAsService();
53 if (status != OK) {
54 LOG(ERROR) << "Could not register service for Vibrator HAL";
55 goto shutdown;
56 }
57
58 LOG(INFO) << "Vibrator HAL service is Ready.";
59 joinRpcThreadpool();
60
61shutdown:
62 // In normal operation, we don't expect the thread pool to shutdown
63 LOG(ERROR) << "Vibrator HAL failed to join thread pool.";
64 return 1;
65}