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