1 /* 2 * Copyright 2019 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 //#define LOG_NDEBUG 0 18 #ifdef LAZY_SERVICE 19 #define LOG_TAG "[email protected]" 20 #else 21 #define LOG_TAG "[email protected]" 22 #endif 23 24 #include <hidl/HidlTransportSupport.h> 25 #include <hidl/LegacySupport.h> 26 27 #include "Tuner.h" 28 29 using android::hardware::configureRpcThreadpool; 30 using android::hardware::joinRpcThreadpool; 31 using android::hardware::LazyServiceRegistrar; 32 using android::hardware::tv::tuner::V1_0::ITuner; 33 using android::hardware::tv::tuner::V1_0::implementation::Tuner; 34 35 #ifdef LAZY_SERVICE 36 const bool kLazyService = true; 37 #else 38 const bool kLazyService = false; 39 #endif 40 main()41int main() { 42 configureRpcThreadpool(8, true /* callerWillJoin */); 43 44 // Setup hwbinder service 45 android::sp<ITuner> service = new Tuner(); 46 android::status_t status; 47 if (kLazyService) { 48 auto serviceRegistrar = LazyServiceRegistrar::getInstance(); 49 status = serviceRegistrar.registerService(service); 50 } else { 51 status = service->registerAsService(); 52 } 53 LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering tuner service: %d", status); 54 55 joinRpcThreadpool(); 56 return 0; 57 } 58