Pavel Maltsev | a2f426a | 2016-10-04 10:17:05 -0700 | [diff] [blame] | 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 | |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 17 | #define LOG_TAG "automotive.vehicle@2.0-default-service" |
Yifan Hong | f9d3034 | 2016-11-30 13:45:34 -0800 | [diff] [blame] | 18 | #include <android/log.h> |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 19 | #include <hidl/HidlTransportSupport.h> |
Pavel Maltsev | a2f426a | 2016-10-04 10:17:05 -0700 | [diff] [blame] | 20 | |
| 21 | #include <iostream> |
| 22 | |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 23 | #include <vhal_v2_0/DefaultVehicleConnector.h> |
| 24 | #include <vhal_v2_0/DefaultVehicleHal.h> |
Hao Chen | fba3ac8 | 2019-11-07 11:55:25 -0800 | [diff] [blame] | 25 | #include <vhal_v2_0/VehicleHalManager.h> |
Pavel Maltsev | a2f426a | 2016-10-04 10:17:05 -0700 | [diff] [blame] | 26 | |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 27 | using ::android::hardware::automotive::vehicle::V2_0::VehicleHalManager; |
| 28 | using ::android::hardware::automotive::vehicle::V2_0::VehiclePropertyStore; |
| 29 | using ::android::hardware::automotive::vehicle::V2_0::impl::DefaultVehicleConnector; |
| 30 | using ::android::hardware::automotive::vehicle::V2_0::impl::DefaultVehicleHal; |
Pavel Maltsev | a2f426a | 2016-10-04 10:17:05 -0700 | [diff] [blame] | 31 | |
| 32 | int main(int /* argc */, char* /* argv */ []) { |
Pavel Maltsev | 3367652 | 2017-03-31 13:45:54 -0700 | [diff] [blame] | 33 | auto store = std::make_unique<VehiclePropertyStore>(); |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 34 | auto connector = std::make_unique<DefaultVehicleConnector>(); |
| 35 | auto hal = std::make_unique<DefaultVehicleHal>(store.get(), connector.get()); |
Steven Moreland | 3b8e60a | 2022-07-15 22:54:22 +0000 | [diff] [blame] | 36 | auto service = android::sp<VehicleHalManager>::make(hal.get()); |
Hao Chen | fba3ac8 | 2019-11-07 11:55:25 -0800 | [diff] [blame] | 37 | connector->setValuePool(hal->getValuePool()); |
Pavel Maltsev | a2f426a | 2016-10-04 10:17:05 -0700 | [diff] [blame] | 38 | |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 39 | android::hardware::configureRpcThreadpool(4, true /* callerWillJoin */); |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 40 | |
Pavel Maltsev | e2603e3 | 2016-10-25 16:03:23 -0700 | [diff] [blame] | 41 | ALOGI("Registering as service..."); |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 42 | android::status_t status = service->registerAsService(); |
Steven Moreland | e50f2ef | 2017-04-26 11:42:24 -0700 | [diff] [blame] | 43 | |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 44 | if (status != android::OK) { |
Steven Moreland | e50f2ef | 2017-04-26 11:42:24 -0700 | [diff] [blame] | 45 | ALOGE("Unable to register vehicle service (%d)", status); |
| 46 | return 1; |
| 47 | } |
Pavel Maltsev | a2f426a | 2016-10-04 10:17:05 -0700 | [diff] [blame] | 48 | |
| 49 | ALOGI("Ready"); |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 50 | android::hardware::joinRpcThreadpool(); |
Steven Moreland | e50f2ef | 2017-04-26 11:42:24 -0700 | [diff] [blame] | 51 | |
Yu Shan | 612dbf6 | 2021-07-02 18:11:08 -0700 | [diff] [blame] | 52 | return 0; |
Pavel Maltsev | a2f426a | 2016-10-04 10:17:05 -0700 | [diff] [blame] | 53 | } |