#[cfg(target_os = "android")]
mod am;
#[cfg(target_os = "android")]
mod display;
#[cfg(target_os = "android")]
mod fps;
#[cfg(target_os = "android")]
mod raw;
#[cfg(target_os = "android")]
mod sys;
#[cfg(target_os = "android")]
mod task_stack;
#[cfg(target_os = "android")]
pub use am::{ActivityManager, TxCodes, last_foreground_pid, resolve_tx_codes};
#[cfg(target_os = "android")]
pub use display::{DisplayInfo, DisplayManager};
#[cfg(target_os = "android")]
pub use fps::FpsListener;
#[cfg(target_os = "android")]
pub use raw::RawBinderService;
#[cfg(target_os = "android")]
pub use task_stack::TaskStackListener;
#[cfg(not(target_os = "android"))]
pub struct ActivityManager;
#[cfg(not(target_os = "android"))]
impl ActivityManager {
pub fn open() -> Result<Self, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn open_with_observer() -> Result<(Self, std::os::fd::OwnedFd), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn open_with_fgproc_observer() -> Result<(Self, std::os::fd::OwnedFd), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn get_focused_task(&self) -> Result<Option<(i32, Option<String>)>, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn get_focused_package(&self) -> Result<Option<String>, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn get_focused_task_id(&self) -> Result<Option<i32>, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
}
#[cfg(not(target_os = "android"))]
pub struct DisplayManager;
#[cfg(not(target_os = "android"))]
impl DisplayManager {
pub fn open_with_callback() -> Result<(Self, crate::fd::Fd), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn is_interactive(&self) -> Result<bool, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn info(&self, _display_id: i32) -> Result<DisplayInfo, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
}
#[cfg(not(target_os = "android"))]
#[derive(Clone, Copy, Debug, PartialEq, Default)]
pub struct DisplayInfo {
pub active_mode_id: i32,
pub vsync_rate: f32,
pub peak_refresh_rate: f32,
pub render_frame_rate: f32,
pub is_interactive: bool,
}
#[cfg(not(target_os = "android"))]
pub struct RawBinderService;
#[cfg(not(target_os = "android"))]
impl RawBinderService {
pub fn open(_service_name: &str) -> Result<Self, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn transact_bool(&self, _code: u32) -> Result<bool, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn transact_i32(&self, _code: u32, _arg: i32) -> Result<(), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
}
#[cfg(not(target_os = "android"))]
pub struct FpsListener;
#[cfg(not(target_os = "android"))]
impl FpsListener {
pub fn open() -> Result<(Self, std::os::fd::OwnedFd), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn register(&mut self, _task_id: i32) -> Result<(), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn unregister(&mut self) -> Result<(), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn last_fps(&self) -> Option<f32> {
None
}
pub fn task_id(&self) -> Option<i32> {
None
}
}
#[cfg(not(target_os = "android"))]
pub struct TaskStackListener;
#[cfg(not(target_os = "android"))]
impl TaskStackListener {
pub fn open() -> Result<(Self, std::os::fd::OwnedFd), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn register(&self) -> Result<(), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
pub fn unregister(&self) -> Result<(), crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
}
#[cfg(not(target_os = "android"))]
pub struct TxCodes {
pub observer_code: u32,
pub query_code: u32,
pub api_mode: u8,
pub fg_code: u32,
}
#[cfg(not(target_os = "android"))]
pub fn resolve_tx_codes() -> Result<TxCodes, crate::CoreError> {
Err(crate::CoreError::binder(-1, "binder:unsupported platform"))
}
#[cfg(not(target_os = "android"))]
pub fn last_foreground_pid() -> i32 {
0
}