pub mod android;
pub mod recording;
use std::collections::HashSet;
use std::path::Path;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use crate::error::Result;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppInfo {
pub package: String,
pub label: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Point {
pub x: i32,
pub y: i32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Action {
Tap,
Swipe,
InputText,
PressKey,
Drag,
StartApp,
InstallApp,
Screenshot,
GetUiTree,
GetDate,
GetApps,
ListPackages,
}
#[async_trait]
pub trait DeviceDriver: Send + Sync {
async fn connect(&mut self) -> Result<()>;
async fn ensure_connected(&mut self) -> Result<()>;
async fn tap(&self, x: i32, y: i32) -> Result<()>;
async fn swipe(
&self,
x1: i32,
y1: i32,
x2: i32,
y2: i32,
duration_ms: u32,
) -> Result<()>;
async fn input_text(&self, text: &str, clear: bool) -> Result<bool>;
async fn press_key(&self, keycode: i32) -> Result<()>;
async fn drag(
&self,
x1: i32,
y1: i32,
x2: i32,
y2: i32,
duration_ms: u32,
) -> Result<()>;
async fn start_app(&self, package: &str, activity: Option<&str>) -> Result<String>;
async fn install_app(&self, path: &Path) -> Result<String>;
async fn get_apps(&self, include_system: bool) -> Result<Vec<AppInfo>>;
async fn list_packages(&self, include_system: bool) -> Result<Vec<String>>;
async fn screenshot(&self, hide_overlay: bool) -> Result<Vec<u8>>;
async fn get_ui_tree(&self) -> Result<serde_json::Value>;
async fn get_date(&self) -> Result<String>;
fn supported_actions(&self) -> &HashSet<Action>;
}