blob: 2968232ed4964428cb05f98d1e0df758bffae28b [file] [log] [blame]
Pavel Maltseva2f426a2016-10-04 10:17:05 -07001/*
2 * Copyright (C) 2016 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
Yu Shan612dbf62021-07-02 18:11:08 -070017#define LOG_TAG "automotive.vehicle@2.0-default-service"
Yifan Hongf9d30342016-11-30 13:45:34 -080018#include <android/log.h>
Martijn Coenen02822372016-12-29 14:03:41 +010019#include <hidl/HidlTransportSupport.h>
Pavel Maltseva2f426a2016-10-04 10:17:05 -070020
21#include <iostream>
22
Yu Shan612dbf62021-07-02 18:11:08 -070023#include <vhal_v2_0/DefaultVehicleConnector.h>
24#include <vhal_v2_0/DefaultVehicleHal.h>
Hao Chenfba3ac82019-11-07 11:55:25 -080025#include <vhal_v2_0/VehicleHalManager.h>
Pavel Maltseva2f426a2016-10-04 10:17:05 -070026
Yu Shan612dbf62021-07-02 18:11:08 -070027using ::android::hardware::automotive::vehicle::V2_0::VehicleHalManager;
28using ::android::hardware::automotive::vehicle::V2_0::VehiclePropertyStore;
29using ::android::hardware::automotive::vehicle::V2_0::impl::DefaultVehicleConnector;
30using ::android::hardware::automotive::vehicle::V2_0::impl::DefaultVehicleHal;
Pavel Maltseva2f426a2016-10-04 10:17:05 -070031
32int main(int /* argc */, char* /* argv */ []) {
Pavel Maltsev33676522017-03-31 13:45:54 -070033 auto store = std::make_unique<VehiclePropertyStore>();
Yu Shan612dbf62021-07-02 18:11:08 -070034 auto connector = std::make_unique<DefaultVehicleConnector>();
35 auto hal = std::make_unique<DefaultVehicleHal>(store.get(), connector.get());
Steven Moreland3b8e60a2022-07-15 22:54:22 +000036 auto service = android::sp<VehicleHalManager>::make(hal.get());
Hao Chenfba3ac82019-11-07 11:55:25 -080037 connector->setValuePool(hal->getValuePool());
Pavel Maltseva2f426a2016-10-04 10:17:05 -070038
Yu Shan612dbf62021-07-02 18:11:08 -070039 android::hardware::configureRpcThreadpool(4, true /* callerWillJoin */);
Martijn Coenen02822372016-12-29 14:03:41 +010040
Pavel Maltseve2603e32016-10-25 16:03:23 -070041 ALOGI("Registering as service...");
Yu Shan612dbf62021-07-02 18:11:08 -070042 android::status_t status = service->registerAsService();
Steven Morelande50f2ef2017-04-26 11:42:24 -070043
Yu Shan612dbf62021-07-02 18:11:08 -070044 if (status != android::OK) {
Steven Morelande50f2ef2017-04-26 11:42:24 -070045 ALOGE("Unable to register vehicle service (%d)", status);
46 return 1;
47 }
Pavel Maltseva2f426a2016-10-04 10:17:05 -070048
49 ALOGI("Ready");
Yu Shan612dbf62021-07-02 18:11:08 -070050 android::hardware::joinRpcThreadpool();
Steven Morelande50f2ef2017-04-26 11:42:24 -070051
Yu Shan612dbf62021-07-02 18:11:08 -070052 return 0;
Pavel Maltseva2f426a2016-10-04 10:17:05 -070053}