blob: 59b584cd46bcb2446b3de85cea8ac06ee87904aa [file] [log] [blame]
Haoxiang Li95917b12019-11-15 11:29:05 -08001/*
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 Li95917b12019-11-15 11:29:05 -080017#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 Jo4ff8fb02020-02-05 21:56:59 -080024#include "AutomotiveDisplayProxyService.h"
Haoxiang Li95917b12019-11-15 11:29:05 -080025
26// libhidl:
27using android::hardware::configureRpcThreadpool;
28using android::hardware::joinRpcThreadpool;
29
30// Generated HIDL files
Changyeon Jo4ff8fb02020-02-05 21:56:59 -080031using android::frameworks::automotive::display::V1_0::IAutomotiveDisplayProxyService;
Haoxiang Li95917b12019-11-15 11:29:05 -080032
33// The namespace in which all our implementation code lives
34using namespace android::frameworks::automotive::display::V1_0::implementation;
35using namespace android;
36
37const static char kServiceName[] = "default";
38
39int main() {
Changyeon Jo75c8aa92019-12-30 11:12:53 -080040 ALOGI("Automotive Display Proxy Service is starting");
Haoxiang Li95917b12019-11-15 11:29:05 -080041
Changyeon Jo75c8aa92019-12-30 11:12:53 -080042 android::sp<IAutomotiveDisplayProxyService> service =
43 new AutomotiveDisplayProxyService();
Haoxiang Li95917b12019-11-15 11:29:05 -080044
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 Jo75c8aa92019-12-30 11:12:53 -080058 ALOGE("Automotive Window Service is shutting down");
Haoxiang Li95917b12019-11-15 11:29:05 -080059
60 return 1;
61}
62