Haoxiang Li | 95917b1 | 2019-11-15 11:29:05 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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 | |
Haoxiang Li | 95917b1 | 2019-11-15 11:29:05 -0800 | [diff] [blame] | 17 | #include <unistd.h> |
| 18 | |
| 19 | #include <hidl/HidlTransportSupport.h> |
| 20 | #include <log/log.h> |
| 21 | #include <utils/Errors.h> |
| 22 | #include <utils/StrongPointer.h> |
| 23 | |
Changyeon Jo | 4ff8fb0 | 2020-02-05 21:56:59 -0800 | [diff] [blame] | 24 | #include "AutomotiveDisplayProxyService.h" |
Haoxiang Li | 95917b1 | 2019-11-15 11:29:05 -0800 | [diff] [blame] | 25 | |
| 26 | // libhidl: |
| 27 | using android::hardware::configureRpcThreadpool; |
| 28 | using android::hardware::joinRpcThreadpool; |
| 29 | |
| 30 | // Generated HIDL files |
Changyeon Jo | 4ff8fb0 | 2020-02-05 21:56:59 -0800 | [diff] [blame] | 31 | using android::frameworks::automotive::display::V1_0::IAutomotiveDisplayProxyService; |
Haoxiang Li | 95917b1 | 2019-11-15 11:29:05 -0800 | [diff] [blame] | 32 | |
| 33 | // The namespace in which all our implementation code lives |
| 34 | using namespace android::frameworks::automotive::display::V1_0::implementation; |
| 35 | using namespace android; |
| 36 | |
| 37 | const static char kServiceName[] = "default"; |
| 38 | |
| 39 | int main() { |
Changyeon Jo | 75c8aa9 | 2019-12-30 11:12:53 -0800 | [diff] [blame^] | 40 | ALOGI("Automotive Display Proxy Service is starting"); |
Haoxiang Li | 95917b1 | 2019-11-15 11:29:05 -0800 | [diff] [blame] | 41 | |
Changyeon Jo | 75c8aa9 | 2019-12-30 11:12:53 -0800 | [diff] [blame^] | 42 | android::sp<IAutomotiveDisplayProxyService> service = |
| 43 | new AutomotiveDisplayProxyService(); |
Haoxiang Li | 95917b1 | 2019-11-15 11:29:05 -0800 | [diff] [blame] | 44 | |
| 45 | configureRpcThreadpool(1, true /* callerWillJoin */); |
| 46 | |
| 47 | // Register our service -- if somebody is already registered by our name, |
| 48 | // they will be killed (their thread pool will throw an exception). |
| 49 | status_t status = service->registerAsService(kServiceName); |
| 50 | if (status == OK) { |
| 51 | ALOGD("%s is ready.", kServiceName); |
| 52 | joinRpcThreadpool(); |
| 53 | } else { |
| 54 | ALOGE("Could not register service %s (%d).", kServiceName, status); |
| 55 | } |
| 56 | |
| 57 | // In normal operation, we don't expect the thread pool to exit |
Changyeon Jo | 75c8aa9 | 2019-12-30 11:12:53 -0800 | [diff] [blame^] | 58 | ALOGE("Automotive Window Service is shutting down"); |
Haoxiang Li | 95917b1 | 2019-11-15 11:29:05 -0800 | [diff] [blame] | 59 | |
| 60 | return 1; |
| 61 | } |
| 62 | |