1*ec779b8eSAndroid Build Coastguard Worker /* 2*ec779b8eSAndroid Build Coastguard Worker * Copyright (C) 2021 The Android Open Source Project 3*ec779b8eSAndroid Build Coastguard Worker * 4*ec779b8eSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*ec779b8eSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*ec779b8eSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*ec779b8eSAndroid Build Coastguard Worker * 8*ec779b8eSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*ec779b8eSAndroid Build Coastguard Worker * 10*ec779b8eSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*ec779b8eSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*ec779b8eSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*ec779b8eSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*ec779b8eSAndroid Build Coastguard Worker * limitations under the License. 15*ec779b8eSAndroid Build Coastguard Worker */ 16*ec779b8eSAndroid Build Coastguard Worker 17*ec779b8eSAndroid Build Coastguard Worker #include <android-base/logging.h> 18*ec779b8eSAndroid Build Coastguard Worker #include <binder/IPCThreadState.h> 19*ec779b8eSAndroid Build Coastguard Worker #include <binder/IServiceManager.h> 20*ec779b8eSAndroid Build Coastguard Worker #include <cutils/properties.h> 21*ec779b8eSAndroid Build Coastguard Worker #include <utils/Log.h> 22*ec779b8eSAndroid Build Coastguard Worker #include <hidl/HidlTransportSupport.h> 23*ec779b8eSAndroid Build Coastguard Worker 24*ec779b8eSAndroid Build Coastguard Worker #include "TunerService.h" 25*ec779b8eSAndroid Build Coastguard Worker #include "hidl/TunerHidlService.h" 26*ec779b8eSAndroid Build Coastguard Worker 27*ec779b8eSAndroid Build Coastguard Worker using ::aidl::android::media::tv::tuner::TunerHidlService; 28*ec779b8eSAndroid Build Coastguard Worker using ::aidl::android::media::tv::tuner::TunerService; 29*ec779b8eSAndroid Build Coastguard Worker 30*ec779b8eSAndroid Build Coastguard Worker using namespace android; 31*ec779b8eSAndroid Build Coastguard Worker main()32*ec779b8eSAndroid Build Coastguard Workerint main() { 33*ec779b8eSAndroid Build Coastguard Worker ALOGD("Tuner service starting"); 34*ec779b8eSAndroid Build Coastguard Worker 35*ec779b8eSAndroid Build Coastguard Worker if (!property_get_bool("tuner.server.enable", false) 36*ec779b8eSAndroid Build Coastguard Worker && !property_get_bool("ro.tuner.lazyhal", false)) { 37*ec779b8eSAndroid Build Coastguard Worker ALOGD("tuner is not enabled, terminating"); 38*ec779b8eSAndroid Build Coastguard Worker return 0; 39*ec779b8eSAndroid Build Coastguard Worker } 40*ec779b8eSAndroid Build Coastguard Worker 41*ec779b8eSAndroid Build Coastguard Worker sp<ProcessState> proc(ProcessState::self()); 42*ec779b8eSAndroid Build Coastguard Worker sp<IServiceManager> sm = defaultServiceManager(); 43*ec779b8eSAndroid Build Coastguard Worker hardware::configureRpcThreadpool(16, true); 44*ec779b8eSAndroid Build Coastguard Worker ProcessState::self()->setThreadPoolMaxThreadCount(16); 45*ec779b8eSAndroid Build Coastguard Worker 46*ec779b8eSAndroid Build Coastguard Worker // Check legacy HIDL HAL first. If it's not existed, use AIDL HAL. 47*ec779b8eSAndroid Build Coastguard Worker binder_status_t status = TunerHidlService::instantiate(); 48*ec779b8eSAndroid Build Coastguard Worker if (status != STATUS_OK) { 49*ec779b8eSAndroid Build Coastguard Worker status = TunerService::instantiate(); 50*ec779b8eSAndroid Build Coastguard Worker CHECK(status == STATUS_OK); 51*ec779b8eSAndroid Build Coastguard Worker } 52*ec779b8eSAndroid Build Coastguard Worker 53*ec779b8eSAndroid Build Coastguard Worker ProcessState::self()->startThreadPool(); 54*ec779b8eSAndroid Build Coastguard Worker IPCThreadState::self()->joinThreadPool(); 55*ec779b8eSAndroid Build Coastguard Worker return EXIT_FAILURE; // should not reached 56*ec779b8eSAndroid Build Coastguard Worker } 57