#![forbid(unsafe_code)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#[allow(unused_imports)]
use binder::binder_impl::IBinderInternal;
use binder::declare_binder_interface;
declare_binder_interface! {
IResultReceiver["com.android.internal.os.IResultReceiver"] {
native: BnResultReceiver(on_transact),
proxy: BpResultReceiver {
},
async: IResultReceiverAsync,
}
}
pub trait IResultReceiver: binder::Interface + Send {
fn get_descriptor() -> &'static str
where
Self: Sized,
{
"com.android.internal.os.IResultReceiver"
}
fn r#send(
&self,
_arg_resultCode: i32,
_arg_resultData: &crate::mangled::_7_android_2_os_6_Bundle,
) -> binder::Result<()>;
fn getDefaultImpl() -> IResultReceiverDefaultRef
where
Self: Sized,
{
DEFAULT_IMPL.lock().unwrap().clone()
}
fn setDefaultImpl(d: IResultReceiverDefaultRef) -> IResultReceiverDefaultRef
where
Self: Sized,
{
std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
}
}
pub trait IResultReceiverAsync<P>: binder::Interface + Send {
fn get_descriptor() -> &'static str
where
Self: Sized,
{
"com.android.internal.os.IResultReceiver"
}
fn r#send(
&self,
_arg_resultCode: i32,
_arg_resultData: &crate::mangled::_7_android_2_os_6_Bundle,
) -> std::future::Ready<binder::Result<()>>;
}
pub trait IResultReceiverDefault: Send + Sync {
fn r#send(
&self,
_arg_resultCode: i32,
_arg_resultData: &crate::mangled::_7_android_2_os_6_Bundle,
) -> binder::Result<()> {
Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
}
}
pub mod transactions {
pub const r#send: binder::binder_impl::TransactionCode =
binder::binder_impl::FIRST_CALL_TRANSACTION + 0;
}
pub type IResultReceiverDefaultRef = Option<std::sync::Arc<dyn IResultReceiverDefault>>;
use lazy_static::lazy_static;
lazy_static! {
static ref DEFAULT_IMPL: std::sync::Mutex<IResultReceiverDefaultRef> =
std::sync::Mutex::new(None);
}
impl BpResultReceiver {
fn build_parcel_send(
&self,
_arg_resultCode: i32,
_arg_resultData: &crate::mangled::_7_android_2_os_6_Bundle,
) -> binder::Result<binder::binder_impl::Parcel> {
let mut aidl_data = self.binder.prepare_transact()?;
aidl_data.write(&_arg_resultCode)?;
aidl_data.write(_arg_resultData)?;
Ok(aidl_data)
}
fn read_response_send(
&self,
_arg_resultCode: i32,
_arg_resultData: &crate::mangled::_7_android_2_os_6_Bundle,
_aidl_reply: std::result::Result<binder::binder_impl::Parcel, binder::StatusCode>,
) -> binder::Result<()> {
if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
if let Some(_aidl_default_impl) = <Self as IResultReceiver>::getDefaultImpl() {
return _aidl_default_impl.r#send(_arg_resultCode, _arg_resultData);
}
}
let _aidl_reply = _aidl_reply?;
Ok(())
}
}
impl IResultReceiver for BpResultReceiver {
fn r#send(
&self,
_arg_resultCode: i32,
_arg_resultData: &crate::mangled::_7_android_2_os_6_Bundle,
) -> binder::Result<()> {
let _aidl_data = self.build_parcel_send(_arg_resultCode, _arg_resultData)?;
let _aidl_reply = self.binder.submit_transact(
transactions::r#send,
_aidl_data,
binder::binder_impl::FLAG_ONEWAY | binder::binder_impl::FLAG_PRIVATE_LOCAL,
);
self.read_response_send(_arg_resultCode, _arg_resultData, _aidl_reply)
}
}
impl<P: binder::BinderAsyncPool> IResultReceiverAsync<P> for BpResultReceiver {
fn r#send(
&self,
_arg_resultCode: i32,
_arg_resultData: &crate::mangled::_7_android_2_os_6_Bundle,
) -> std::future::Ready<binder::Result<()>> {
let _aidl_data = match self.build_parcel_send(_arg_resultCode, _arg_resultData) {
Ok(_aidl_data) => _aidl_data,
Err(err) => return std::future::ready(Err(err)),
};
let _aidl_reply = self.binder.submit_transact(
transactions::r#send,
_aidl_data,
binder::binder_impl::FLAG_ONEWAY | binder::binder_impl::FLAG_PRIVATE_LOCAL,
);
std::future::ready(self.read_response_send(_arg_resultCode, _arg_resultData, _aidl_reply))
}
}
impl IResultReceiver for binder::binder_impl::Binder<BnResultReceiver> {
fn r#send(
&self,
_arg_resultCode: i32,
_arg_resultData: &crate::mangled::_7_android_2_os_6_Bundle,
) -> binder::Result<()> {
self.0.r#send(_arg_resultCode, _arg_resultData)
}
}
fn on_transact(
_aidl_service: &dyn IResultReceiver,
_aidl_code: binder::binder_impl::TransactionCode,
_aidl_data: &binder::binder_impl::BorrowedParcel<'_>,
_aidl_reply: &mut binder::binder_impl::BorrowedParcel<'_>,
) -> std::result::Result<(), binder::StatusCode> {
match _aidl_code {
transactions::r#send => {
let _arg_resultCode: i32 = _aidl_data.read()?;
let _arg_resultData: crate::mangled::_7_android_2_os_6_Bundle = _aidl_data.read()?;
let _aidl_return = _aidl_service.r#send(_arg_resultCode, &_arg_resultData);
Ok(())
}
_ => Err(binder::StatusCode::UNKNOWN_TRANSACTION),
}
}