1 /*
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
17 #define LOG_TAG "automotive.vehicle@2.0-service"
18 #include <android/log.h>
19 #include <hidl/HidlTransportSupport.h>
20
21 #include <iostream>
22
23 #include <vhal_v2_0/EmulatedUserHal.h>
24 #include <vhal_v2_0/EmulatedVehicleConnector.h>
25 #include <vhal_v2_0/EmulatedVehicleHal.h>
26 #include <vhal_v2_0/VehicleHalManager.h>
27
28 using namespace android;
29 using namespace android::hardware;
30 using namespace android::hardware::automotive::vehicle::V2_0;
31
main(int,char * [])32 int main(int /* argc */, char* /* argv */ []) {
33 auto store = std::make_unique<VehiclePropertyStore>();
34 auto connector = std::make_unique<impl::EmulatedVehicleConnector>();
35 auto userHal = connector->getEmulatedUserHal();
36 auto hal = std::make_unique<impl::EmulatedVehicleHal>(store.get(), connector.get(), userHal);
37 auto emulator = std::make_unique<impl::VehicleEmulator>(hal.get());
38 auto service = std::make_unique<VehicleHalManager>(hal.get());
39 connector->setValuePool(hal->getValuePool());
40
41 configureRpcThreadpool(4, true /* callerWillJoin */);
42
43 ALOGI("Registering as service...");
44 status_t status = service->registerAsService();
45
46 if (status != OK) {
47 ALOGE("Unable to register vehicle service (%d)", status);
48 return 1;
49 }
50
51 ALOGI("Ready");
52 joinRpcThreadpool();
53
54 return 1;
55 }
56