rust: properly handle async->async handles
Bug: 293406123
Test: Pending
Change-Id: I270f45a5acced0cb9d55c1a2b2ffa7576923691a
diff --git a/libs/binder/rust/tests/integration.rs b/libs/binder/rust/tests/integration.rs
index 15ae56f..5359832 100644
--- a/libs/binder/rust/tests/integration.rs
+++ b/libs/binder/rust/tests/integration.rs
@@ -182,7 +182,7 @@
proxy: BpTest {
x: i32 = 100
},
- async: IATest,
+ async: IATest(try_into_local_async),
}
}
@@ -323,6 +323,14 @@
}
}
+impl BnTest {
+ fn try_into_local_async<P: binder::BinderAsyncPool + 'static>(
+ me: Binder<BnTest>,
+ ) -> Option<binder::Strong<dyn IATest<P>>> {
+ Some(binder::Strong::new(Box::new(me) as _))
+ }
+}
+
/// Trivial testing binder interface
pub trait ITestSameDescriptor: Interface {}
@@ -900,6 +908,19 @@
assert_eq!(service.test().unwrap(), service_name);
}
+ #[tokio::test]
+ async fn reassociate_rust_binder_async() {
+ let service_name = "testing_service";
+ let service_ibinder =
+ BnTest::new_binder(TestService::new(service_name), BinderFeatures::default())
+ .as_binder();
+
+ let service: Strong<dyn IATest<Tokio>> =
+ service_ibinder.into_interface().expect("Could not reassociate the generic ibinder");
+
+ assert_eq!(service.test().await.unwrap(), service_name);
+ }
+
#[test]
fn weak_binder_upgrade() {
let service_name = "testing_service";