blob: 2764a26cc1d0f82aaf617d3b9b4fb74ada405ae8 [file] [log] [blame]
Changyeon Jo2400b692019-07-18 21:32:48 -07001/*
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
Changyeon Jo33ba66b2022-01-16 16:33:52 -080017#include "EvsDisplay.h"
18#include "EvsEnumerator.h"
19#include "ServiceNames.h"
Changyeon Jo2400b692019-07-18 21:32:48 -070020
21#include <hidl/HidlTransportSupport.h>
22#include <log/log.h>
23#include <utils/Errors.h>
24#include <utils/StrongPointer.h>
25
Changyeon Jo33ba66b2022-01-16 16:33:52 -080026#include <unistd.h>
Changyeon Jo2400b692019-07-18 21:32:48 -070027
Changyeon Jo33ba66b2022-01-16 16:33:52 -080028using android::frameworks::automotive::display::V1_0::IAutomotiveDisplayProxyService;
Changyeon Jo2400b692019-07-18 21:32:48 -070029using android::hardware::configureRpcThreadpool;
30using android::hardware::joinRpcThreadpool;
Changyeon Jo33ba66b2022-01-16 16:33:52 -080031using android::hardware::automotive::evs::V1_0::DisplayState;
Changyeon Joc6fa0ab2019-10-12 05:25:44 -070032using android::hardware::automotive::evs::V1_1::IEvsEnumerator;
Changyeon Jo33ba66b2022-01-16 16:33:52 -080033using android::hardware::automotive::evs::V1_1::implementation::EvsEnumerator;
Changyeon Jo2400b692019-07-18 21:32:48 -070034
35int main() {
36 ALOGI("EVS Hardware Enumerator service is starting");
Changyeon Jo33ba66b2022-01-16 16:33:52 -080037
38 android::sp<IAutomotiveDisplayProxyService> carWindowService =
39 IAutomotiveDisplayProxyService::getService("default");
40 if (carWindowService == nullptr) {
41 ALOGE("Cannot use AutomotiveDisplayProxyService. Exiting.");
42 return EXIT_FAILURE;
43 }
44
45 android::sp<IEvsEnumerator> service = new EvsEnumerator(carWindowService);
Changyeon Jo2400b692019-07-18 21:32:48 -070046
47 configureRpcThreadpool(1, true /* callerWillJoin */);
48
49 // Register our service -- if somebody is already registered by our name,
50 // they will be killed (their thread pool will throw an exception).
Changyeon Jo33ba66b2022-01-16 16:33:52 -080051 auto status = service->registerAsService(kEnumeratorServiceName);
52 if (status == android::OK) {
Changyeon Jo2400b692019-07-18 21:32:48 -070053 ALOGD("%s is ready.", kEnumeratorServiceName);
54 joinRpcThreadpool();
55 } else {
56 ALOGE("Could not register service %s (%d).", kEnumeratorServiceName, status);
57 }
58
59 // In normal operation, we don't expect the thread pool to exit
60 ALOGE("EVS Hardware Enumerator is shutting down");
Changyeon Jo33ba66b2022-01-16 16:33:52 -080061 return EXIT_SUCCESS;
Changyeon Jo2400b692019-07-18 21:32:48 -070062}