3 releases

0.1.4 Mar 29, 2024
0.1.3 Mar 23, 2024
0.1.2 Mar 22, 2024
0.1.1 Dec 31, 2023
0.1.0 Dec 31, 2023

#361 in Debugging

MIT license

57KB
1K SLoC

介绍

这个项目是基于openatx/adbutils 使用Rust实现的一个Adb操作相关的库

使用方式

引入依赖

cargo add radb

使用示例

获取设备列表

fn main() {
    let mut adb_client = AdbConnection::default().unwrap();
    let devices = adb_client.list_devices().unwrap();
    devices.iter().for_each(
        |device|{
            println!("{:?}", device);
        }
    )
}

logcat

#[cfg(test)]    
mod test{
    
    use radb::beans::app_info::AppInfo;
    use radb::beans::file_info::FileInfo;
    use radb::client::adb_device::AdbDevice;
    use radb::utils::init_logger;
    
    fn setup() -> AdbDevice{
            init_logger();
            let serial = "emulator-5554";
            let device = AdbDevice::new_device_default(serial);
            device
        }

    #[test]
    fn test_logcat(){
        let mut device = setup();
        let mut mtx = Arc::new(RwLock::new(true));
        let logcat_lock = mtx.clone();
        thread::spawn(
            move ||{
                for i in device.logcat(true, None,logcat_lock).unwrap(){
                    info!("{}", i)
                }
            }
        );
        sleep(Duration::from_secs(10));
        let mut s= mtx.write().unwrap();
        *s = false;
        info!("stop log cat");
    }

已实现功能(对应Python-AdbUtils)

adb device
list_device open_transport
iter_device get_state
get_device_by_serial shell
get_device_by_transport_id forward
server_version forward_list
server_kill reverse
connect adb_output
disconnect push
device create_connection
tcpip
screenshot
switch_screen
switch_airplane_mode
keyevent
switch_wifi
click
swipe
send_keys
wlan_ip
uninstall
install
logcat
...

Crates链接

crates.io

Dependencies

~13–31MB
~430K SLoC