blob: 68813c90354aa29d30fadeadb42b51648d1403c5 [file] [log] [blame]
Hao Chen5a97c382019-12-05 15:53: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#include <android-base/logging.h>
Hao Chen5a97c382019-12-05 15:53:05 -080018#include <hidl/HidlTransportSupport.h>
19
20#include <vhal_v2_0/EmulatedVehicleConnector.h>
21#include <vhal_v2_0/EmulatedVehicleHal.h>
22#include <vhal_v2_0/VehicleHalManager.h>
23#include <vhal_v2_0/virtualization/GrpcVehicleClient.h>
24#include <vhal_v2_0/virtualization/Utils.h>
25
26using namespace android;
27using namespace android::hardware;
28using namespace android::hardware::automotive::vehicle::V2_0;
29
30int main(int argc, char* argv[]) {
Enrico Granatac44909d2020-01-24 14:13:52 -080031 namespace vhal_impl = android::hardware::automotive::vehicle::V2_0::impl;
Hao Chen5a97c382019-12-05 15:53:05 -080032
Enrico Granatac44909d2020-01-24 14:13:52 -080033 auto serverInfo = vhal_impl::VsockServerInfo::fromRoPropertyStore();
34 CHECK(serverInfo.has_value()) << "Invalid server CID/port combination";
Hao Chen5a97c382019-12-05 15:53:05 -080035
36 auto store = std::make_unique<VehiclePropertyStore>();
Enrico Granatac44909d2020-01-24 14:13:52 -080037 auto connector = impl::makeGrpcVehicleClient(serverInfo->toUri());
Hao Chen5a97c382019-12-05 15:53:05 -080038 auto hal = std::make_unique<impl::EmulatedVehicleHal>(store.get(), connector.get());
39 auto emulator = std::make_unique<impl::VehicleEmulator>(hal.get());
40 auto service = std::make_unique<VehicleHalManager>(hal.get());
41
42 configureRpcThreadpool(4, true /* callerWillJoin */);
43
44 LOG(INFO) << "Registering as service...";
45 status_t status = service->registerAsService();
46
47 if (status != OK) {
48 LOG(ERROR) << "Unable to register vehicle service (" << status << ")";
49 return 1;
50 }
51
52 LOG(INFO) << "Ready";
53 joinRpcThreadpool();
54
55 return 1;
56}