1 /* 2 * Copyright (C) 2016 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 <unistd.h> 18 19 #include <hidl/HidlTransportSupport.h> 20 #include <utils/Errors.h> 21 #include <utils/StrongPointer.h> 22 #include <utils/Log.h> 23 24 #include "ServiceNames.h" 25 #include "EvsEnumerator.h" 26 #include "EvsGlDisplay.h" 27 28 29 // libhidl: 30 using android::hardware::configureRpcThreadpool; 31 using android::hardware::joinRpcThreadpool; 32 33 // Generated HIDL files 34 using android::hardware::automotive::evs::V1_0::IEvsEnumerator; 35 using android::hardware::automotive::evs::V1_0::IEvsDisplay; 36 37 // The namespace in which all our implementation code lives 38 using namespace android::hardware::automotive::evs::V1_0::implementation; 39 using namespace android; 40 41 42 int main() { 43 ALOGI("EVS Hardware Enumerator service is starting"); 44 android::sp<IEvsEnumerator> service = new EvsEnumerator(); 45 46 configureRpcThreadpool(1, true /* callerWillJoin */); 47 48 // Register our service -- if somebody is already registered by our name, 49 // they will be killed (their thread pool will throw an exception). 50 status_t status = service->registerAsService(kEnumeratorServiceName); 51 if (status == OK) { 52 ALOGD("%s is ready.", kEnumeratorServiceName); 53 joinRpcThreadpool(); 54 } else { 55 ALOGE("Could not register service %s (%d).", kEnumeratorServiceName, status); 56 } 57 58 // In normal operation, we don't expect the thread pool to exit 59 ALOGE("EVS Hardware Enumerator is shutting down"); 60 return 1; 61 } 62