1 /* 2 * Copyright (C) 2018 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 #define LOG_TAG "hardware.google.light@1.0-service" 17 18 #include <hardware/lights.h> 19 #include <hidl/LegacySupport.h> 20 #include <hardware/google/light/1.0/ILight.h> 21 #include "LightExt.h" 22 23 namespace android { 24 namespace hardware { 25 namespace light { 26 namespace V2_0 { 27 namespace implementation { 28 29 extern ILight* HIDL_FETCH_ILight(const char* /* name */); 30 31 } // namespace implementation 32 } // namespace V2_0 33 } // namespace light 34 } // namespace hardware 35 } // namespace android 36 37 using android::hardware::configureRpcThreadpool; 38 using android::hardware::joinRpcThreadpool; 39 using hardware::google::light::V1_0::implementation::LightExt; 40 using hwLight = hardware::google::light::V1_0::ILight; 41 main()42int main() { 43 configureRpcThreadpool(1, true /*willJoinThreadpool*/); 44 45 android::sp<hwLight> light = new LightExt{ 46 android::hardware::light::V2_0::implementation::HIDL_FETCH_ILight( 47 nullptr)}; 48 auto ret = light->registerAsService(); 49 if (ret != android::OK) { 50 ALOGE("open light servie failed, ret=%d", ret); 51 return 1; 52 } 53 joinRpcThreadpool(); 54 return 1; 55 } 56