blob: 9b4e3557be880e0ede084fa99cb87cce176d6a15 [file] [log] [blame]
Jesse Chana4922f42018-05-02 17:09:59 -07001/*
2 * Copyright (C) 2019 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 "android.hardware.vibrator@1.0-service.samsung-haptic"
18
19#include <android-base/logging.h>
20#include <android/hardware/vibrator/1.0/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_0::IVibrator;
31using android::hardware::vibrator::V1_0::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, exiting.";
46 goto shutdown;
47 }
48
49 configureRpcThreadpool(1, true);
50
51 status = vibrator->registerAsService();
52 if (status != OK) {
53 LOG(ERROR) << "Could not register service for Vibrator HAL";
54 goto shutdown;
55 }
56
57 LOG(INFO) << "Vibrator HAL service is Ready.";
58 joinRpcThreadpool();
59
60shutdown:
61 // In normal operation, we don't expect the thread pool to shutdown
62 LOG(ERROR) << "Vibrator HAL failed to join thread pool.";
63 return 1;
64}