1a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev/*
2a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * Copyright (C) 2016 The Android Open Source Project
3a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev *
4a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * Licensed under the Apache License, Version 2.0 (the "License");
5a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * you may not use this file except in compliance with the License.
6a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * You may obtain a copy of the License at
7a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev *
8a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev *      http://www.apache.org/licenses/LICENSE-2.0
9a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev *
10a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * Unless required by applicable law or agreed to in writing, software
11a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * distributed under the License is distributed on an "AS IS" BASIS,
12a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * See the License for the specific language governing permissions and
14a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev * limitations under the License.
15a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev */
16a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev
172579fb792b4d47555515459f372f63c4305ee2caPavel Maltsev#define LOG_TAG "automotive.vehicle@2.0-service"
18f9d303435d80161fabb16cdff3b8f2f75f362480Yifan Hong#include <android/log.h>
19028223775be7539c5b569a454524584a7ad8e152Martijn Coenen#include <hidl/HidlTransportSupport.h>
20a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev
21a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev#include <iostream>
22a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev
23c5344ac04c430486633521098fdb63887546a32aPavel Maltsev#include <vhal_v2_0/VehicleHalManager.h>
2433676528f85f29906b5875cfc5d28b4639402afdPavel Maltsev#include <vhal_v2_0/EmulatedVehicleHal.h>
25a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev
26a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsevusing namespace android;
27a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsevusing namespace android::hardware;
282579fb792b4d47555515459f372f63c4305ee2caPavel Maltsevusing namespace android::hardware::automotive::vehicle::V2_0;
29a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev
30a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsevint main(int /* argc */, char* /* argv */ []) {
3133676528f85f29906b5875cfc5d28b4639402afdPavel Maltsev    auto store = std::make_unique<VehiclePropertyStore>();
3233676528f85f29906b5875cfc5d28b4639402afdPavel Maltsev    auto hal = std::make_unique<impl::EmulatedVehicleHal>(store.get());
3333676528f85f29906b5875cfc5d28b4639402afdPavel Maltsev    auto emulator = std::make_unique<impl::VehicleEmulator>(hal.get());
34e2603e3d52dbd505cdda20a8111f45bf833d674aPavel Maltsev    auto service = std::make_unique<VehicleHalManager>(hal.get());
35e2603e3d52dbd505cdda20a8111f45bf833d674aPavel Maltsev
360e251c88057153c5b49cc8b88dec803c3658df59Pavel Maltsev    configureRpcThreadpool(4, true /* callerWillJoin */);
37028223775be7539c5b569a454524584a7ad8e152Martijn Coenen
38e2603e3d52dbd505cdda20a8111f45bf833d674aPavel Maltsev    ALOGI("Registering as service...");
39e50f2efab5b1f42e6a908272458975c8bced0cdbSteven Moreland    status_t status = service->registerAsService();
40e50f2efab5b1f42e6a908272458975c8bced0cdbSteven Moreland
41e50f2efab5b1f42e6a908272458975c8bced0cdbSteven Moreland    if (status != OK) {
42e50f2efab5b1f42e6a908272458975c8bced0cdbSteven Moreland        ALOGE("Unable to register vehicle service (%d)", status);
43e50f2efab5b1f42e6a908272458975c8bced0cdbSteven Moreland        return 1;
44e50f2efab5b1f42e6a908272458975c8bced0cdbSteven Moreland    }
45a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev
46a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev    ALOGI("Ready");
47028223775be7539c5b569a454524584a7ad8e152Martijn Coenen    joinRpcThreadpool();
48e50f2efab5b1f42e6a908272458975c8bced0cdbSteven Moreland
49e50f2efab5b1f42e6a908272458975c8bced0cdbSteven Moreland    return 1;
50a2f426ab27771055d1762ef5f196f23462e7c53ePavel Maltsev}
51