blob: 626c1852c986148ba534f622016af334f00791db [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
17#define LOG_TAG "AutomotiveDisplayService"
18
19#include <unistd.h>
20
21#include <hidl/HidlTransportSupport.h>
22#include <log/log.h>
23#include <utils/Errors.h>
24#include <utils/StrongPointer.h>
25
Changyeon Jo4ff8fb02020-02-05 21:56:59 -080026#include "AutomotiveDisplayProxyService.h"
Haoxiang Li95917b12019-11-15 11:29:05 -080027
28// libhidl:
29using android::hardware::configureRpcThreadpool;
30using android::hardware::joinRpcThreadpool;
31
32// Generated HIDL files
Changyeon Jo4ff8fb02020-02-05 21:56:59 -080033using android::frameworks::automotive::display::V1_0::IAutomotiveDisplayProxyService;
Haoxiang Li95917b12019-11-15 11:29:05 -080034
35// The namespace in which all our implementation code lives
36using namespace android::frameworks::automotive::display::V1_0::implementation;
37using namespace android;
38
39const static char kServiceName[] = "default";
40
41int main() {
42 ALOGI("Car Window Service is starting");
43
Changyeon Jo4ff8fb02020-02-05 21:56:59 -080044 android::sp<IAutomotiveDisplayProxyService> service = new AutomotiveDisplayProxyService();
Haoxiang Li95917b12019-11-15 11:29:05 -080045
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(kServiceName);
51 if (status == OK) {
52 ALOGD("%s is ready.", kServiceName);
53 joinRpcThreadpool();
54 } else {
55 ALOGE("Could not register service %s (%d).", kServiceName, status);
56 }
57
58 // In normal operation, we don't expect the thread pool to exit
59 ALOGE("Car Window Service is shutting down");
60
61 return 1;
62}
63