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
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
24 #include "AutomotiveDisplayProxyService.h"
25
26 // libhidl:
27 using android::hardware::configureRpcThreadpool;
28 using android::hardware::joinRpcThreadpool;
29
30 // Generated HIDL files
31 using android::frameworks::automotive::display::V1_0::IAutomotiveDisplayProxyService;
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
main()39 int main() {
40 ALOGI("Automotive Display Proxy Service is starting");
41
42 android::sp<IAutomotiveDisplayProxyService> service =
43 new AutomotiveDisplayProxyService();
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
58 ALOGE("Automotive Window Service is shutting down");
59
60 return 1;
61 }
62
63