| 1 | # forensic-adb |
| 2 | |
| 3 | Tokio based client library for the Android Debug Bridge (adb) based on mozdevice for Rust. |
| 4 | |
| 5 | [Documentation](https://docs.rs/forensic-adb) |
| 6 | |
| 7 | This code has been extracted from [mozilla-central/testing/mozbase/rust/mozdevice][1] and ported to async Rust. It also removes root detection so no commands are executed on the remote device by default. |
| 8 | |
| 9 | [1]: https://hg.mozilla.org/mozilla-central/file/tip/testing/mozbase/rust/mozdevice |
| 10 | |
| 11 | ```rust |
| 12 | use forensic_adb::{AndroidStorageInput, DeviceError, Host}; |
| 13 | |
| 14 | #[tokio::main] |
| 15 | async fn main() -> Result<(), DeviceError> { |
| 16 | let host = Host::default(); |
| 17 | |
| 18 | let devices = host.devices::<Vec<_>>().await?; |
| 19 | println!("Found devices: {:?}", devices); |
| 20 | |
| 21 | let device = host |
| 22 | .device_or_default(Option::<&String>::None, AndroidStorageInput::default()) |
| 23 | .await?; |
| 24 | println!("Selected device: {:?}", device); |
| 25 | |
| 26 | let output = device.execute_host_shell_command("id").await?; |
| 27 | println!("Received response: {:?}", output); |
| 28 | |
| 29 | Ok(()) |
| 30 | } |
| 31 | ``` |
| 32 | |
| 33 | ## License |
| 34 | |
| 35 | Mozilla Public License (MPL-2.0) |