Add VHAL AIDL v1 service.
Test: Local build.
Bug: 198664004
Change-Id: Ifd8b15d85865f360f9cce7b35bc2114f4478682c
diff --git a/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h b/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h
index a8f5ec7..99f6431 100644
--- a/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h
+++ b/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h
@@ -39,6 +39,7 @@
#include <aidl/android/hardware/automotive/vehicle/VehicleLightSwitch.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleOilLevel.h>
#include <aidl/android/hardware/automotive/vehicle/VehiclePropConfig.h>
+#include <aidl/android/hardware/automotive/vehicle/VehiclePropConfigs.h>
#include <aidl/android/hardware/automotive/vehicle/VehiclePropError.h>
#include <aidl/android/hardware/automotive/vehicle/VehiclePropValue.h>
#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
diff --git a/automotive/vehicle/aidl/impl/vhal/Android.bp b/automotive/vehicle/aidl/impl/vhal/Android.bp
new file mode 100644
index 0000000..0a2dc64
--- /dev/null
+++ b/automotive/vehicle/aidl/impl/vhal/Android.bp
@@ -0,0 +1,30 @@
+// Copyright (C) 2021 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.
+
+cc_binary {
+ name: "android.hardware.automotive.vehicle-aidl-default-service",
+ defaults: ["VehicleHalDefaults"],
+ local_include_dirs: ["include"],
+ vintf_fragments: ["vhal-default-service.xml"],
+ init_rc: ["vhal-default-service.rc"],
+ vendor: true,
+ relative_install_path: "hw",
+ srcs: ["src/*.cpp"],
+ static_libs: [
+ "VehicleHalUtils",
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ ],
+}
diff --git a/automotive/vehicle/aidl/impl/vhal/include/DefaultVehicleHal.h b/automotive/vehicle/aidl/impl/vhal/include/DefaultVehicleHal.h
new file mode 100644
index 0000000..49c501e
--- /dev/null
+++ b/automotive/vehicle/aidl/impl/vhal/include/DefaultVehicleHal.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#ifndef android_hardware_automotive_vehicle_aidl_impl_vhal_include_DefaultVehicleHal_H_
+#define android_hardware_automotive_vehicle_aidl_impl_vhal_include_DefaultVehicleHal_H_
+
+#include <aidl/android/hardware/automotive/vehicle/BnVehicle.h>
+
+namespace android {
+namespace hardware {
+namespace automotive {
+namespace vehicle {
+
+class DefaultVehicleHal final : public ::aidl::android::hardware::automotive::vehicle::BnVehicle {
+ ::ndk::ScopedAStatus getAllPropConfigs(
+ ::aidl::android::hardware::automotive::vehicle::VehiclePropConfigs* returnConfigs)
+ override;
+ ::ndk::ScopedAStatus getValues(
+ const std::shared_ptr<::aidl::android::hardware::automotive::vehicle::IVehicleCallback>&
+ callback,
+ const ::aidl::android::hardware::automotive::vehicle::GetValueRequests& requests)
+ override;
+ ::ndk::ScopedAStatus setValues(
+ const std::shared_ptr<::aidl::android::hardware::automotive::vehicle::IVehicleCallback>&
+ callback,
+ const ::aidl::android::hardware::automotive::vehicle::SetValueRequests& requests)
+ override;
+ ::ndk::ScopedAStatus getPropConfigs(
+ const std::vector<int32_t>& props,
+ ::aidl::android::hardware::automotive::vehicle::VehiclePropConfigs* returnConfigs)
+ override;
+ ::ndk::ScopedAStatus subscribe(
+ const std::shared_ptr<::aidl::android::hardware::automotive::vehicle::IVehicleCallback>&
+ callback,
+ const std::vector<::aidl::android::hardware::automotive::vehicle::SubscribeOptions>&
+ options,
+ int32_t maxSharedMemoryFileCount) override;
+ ::ndk::ScopedAStatus unsubscribe(
+ const std::shared_ptr<::aidl::android::hardware::automotive::vehicle::IVehicleCallback>&
+ callback,
+ const std::vector<int32_t>& propIds) override;
+ ::ndk::ScopedAStatus returnSharedMemory(
+ const std::shared_ptr<::aidl::android::hardware::automotive::vehicle::IVehicleCallback>&
+ callback,
+ int64_t sharedMemoryId) override;
+};
+
+} // namespace vehicle
+} // namespace automotive
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_automotive_vehicle_aidl_impl_vhal_include_DefaultVehicleHal_H_
diff --git a/automotive/vehicle/aidl/impl/vhal/src/DefaultVehicleHal.cpp b/automotive/vehicle/aidl/impl/vhal/src/DefaultVehicleHal.cpp
new file mode 100644
index 0000000..5a31643
--- /dev/null
+++ b/automotive/vehicle/aidl/impl/vhal/src/DefaultVehicleHal.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2021 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 "DefaultVehicleHal"
+
+#include <DefaultVehicleHal.h>
+
+#include <VehicleHalTypes.h>
+
+namespace android {
+namespace hardware {
+namespace automotive {
+namespace vehicle {
+
+using ::aidl::android::hardware::automotive::vehicle::GetValueRequests;
+using ::aidl::android::hardware::automotive::vehicle::IVehicleCallback;
+using ::aidl::android::hardware::automotive::vehicle::SetValueRequests;
+using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions;
+using ::aidl::android::hardware::automotive::vehicle::VehiclePropConfigs;
+using ::ndk::ScopedAStatus;
+
+ScopedAStatus DefaultVehicleHal::getAllPropConfigs(VehiclePropConfigs*) {
+ // TODO(b/200737967): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus DefaultVehicleHal::getValues(const std::shared_ptr<IVehicleCallback>&,
+ const GetValueRequests&) {
+ // TODO(b/200737967): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus DefaultVehicleHal::setValues(const std::shared_ptr<IVehicleCallback>&,
+ const SetValueRequests&) {
+ // TODO(b/200737967): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus DefaultVehicleHal::getPropConfigs(const std::vector<int32_t>&, VehiclePropConfigs*) {
+ // TODO(b/200737967): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus DefaultVehicleHal::subscribe(const std::shared_ptr<IVehicleCallback>&,
+ const std::vector<SubscribeOptions>&, int32_t) {
+ // TODO(b/200737967): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus DefaultVehicleHal::unsubscribe(const std::shared_ptr<IVehicleCallback>&,
+ const std::vector<int32_t>&) {
+ // TODO(b/200737967): implement this.
+ return ScopedAStatus::ok();
+}
+
+ScopedAStatus DefaultVehicleHal::returnSharedMemory(const std::shared_ptr<IVehicleCallback>&,
+ int64_t) {
+ // TODO(b/200737967): implement this.
+ return ScopedAStatus::ok();
+}
+
+} // namespace vehicle
+} // namespace automotive
+} // namespace hardware
+} // namespace android
diff --git a/automotive/vehicle/aidl/impl/vhal/src/VehicleService.cpp b/automotive/vehicle/aidl/impl/vhal/src/VehicleService.cpp
new file mode 100644
index 0000000..7c623ea
--- /dev/null
+++ b/automotive/vehicle/aidl/impl/vhal/src/VehicleService.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 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 "VehicleService"
+
+#include <DefaultVehicleHal.h>
+
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <utils/Log.h>
+
+using ::android::hardware::automotive::vehicle::DefaultVehicleHal;
+
+int main(int /* argc */, char* /* argv */[]) {
+ std::shared_ptr<DefaultVehicleHal> vhal = ndk::SharedRefBase::make<DefaultVehicleHal>();
+
+ ALOGI("Registering as service...");
+ binder_exception_t err = AServiceManager_addService(vhal->asBinder().get(),
+ "android.hardware.automotive.vehicle");
+ if (err != EX_NONE) {
+ ALOGE("failed to register android.hardware.automotive.vehicle service, exception: %d", err);
+ return 1;
+ }
+
+ if (!ABinderProcess_setThreadPoolMaxThreadCount(4)) {
+ ALOGE("%s", "failed to set thread pool max thread count");
+ return 1;
+ }
+ ABinderProcess_startThreadPool();
+
+ ALOGI("Vehicle Service Ready");
+
+ ABinderProcess_joinThreadPool();
+
+ ALOGI("Vehicle Service Exiting");
+
+ return 0;
+}
diff --git a/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc b/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc
new file mode 100644
index 0000000..4c8865a
--- /dev/null
+++ b/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc
@@ -0,0 +1,4 @@
+service vendor.vehicle-hal-default /vendor/bin/hw/android.hardware.automotive.vehicle-aidl-default-service
+ class early_hal
+ user vehicle_network
+ group system inet
diff --git a/automotive/vehicle/aidl/impl/vhal/vhal-default-service.xml b/automotive/vehicle/aidl/impl/vhal/vhal-default-service.xml
new file mode 100644
index 0000000..8d237b8
--- /dev/null
+++ b/automotive/vehicle/aidl/impl/vhal/vhal-default-service.xml
@@ -0,0 +1,11 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.automotive.vehicle</name>
+ <transport>hwbinder</transport>
+ <version>1</version>
+ <interface>
+ <name>IVehicle</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>