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