1 /* 2 * Copyright (C) 2017 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 #include <android/hardware/vibrator/1.3/IVibrator.h> 18 #include <hidl/HidlSupport.h> 19 #include <hidl/HidlTransportSupport.h> 20 #include <utils/Errors.h> 21 #include <utils/StrongPointer.h> 22 23 #include "Hardware.h" 24 #include "Vibrator.h" 25 26 using android::OK; 27 using android::sp; 28 using android::status_t; 29 using android::UNKNOWN_ERROR; 30 using android::hardware::configureRpcThreadpool; 31 using android::hardware::joinRpcThreadpool; 32 using android::hardware::vibrator::V1_3::implementation::HwApi; 33 using android::hardware::vibrator::V1_3::implementation::HwCal; 34 using android::hardware::vibrator::V1_3::implementation::Vibrator; 35 registerVibratorService()36status_t registerVibratorService() { 37 auto hwapi = HwApi::Create(); 38 39 if (!hwapi) { 40 return UNKNOWN_ERROR; 41 } 42 43 sp<Vibrator> vibrator = new Vibrator(std::move(hwapi), std::make_unique<HwCal>()); 44 45 return vibrator->registerAsService(); 46 } 47 main()48int main() { 49 configureRpcThreadpool(1, true); 50 status_t status = registerVibratorService(); 51 52 if (status != OK) { 53 return status; 54 } 55 56 joinRpcThreadpool(); 57 } 58