Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 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 | |
Scott Randolph | 8342279 | 2017-03-01 20:32:59 -0800 | [diff] [blame] | 17 | #define LOG_TAG "android.hardware.automotive.evs@1.0-service" |
Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 18 | |
| 19 | #include <unistd.h> |
| 20 | |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 21 | #include <hidl/HidlTransportSupport.h> |
Steven Moreland | 4e7a307 | 2017-04-06 12:15:23 -0700 | [diff] [blame^] | 22 | #include <log/log.h> |
Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 23 | #include <utils/Errors.h> |
| 24 | #include <utils/StrongPointer.h> |
Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 25 | |
| 26 | #include "ServiceNames.h" |
| 27 | #include "EvsEnumerator.h" |
| 28 | #include "EvsDisplay.h" |
| 29 | |
| 30 | |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 31 | // libhidl: |
| 32 | using android::hardware::configureRpcThreadpool; |
| 33 | using android::hardware::joinRpcThreadpool; |
Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 34 | |
| 35 | // Generated HIDL files |
Scott Randolph | 8342279 | 2017-03-01 20:32:59 -0800 | [diff] [blame] | 36 | using android::hardware::automotive::evs::V1_0::IEvsEnumerator; |
| 37 | using android::hardware::automotive::evs::V1_0::IEvsDisplay; |
Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 38 | |
| 39 | // The namespace in which all our implementation code lives |
Scott Randolph | 8342279 | 2017-03-01 20:32:59 -0800 | [diff] [blame] | 40 | using namespace android::hardware::automotive::evs::V1_0::implementation; |
Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 41 | using namespace android; |
| 42 | |
| 43 | |
| 44 | int main() { |
| 45 | ALOGI("EVS Hardware Enumerator service is starting"); |
| 46 | android::sp<IEvsEnumerator> service = new EvsEnumerator(); |
| 47 | |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 48 | configureRpcThreadpool(1, true /* callerWillJoin */); |
| 49 | |
Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 50 | // Register our service -- if somebody is already registered by our name, |
| 51 | // they will be killed (their thread pool will throw an exception). |
| 52 | status_t status = service->registerAsService(kEnumeratorServiceName); |
| 53 | if (status == OK) { |
| 54 | ALOGD("%s is ready.", kEnumeratorServiceName); |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 55 | joinRpcThreadpool(); |
Scott Randolph | 5c99d85 | 2016-11-15 17:01:23 -0800 | [diff] [blame] | 56 | } else { |
| 57 | ALOGE("Could not register service %s (%d).", kEnumeratorServiceName, status); |
| 58 | } |
| 59 | |
| 60 | // In normal operation, we don't expect the thread pool to exit |
| 61 | ALOGE("EVS Hardware Enumerator is shutting down"); |
| 62 | return 1; |
| 63 | } |