summaryrefslogtreecommitdiff
path: root/emulator/vhal_v2_0
diff options
context:
space:
mode:
authorYu Shan <shanyu@google.com>2021-07-02 16:34:28 -0700
committerYu Shan <shanyu@google.com>2021-07-16 16:43:20 -0700
commit93eb4511f5c24fad6236cc1f9b5d05cee135c12c (patch)
treea0d6cc0818917944fb242218bf6d792e4bd2eb5d /emulator/vhal_v2_0
parentc8823eb570a052da4e40ddccd6331b8b0d63a209 (diff)
downloadcar-93eb4511f5c24fad6236cc1f9b5d05cee135c12c.tar.gz
Create emulator VehicleService.
Test: Presubmit Bug: 192276902 Change-Id: If43e68da5f91ea1cf240d8b9f487b90702b4c68a
Diffstat (limited to 'emulator/vhal_v2_0')
-rw-r--r--emulator/vhal_v2_0/Android.bp30
-rw-r--r--emulator/vhal_v2_0/VehicleService.cpp54
-rw-r--r--emulator/vhal_v2_0/android.hardware.automotive.vehicle@2.0-emulator-service.rc4
-rw-r--r--emulator/vhal_v2_0/android.hardware.automotive.vehicle@2.0-emulator-service.xml11
4 files changed, 95 insertions, 4 deletions
diff --git a/emulator/vhal_v2_0/Android.bp b/emulator/vhal_v2_0/Android.bp
index 85967a5..9c1a3a5 100644
--- a/emulator/vhal_v2_0/Android.bp
+++ b/emulator/vhal_v2_0/Android.bp
@@ -26,7 +26,7 @@ cc_library_static {
name: "android.hardware.automotive.vehicle@2.0-emulator-impl-lib",
visibility: ["//hardware/interfaces/automotive/vehicle/2.0:__subpackages__"],
vendor: true,
- defaults: ["//hardware/interfaces/automotive/vehicle/2.0/default:vhal_v2_0_target_defaults"],
+ defaults: ["vhal_v2_0_target_defaults"],
cflags: ["-DENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING"],
srcs: [
"CommConn.cpp",
@@ -38,17 +38,39 @@ cc_library_static {
"SocketComm.cpp",
"PipeComm.cpp",
],
- header_libs: ["//hardware/interfaces/automotive/vehicle/2.0/default:vhal_v2_0_common_headers"],
+ header_libs: ["vhal_v2_0_common_headers"],
whole_static_libs: [
- "//hardware/interfaces/automotive/vehicle/2.0/default:android.hardware.automotive.vehicle@2.0-default-impl-lib",
+ "android.hardware.automotive.vehicle@2.0-default-impl-lib",
],
shared_libs: [
"libbase",
"libjsoncpp",
- "//hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/proto:libprotobuf-cpp-lite",
+ "libprotobuf-cpp-lite",
],
export_include_dirs: ["."],
static_libs: [
"android.hardware.automotive.vehicle@2.0-libproto-native",
],
}
+
+cc_binary {
+ name: "android.hardware.automotive.vehicle@2.0-emulator-service",
+ defaults: ["vhal_v2_0_target_defaults"],
+ vintf_fragments: [
+ "android.hardware.automotive.vehicle@2.0-emulator-service.xml",
+ ],
+ init_rc: ["android.hardware.automotive.vehicle@2.0-emulator-service.rc"],
+ vendor: true,
+ relative_install_path: "hw",
+ srcs: ["VehicleService.cpp"],
+ shared_libs: [
+ "libbase",
+ "libjsoncpp",
+ "libprotobuf-cpp-lite",
+ ],
+ static_libs: [
+ "android.hardware.automotive.vehicle@2.0-manager-lib",
+ "android.hardware.automotive.vehicle@2.0-libproto-native",
+ "android.hardware.automotive.vehicle@2.0-emulator-impl-lib",
+ ],
+}
diff --git a/emulator/vhal_v2_0/VehicleService.cpp b/emulator/vhal_v2_0/VehicleService.cpp
new file mode 100644
index 0000000..f26a246
--- /dev/null
+++ b/emulator/vhal_v2_0/VehicleService.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "automotive.vehicle@2.0-emulator-service"
+#include <android/log.h>
+#include <hidl/HidlTransportSupport.h>
+
+#include <iostream>
+
+#include <EmulatedVehicleConnector.h>
+#include <EmulatedVehicleHal.h>
+#include <vhal_v2_0/VehicleHalManager.h>
+
+using ::android::hardware::automotive::vehicle::V2_0::VehicleHalManager;
+using ::android::hardware::automotive::vehicle::V2_0::VehiclePropertyStore;
+using ::android::hardware::automotive::vehicle::V2_0::impl::EmulatedVehicleConnector;
+using ::android::hardware::automotive::vehicle::V2_0::impl::EmulatedVehicleHal;
+
+int main(int /* argc */, char* /* argv */ []) {
+ auto store = std::make_unique<VehiclePropertyStore>();
+ auto connector = std::make_unique<EmulatedVehicleConnector>();
+ auto hal = std::make_unique<EmulatedVehicleHal>(store.get(), connector.get());
+ auto emulator = connector->getEmulator();
+ auto service = std::make_unique<VehicleHalManager>(hal.get());
+ connector->setValuePool(hal->getValuePool());
+
+ android::hardware::configureRpcThreadpool(4, true /* callerWillJoin */);
+
+ ALOGI("Registering as service...");
+ android::status_t status = service->registerAsService();
+
+ if (status != android::OK) {
+ ALOGE("Unable to register vehicle service (%d)", status);
+ return 1;
+ }
+
+ ALOGI("Ready");
+ android::hardware::joinRpcThreadpool();
+
+ return 0;
+}
diff --git a/emulator/vhal_v2_0/android.hardware.automotive.vehicle@2.0-emulator-service.rc b/emulator/vhal_v2_0/android.hardware.automotive.vehicle@2.0-emulator-service.rc
new file mode 100644
index 0000000..1fa2e79
--- /dev/null
+++ b/emulator/vhal_v2_0/android.hardware.automotive.vehicle@2.0-emulator-service.rc
@@ -0,0 +1,4 @@
+service vendor.vehicle-hal-2.0 /vendor/bin/hw/android.hardware.automotive.vehicle@2.0-emulator-service
+ class early_hal
+ user vehicle_network
+ group system inet
diff --git a/emulator/vhal_v2_0/android.hardware.automotive.vehicle@2.0-emulator-service.xml b/emulator/vhal_v2_0/android.hardware.automotive.vehicle@2.0-emulator-service.xml
new file mode 100644
index 0000000..660b03d
--- /dev/null
+++ b/emulator/vhal_v2_0/android.hardware.automotive.vehicle@2.0-emulator-service.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+ <hal format="hidl">
+ <name>android.hardware.automotive.vehicle</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>IVehicle</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>