diff --git a/adb_cli/src/commands/local.rs b/adb_cli/src/commands/local.rs index 23fa84a..941c2fd 100644 --- a/adb_cli/src/commands/local.rs +++ b/adb_cli/src/commands/local.rs @@ -18,8 +18,10 @@ pub enum LocalCommand { Shell { commands: Vec }, /// Run an activity on device specified by the intent Run { - /// The activity intent to be invoked, it is most commonly packagename/packagename.MainActivity - intent: String, + /// The package whose activity is to be invoked + package: String, + /// The activity to be invoked itself, Usually it is MainActivity + activity: String, }, /// Reboot the device Reboot { diff --git a/adb_cli/src/commands/usb.rs b/adb_cli/src/commands/usb.rs index 15e6ed4..2acaad7 100644 --- a/adb_cli/src/commands/usb.rs +++ b/adb_cli/src/commands/usb.rs @@ -36,8 +36,10 @@ pub enum UsbCommands { Stat { path: String }, /// Run an activity on device specified by the intent Run { - /// The activity intent to be invoked, it is most commonly packagename/packagename.MainActivity - intent: String, + /// The package whose activity is to be invoked + package: String, + /// The activity to be invoked itself, Usually it is MainActivity + activity: String, }, /// Reboot the device Reboot { diff --git a/adb_cli/src/main.rs b/adb_cli/src/main.rs index 2340072..9e3d2e5 100644 --- a/adb_cli/src/main.rs +++ b/adb_cli/src/main.rs @@ -65,8 +65,8 @@ fn main() -> Result<()> { device.shell_command(commands, std::io::stdout())?; } } - LocalCommand::Run { intent } => { - device.shell_command(["am", "start", &intent], std::io::stdout())?; + LocalCommand::Run { package, activity } => { + device.run_activity(&package, &activity)?; } LocalCommand::HostFeatures => { let features = device @@ -218,8 +218,8 @@ fn main() -> Result<()> { device.push(&mut input, &path)?; log::info!("Uploaded {filename} to {path}"); } - UsbCommands::Run { intent } => { - device.shell_command(["am", "start", &intent], std::io::stdout())?; + UsbCommands::Run { package, activity } => { + device.run_activity(&package, &activity)?; } } } diff --git a/adb_client/src/adb_device_ext.rs b/adb_client/src/adb_device_ext.rs index b392ced..10be474 100644 --- a/adb_client/src/adb_device_ext.rs +++ b/adb_client/src/adb_device_ext.rs @@ -28,4 +28,12 @@ pub trait ADBDeviceExt { /// Reboots the device using given reboot type fn reboot(&mut self, reboot_type: RebootType) -> Result<()>; + + /// Run an `activity` from a given `package` on device + fn run_activity(&mut self, package: &str, activity: &str) -> Result<()> { + self.shell_command( + ["am", "start", &format!("{package}/{package}.{activity}")], + std::io::stdout(), + ) + } }