#![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! {
IPowerStatsService["android.os.IPowerStatsService"] {
native: BnPowerStatsService(on_transact),
proxy: BpPowerStatsService {
},
async: IPowerStatsServiceAsync,
}
}
pub trait IPowerStatsService: binder::Interface + Send {
fn get_descriptor() -> &'static str
where
Self: Sized,
{
"android.os.IPowerStatsService"
}
fn getSupportedPowerMonitors(
&self,
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<()>;
fn getPowerMonitorReadings(
&self,
_arg_powerMonitorIndices: &[i32],
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<()>;
fn getDefaultImpl() -> IPowerStatsServiceDefaultRef
where
Self: Sized,
{
DEFAULT_IMPL.lock().unwrap().clone()
}
fn setDefaultImpl(d: IPowerStatsServiceDefaultRef) -> IPowerStatsServiceDefaultRef
where
Self: Sized,
{
std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
}
}
pub trait IPowerStatsServiceAsync<P>: binder::Interface + Send {
fn get_descriptor() -> &'static str
where
Self: Sized,
{
"android.os.IPowerStatsService"
}
fn getSupportedPowerMonitors(
&self,
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> std::future::Ready<binder::Result<()>>;
fn getPowerMonitorReadings(
&self,
_arg_powerMonitorIndices: &[i32],
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> std::future::Ready<binder::Result<()>>;
}
pub trait IPowerStatsServiceDefault: Send + Sync {
fn getSupportedPowerMonitors(
&self,
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<()> {
Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
}
fn getPowerMonitorReadings(
&self,
_arg_powerMonitorIndices: &[i32],
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<()> {
Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
}
}
pub mod transactions {
pub const getSupportedPowerMonitors: binder::binder_impl::TransactionCode =
binder::binder_impl::FIRST_CALL_TRANSACTION + 0;
pub const getPowerMonitorReadings: binder::binder_impl::TransactionCode =
binder::binder_impl::FIRST_CALL_TRANSACTION + 1;
}
pub type IPowerStatsServiceDefaultRef = Option<std::sync::Arc<dyn IPowerStatsServiceDefault>>;
use lazy_static::lazy_static;
lazy_static! {
static ref DEFAULT_IMPL: std::sync::Mutex<IPowerStatsServiceDefaultRef> =
std::sync::Mutex::new(None);
}
pub const KEY_MONITORS: &str = "monitors";
pub const KEY_ENERGY: &str = "energy";
pub const KEY_TIMESTAMPS: &str = "timestamps";
pub const RESULT_SUCCESS: i32 = 0;
pub const RESULT_UNSUPPORTED_POWER_MONITOR: i32 = 1;
impl BpPowerStatsService {
fn build_parcel_getSupportedPowerMonitors(
&self,
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<binder::binder_impl::Parcel> {
let mut aidl_data = self.binder.prepare_transact()?;
aidl_data.write(_arg_resultReceiver)?;
Ok(aidl_data)
}
fn read_response_getSupportedPowerMonitors(
&self,
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
_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 IPowerStatsService>::getDefaultImpl() {
return _aidl_default_impl.getSupportedPowerMonitors(_arg_resultReceiver);
}
}
let _aidl_reply = _aidl_reply?;
Ok(())
}
fn build_parcel_getPowerMonitorReadings(
&self,
_arg_powerMonitorIndices: &[i32],
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<binder::binder_impl::Parcel> {
let mut aidl_data = self.binder.prepare_transact()?;
aidl_data.write(_arg_powerMonitorIndices)?;
aidl_data.write(_arg_resultReceiver)?;
Ok(aidl_data)
}
fn read_response_getPowerMonitorReadings(
&self,
_arg_powerMonitorIndices: &[i32],
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
_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 IPowerStatsService>::getDefaultImpl() {
return _aidl_default_impl
.getPowerMonitorReadings(_arg_powerMonitorIndices, _arg_resultReceiver);
}
}
let _aidl_reply = _aidl_reply?;
Ok(())
}
}
impl IPowerStatsService for BpPowerStatsService {
fn getSupportedPowerMonitors(
&self,
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<()> {
let _aidl_data = self.build_parcel_getSupportedPowerMonitors(_arg_resultReceiver)?;
let _aidl_reply = self.binder.submit_transact(
transactions::getSupportedPowerMonitors,
_aidl_data,
binder::binder_impl::FLAG_ONEWAY | binder::binder_impl::FLAG_PRIVATE_LOCAL,
);
self.read_response_getSupportedPowerMonitors(_arg_resultReceiver, _aidl_reply)
}
fn getPowerMonitorReadings(
&self,
_arg_powerMonitorIndices: &[i32],
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<()> {
let _aidl_data = self
.build_parcel_getPowerMonitorReadings(_arg_powerMonitorIndices, _arg_resultReceiver)?;
let _aidl_reply = self.binder.submit_transact(
transactions::getPowerMonitorReadings,
_aidl_data,
binder::binder_impl::FLAG_ONEWAY | binder::binder_impl::FLAG_PRIVATE_LOCAL,
);
self.read_response_getPowerMonitorReadings(
_arg_powerMonitorIndices,
_arg_resultReceiver,
_aidl_reply,
)
}
}
impl<P: binder::BinderAsyncPool> IPowerStatsServiceAsync<P> for BpPowerStatsService {
fn getSupportedPowerMonitors(
&self,
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> std::future::Ready<binder::Result<()>> {
let _aidl_data = match self.build_parcel_getSupportedPowerMonitors(_arg_resultReceiver) {
Ok(_aidl_data) => _aidl_data,
Err(err) => return std::future::ready(Err(err)),
};
let _aidl_reply = self.binder.submit_transact(
transactions::getSupportedPowerMonitors,
_aidl_data,
binder::binder_impl::FLAG_ONEWAY | binder::binder_impl::FLAG_PRIVATE_LOCAL,
);
std::future::ready(
self.read_response_getSupportedPowerMonitors(_arg_resultReceiver, _aidl_reply),
)
}
fn getPowerMonitorReadings(
&self,
_arg_powerMonitorIndices: &[i32],
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> std::future::Ready<binder::Result<()>> {
let _aidl_data = match self
.build_parcel_getPowerMonitorReadings(_arg_powerMonitorIndices, _arg_resultReceiver)
{
Ok(_aidl_data) => _aidl_data,
Err(err) => return std::future::ready(Err(err)),
};
let _aidl_reply = self.binder.submit_transact(
transactions::getPowerMonitorReadings,
_aidl_data,
binder::binder_impl::FLAG_ONEWAY | binder::binder_impl::FLAG_PRIVATE_LOCAL,
);
std::future::ready(self.read_response_getPowerMonitorReadings(
_arg_powerMonitorIndices,
_arg_resultReceiver,
_aidl_reply,
))
}
}
impl IPowerStatsService for binder::binder_impl::Binder<BnPowerStatsService> {
fn getSupportedPowerMonitors(
&self,
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<()> {
self.0.getSupportedPowerMonitors(_arg_resultReceiver)
}
fn getPowerMonitorReadings(
&self,
_arg_powerMonitorIndices: &[i32],
_arg_resultReceiver: &crate::mangled::_7_android_2_os_14_ResultReceiver,
) -> binder::Result<()> {
self.0
.getPowerMonitorReadings(_arg_powerMonitorIndices, _arg_resultReceiver)
}
}
fn on_transact(
_aidl_service: &dyn IPowerStatsService,
_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::getSupportedPowerMonitors => {
let _arg_resultReceiver: crate::mangled::_7_android_2_os_14_ResultReceiver =
_aidl_data.read()?;
let _aidl_return = _aidl_service.getSupportedPowerMonitors(&_arg_resultReceiver);
Ok(())
}
transactions::getPowerMonitorReadings => {
let _arg_powerMonitorIndices: Vec<i32> = _aidl_data.read()?;
let _arg_resultReceiver: crate::mangled::_7_android_2_os_14_ResultReceiver =
_aidl_data.read()?;
let _aidl_return = _aidl_service
.getPowerMonitorReadings(&_arg_powerMonitorIndices, &_arg_resultReceiver);
Ok(())
}
_ => Err(binder::StatusCode::UNKNOWN_TRANSACTION),
}
}
pub(crate) mod mangled {
pub use super::IPowerStatsService as _7_android_2_os_18_IPowerStatsService;
}