Loading automotive/vehicle/Android.bp +8 −0 Original line number Diff line number Diff line Loading @@ -25,3 +25,11 @@ cc_defaults { "android.hardware.automotive.vehicle.property-V3-ndk", ], } rust_defaults { name: "VehicleHalInterfaceRustDefaults", rustlibs: [ "android.hardware.automotive.vehicle-V3-rust", "android.hardware.automotive.vehicle.property-V3-rust", ], } automotive/vehicle/aidl/rust_impl/README.md 0 → 100644 +12 −0 Original line number Diff line number Diff line # Rust Skeleton VHAL implementation. WARNING: This is not a reference VHAL implementation and does not contain any actual implementation. This folder contains a skeleton VHAL implementation in Rust to demonstrate how vendor may implement a Rust VHAL. To run this VHAL, include `android.hardware.automotive.vehicle-V3-rust-service` in your image. This implementation returns `StatusCode::UNKNOWN_ERROR` for all operations and does not pass VTS/CTS. Vendor must replace the logic in `default_vehicle_hal.rs` with the actual implementation. automotive/vehicle/aidl/rust_impl/vhal/Android.bp 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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. */ rust_binary { name: "android.hardware.automotive.vehicle-V3-rust-service", relative_install_path: "hw", vendor: true, srcs: ["src/*.rs"], crate_root: "src/main.rs", defaults: ["VehicleHalInterfaceRustDefaults"], vintf_fragments: ["vhal-rust-service.xml"], init_rc: ["vhal-rust-service.rc"], rustlibs: [ "libbinder_rs", ], } automotive/vehicle/aidl/rust_impl/vhal/src/default_vehicle_hal.rs 0 → 100644 +55 −0 Original line number Diff line number Diff line use android_hardware_automotive_vehicle::aidl::android::hardware::automotive::vehicle::{ IVehicle::IVehicle, IVehicleCallback::IVehicleCallback, VehiclePropConfigs::VehiclePropConfigs, GetValueRequests::GetValueRequests, SetValueRequests::SetValueRequests, SubscribeOptions::SubscribeOptions, }; use binder::{Interface, Result as BinderResult, StatusCode, Strong}; /// This struct is defined to implement IVehicle AIDL interface. pub struct DefaultVehicleHal; impl Interface for DefaultVehicleHal {} impl IVehicle for DefaultVehicleHal { fn getAllPropConfigs(&self) -> BinderResult<VehiclePropConfigs> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn getPropConfigs(&self, _props: &[i32]) -> BinderResult<VehiclePropConfigs> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn getValues( &self, _callback: &Strong<dyn IVehicleCallback>, _requests: &GetValueRequests ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn setValues( &self, _callback: &Strong<dyn IVehicleCallback>, _requests: &SetValueRequests ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn subscribe( &self, _callback: &Strong<dyn IVehicleCallback>, _options: &[SubscribeOptions], _max_shared_memory_file_count: i32 ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn unsubscribe( &self, _callback: &Strong<dyn IVehicleCallback>, _prop_ids: &[i32] ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn returnSharedMemory( &self, _callback: &Strong<dyn IVehicleCallback>, _shared_memory_id: i64 ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } } automotive/vehicle/aidl/rust_impl/vhal/src/main.rs 0 → 100644 +18 −0 Original line number Diff line number Diff line mod default_vehicle_hal; use android_hardware_automotive_vehicle::aidl::android::hardware::automotive::vehicle::IVehicle::BnVehicle; use crate::default_vehicle_hal::DefaultVehicleHal; fn main() { binder::ProcessState::start_thread_pool(); let my_service = DefaultVehicleHal; let service_name = "android.hardware.automotive.vehicle.IVehicle/default"; let my_service_binder = BnVehicle::new_binder( my_service, binder::BinderFeatures::default(), ); binder::add_service(service_name, my_service_binder.as_binder()) .expect(format!("Failed to register {}?", service_name).as_str()); // Does not return. binder::ProcessState::join_thread_pool() } Loading
automotive/vehicle/Android.bp +8 −0 Original line number Diff line number Diff line Loading @@ -25,3 +25,11 @@ cc_defaults { "android.hardware.automotive.vehicle.property-V3-ndk", ], } rust_defaults { name: "VehicleHalInterfaceRustDefaults", rustlibs: [ "android.hardware.automotive.vehicle-V3-rust", "android.hardware.automotive.vehicle.property-V3-rust", ], }
automotive/vehicle/aidl/rust_impl/README.md 0 → 100644 +12 −0 Original line number Diff line number Diff line # Rust Skeleton VHAL implementation. WARNING: This is not a reference VHAL implementation and does not contain any actual implementation. This folder contains a skeleton VHAL implementation in Rust to demonstrate how vendor may implement a Rust VHAL. To run this VHAL, include `android.hardware.automotive.vehicle-V3-rust-service` in your image. This implementation returns `StatusCode::UNKNOWN_ERROR` for all operations and does not pass VTS/CTS. Vendor must replace the logic in `default_vehicle_hal.rs` with the actual implementation.
automotive/vehicle/aidl/rust_impl/vhal/Android.bp 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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. */ rust_binary { name: "android.hardware.automotive.vehicle-V3-rust-service", relative_install_path: "hw", vendor: true, srcs: ["src/*.rs"], crate_root: "src/main.rs", defaults: ["VehicleHalInterfaceRustDefaults"], vintf_fragments: ["vhal-rust-service.xml"], init_rc: ["vhal-rust-service.rc"], rustlibs: [ "libbinder_rs", ], }
automotive/vehicle/aidl/rust_impl/vhal/src/default_vehicle_hal.rs 0 → 100644 +55 −0 Original line number Diff line number Diff line use android_hardware_automotive_vehicle::aidl::android::hardware::automotive::vehicle::{ IVehicle::IVehicle, IVehicleCallback::IVehicleCallback, VehiclePropConfigs::VehiclePropConfigs, GetValueRequests::GetValueRequests, SetValueRequests::SetValueRequests, SubscribeOptions::SubscribeOptions, }; use binder::{Interface, Result as BinderResult, StatusCode, Strong}; /// This struct is defined to implement IVehicle AIDL interface. pub struct DefaultVehicleHal; impl Interface for DefaultVehicleHal {} impl IVehicle for DefaultVehicleHal { fn getAllPropConfigs(&self) -> BinderResult<VehiclePropConfigs> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn getPropConfigs(&self, _props: &[i32]) -> BinderResult<VehiclePropConfigs> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn getValues( &self, _callback: &Strong<dyn IVehicleCallback>, _requests: &GetValueRequests ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn setValues( &self, _callback: &Strong<dyn IVehicleCallback>, _requests: &SetValueRequests ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn subscribe( &self, _callback: &Strong<dyn IVehicleCallback>, _options: &[SubscribeOptions], _max_shared_memory_file_count: i32 ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn unsubscribe( &self, _callback: &Strong<dyn IVehicleCallback>, _prop_ids: &[i32] ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } fn returnSharedMemory( &self, _callback: &Strong<dyn IVehicleCallback>, _shared_memory_id: i64 ) -> BinderResult<()> { Err(StatusCode::UNKNOWN_ERROR.into()) } }
automotive/vehicle/aidl/rust_impl/vhal/src/main.rs 0 → 100644 +18 −0 Original line number Diff line number Diff line mod default_vehicle_hal; use android_hardware_automotive_vehicle::aidl::android::hardware::automotive::vehicle::IVehicle::BnVehicle; use crate::default_vehicle_hal::DefaultVehicleHal; fn main() { binder::ProcessState::start_thread_pool(); let my_service = DefaultVehicleHal; let service_name = "android.hardware.automotive.vehicle.IVehicle/default"; let my_service_binder = BnVehicle::new_binder( my_service, binder::BinderFeatures::default(), ); binder::add_service(service_name, my_service_binder.as_binder()) .expect(format!("Failed to register {}?", service_name).as_str()); // Does not return. binder::ProcessState::join_thread_pool() }