| 1 | use bstr::ByteSlice; |
| 2 | use forensic_adb::{AndroidStorageInput, DeviceError, Host}; |
| 3 | |
| 4 | #[tokio::main] |
| 5 | async fn main() -> Result<(), DeviceError> { |
| 6 | let host = Host::default(); |
| 7 | |
| 8 | let devices = host.devices::<Vec<_>>().await?; |
| 9 | println!("Found devices: {:?}", devices); |
| 10 | |
| 11 | let device = host |
| 12 | .device_or_default(Option::<&String>::None, AndroidStorageInput::default()) |
| 13 | .await?; |
| 14 | println!("Selected device: {:?}", device); |
| 15 | |
| 16 | let output = device.execute_host_exec_out_command("id").await?; |
| 17 | println!("Received response: {:?}", bstr::BStr::new(&output)); |
| 18 | |
| 19 | let output = device |
| 20 | .execute_host_exec_out_command("pm list packages -f") |
| 21 | .await?; |
| 22 | for line in output.lines() { |
| 23 | println!("Received line: {:?}", bstr::BStr::new(line)); |
| 24 | } |
| 25 | |
| 26 | Ok(()) |
| 27 | } |