1 #![forbid(unsafe_code)]
2 #![rustfmt::skip]
3 #![allow(non_upper_case_globals)]
4 #![allow(non_snake_case)]
5 #[allow(unused_imports)] use binder::binder_impl::IBinderInternal;
6 use binder::declare_binder_interface;
7 declare_binder_interface! {
8 IOldName["android.aidl.tests.IOldName"] {
9 native: BnOldName(on_transact),
10 proxy: BpOldName {
11 },
12 async: IOldNameAsync,
13 }
14 }
15 pub trait IOldName: binder::Interface + Send {
get_descriptor() -> &'static str where Self: Sized16 fn get_descriptor() -> &'static str where Self: Sized { "android.aidl.tests.IOldName" }
17 fn r#RealName(&self) -> binder::Result<String>;
getDefaultImpl() -> IOldNameDefaultRef where Self: Sized18 fn getDefaultImpl() -> IOldNameDefaultRef where Self: Sized {
19 DEFAULT_IMPL.lock().unwrap().clone()
20 }
setDefaultImpl(d: IOldNameDefaultRef) -> IOldNameDefaultRef where Self: Sized21 fn setDefaultImpl(d: IOldNameDefaultRef) -> IOldNameDefaultRef where Self: Sized {
22 std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
23 }
24 }
25 pub trait IOldNameAsync<P>: binder::Interface + Send {
get_descriptor() -> &'static str where Self: Sized26 fn get_descriptor() -> &'static str where Self: Sized { "android.aidl.tests.IOldName" }
27 fn r#RealName<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<String>>;
28 }
29 #[::async_trait::async_trait]
30 pub trait IOldNameAsyncServer: binder::Interface + Send {
get_descriptor() -> &'static str where Self: Sized31 fn get_descriptor() -> &'static str where Self: Sized { "android.aidl.tests.IOldName" }
32 async fn r#RealName(&self) -> binder::Result<String>;
33 }
34 impl BnOldName {
35 /// Create a new async binder service.
new_async_binder<T, R>(inner: T, rt: R, features: binder::BinderFeatures) -> binder::Strong<dyn IOldName> where T: IOldNameAsyncServer + binder::Interface + Send + Sync + 'static, R: binder::binder_impl::BinderAsyncRuntime + Send + Sync + 'static,36 pub fn new_async_binder<T, R>(inner: T, rt: R, features: binder::BinderFeatures) -> binder::Strong<dyn IOldName>
37 where
38 T: IOldNameAsyncServer + binder::Interface + Send + Sync + 'static,
39 R: binder::binder_impl::BinderAsyncRuntime + Send + Sync + 'static,
40 {
41 struct Wrapper<T, R> {
42 _inner: T,
43 _rt: R,
44 }
45 impl<T, R> binder::Interface for Wrapper<T, R> where T: binder::Interface, R: Send + Sync {
46 fn as_binder(&self) -> binder::SpIBinder { self._inner.as_binder() }
47 fn dump(&self, _file: &std::fs::File, _args: &[&std::ffi::CStr]) -> std::result::Result<(), binder::StatusCode> { self._inner.dump(_file, _args) }
48 }
49 impl<T, R> IOldName for Wrapper<T, R>
50 where
51 T: IOldNameAsyncServer + Send + Sync + 'static,
52 R: binder::binder_impl::BinderAsyncRuntime + Send + Sync + 'static,
53 {
54 fn r#RealName(&self) -> binder::Result<String> {
55 self._rt.block_on(self._inner.r#RealName())
56 }
57 }
58 let wrapped = Wrapper { _inner: inner, _rt: rt };
59 Self::new_binder(wrapped, features)
60 }
61 }
62 pub trait IOldNameDefault: Send + Sync {
63 fn r#RealName(&self) -> binder::Result<String> {
64 Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
65 }
66 }
67 pub mod transactions {
68 pub const r#RealName: binder::binder_impl::TransactionCode = binder::binder_impl::FIRST_CALL_TRANSACTION + 0;
69 }
70 pub type IOldNameDefaultRef = Option<std::sync::Arc<dyn IOldNameDefault>>;
71 use lazy_static::lazy_static;
72 lazy_static! {
73 static ref DEFAULT_IMPL: std::sync::Mutex<IOldNameDefaultRef> = std::sync::Mutex::new(None);
74 }
75 impl BpOldName {
build_parcel_RealName(&self) -> binder::Result<binder::binder_impl::Parcel>76 fn build_parcel_RealName(&self) -> binder::Result<binder::binder_impl::Parcel> {
77 let mut aidl_data = self.binder.prepare_transact()?;
78 Ok(aidl_data)
79 }
read_response_RealName(&self, _aidl_reply: std::result::Result<binder::binder_impl::Parcel, binder::StatusCode>) -> binder::Result<String>80 fn read_response_RealName(&self, _aidl_reply: std::result::Result<binder::binder_impl::Parcel, binder::StatusCode>) -> binder::Result<String> {
81 if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
82 if let Some(_aidl_default_impl) = <Self as IOldName>::getDefaultImpl() {
83 return _aidl_default_impl.r#RealName();
84 }
85 }
86 let _aidl_reply = _aidl_reply?;
87 let _aidl_status: binder::Status = _aidl_reply.read()?;
88 if !_aidl_status.is_ok() { return Err(_aidl_status); }
89 let _aidl_return: String = _aidl_reply.read()?;
90 Ok(_aidl_return)
91 }
92 }
93 impl IOldName for BpOldName {
94 fn r#RealName(&self) -> binder::Result<String> {
95 let _aidl_data = self.build_parcel_RealName()?;
96 let _aidl_reply = self.binder.submit_transact(transactions::r#RealName, _aidl_data, binder::binder_impl::FLAG_PRIVATE_LOCAL);
97 self.read_response_RealName(_aidl_reply)
98 }
99 }
100 impl<P: binder::BinderAsyncPool> IOldNameAsync<P> for BpOldName {
101 fn r#RealName<'a>(&'a self) -> binder::BoxFuture<'a, binder::Result<String>> {
102 let _aidl_data = match self.build_parcel_RealName() {
103 Ok(_aidl_data) => _aidl_data,
104 Err(err) => return Box::pin(std::future::ready(Err(err))),
105 };
106 let binder = self.binder.clone();
107 P::spawn(
108 move || binder.submit_transact(transactions::r#RealName, _aidl_data, binder::binder_impl::FLAG_PRIVATE_LOCAL),
109 move |_aidl_reply| async move {
110 self.read_response_RealName(_aidl_reply)
111 }
112 )
113 }
114 }
115 impl IOldName for binder::binder_impl::Binder<BnOldName> {
116 fn r#RealName(&self) -> binder::Result<String> { self.0.r#RealName() }
117 }
on_transact(_aidl_service: &dyn IOldName, _aidl_code: binder::binder_impl::TransactionCode, _aidl_data: &binder::binder_impl::BorrowedParcel<'_>, _aidl_reply: &mut binder::binder_impl::BorrowedParcel<'_>) -> std::result::Result<(), binder::StatusCode>118 fn on_transact(_aidl_service: &dyn IOldName, _aidl_code: binder::binder_impl::TransactionCode, _aidl_data: &binder::binder_impl::BorrowedParcel<'_>, _aidl_reply: &mut binder::binder_impl::BorrowedParcel<'_>) -> std::result::Result<(), binder::StatusCode> {
119 match _aidl_code {
120 transactions::r#RealName => {
121 let _aidl_return = _aidl_service.r#RealName();
122 match &_aidl_return {
123 Ok(_aidl_return) => {
124 _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
125 _aidl_reply.write(_aidl_return)?;
126 }
127 Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
128 }
129 Ok(())
130 }
131 _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
132 }
133 }
134 pub(crate) mod mangled {
135 pub use super::r#IOldName as _7_android_4_aidl_5_tests_8_IOldName;
136 }
137