diff options
Diffstat (limited to 'tests/rust/test_service_async.rs')
-rw-r--r-- | tests/rust/test_service_async.rs | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/tests/rust/test_service_async.rs b/tests/rust/test_service_async.rs index cfc0f285..8ae3906c 100644 --- a/tests/rust/test_service_async.rs +++ b/tests/rust/test_service_async.rs @@ -24,9 +24,10 @@ use aidl_test_interface::aidl::android::aidl::tests::ITestService::{ }; use aidl_test_interface::aidl::android::aidl::tests::{ extension::ExtendableParcelable::ExtendableParcelable, extension::MyExt::MyExt, - BackendType::BackendType, ByteEnum::ByteEnum, ConstantExpressionEnum::ConstantExpressionEnum, - INamedCallback, INewName, IOldName, IntEnum::IntEnum, LongEnum::LongEnum, - RecursiveList::RecursiveList, StructuredParcelable, Union, + BackendType::BackendType, ByteEnum::ByteEnum, CircularParcelable::CircularParcelable, + ConstantExpressionEnum::ConstantExpressionEnum, ICircular, INamedCallback, INewName, IOldName, + IntEnum::IntEnum, LongEnum::LongEnum, RecursiveList::RecursiveList, StructuredParcelable, + Union, }; use aidl_test_interface::binder::{ self, BinderFeatures, Interface, ParcelFileDescriptor, SpIBinder, @@ -78,6 +79,20 @@ impl INewName::INewNameAsyncServer for NewName { } } +#[derive(Debug, Default)] +struct Circular; + +impl Interface for Circular {} + +#[async_trait] +impl ICircular::ICircularAsyncServer for Circular { + async fn GetTestService( + &self, + ) -> binder::Result<Option<binder::Strong<dyn ITestService::ITestService>>> { + Ok(None) + } +} + #[derive(Default)] struct TestService { service_map: Mutex<HashMap<String, binder::Strong<dyn INamedCallback::INamedCallback>>>, @@ -202,6 +217,21 @@ impl ITestService::ITestServiceAsyncServer for TestService { Ok(other_service.to_owned()) } + async fn SetOtherTestService( + &self, + name: &str, + service: &binder::Strong<dyn INamedCallback::INamedCallback>, + ) -> binder::Result<bool> { + let mut service_map = self.service_map.lock().unwrap(); + if let Some(existing_service) = service_map.get(name) { + if existing_service == service { + return Ok(true); + } + } + service_map.insert(name.into(), service.clone()); + Ok(false) + } + async fn VerifyName( &self, service: &binder::Strong<dyn INamedCallback::INamedCallback>, @@ -505,6 +535,13 @@ impl ITestService::ITestServiceAsyncServer for TestService { async fn getBackendType(&self) -> binder::Result<BackendType> { Ok(BackendType::RUST) } + + async fn GetCircular( + &self, + _: &mut CircularParcelable, + ) -> binder::Result<binder::Strong<dyn ICircular::ICircular>> { + Ok(ICircular::BnCircular::new_async_binder(Circular, rt(), BinderFeatures::default())) + } } struct FooInterface; |