fix: minor improvments
This commit is contained in:
@@ -19,8 +19,10 @@ pub enum LocalCommand {
|
||||
/// Run an activity on device specified by the intent
|
||||
Run {
|
||||
/// The package whose activity is to be invoked
|
||||
#[clap(short = 'p', long = "package")]
|
||||
package: String,
|
||||
/// The activity to be invoked itself, Usually it is MainActivity
|
||||
#[clap(short = 'a', long = "activity")]
|
||||
activity: String,
|
||||
},
|
||||
/// Reboot the device
|
||||
|
||||
@@ -37,8 +37,10 @@ pub enum UsbCommands {
|
||||
/// Run an activity on device specified by the intent
|
||||
Run {
|
||||
/// The package whose activity is to be invoked
|
||||
#[clap(short = 'p', long = "package")]
|
||||
package: String,
|
||||
/// The activity to be invoked itself, Usually it is MainActivity
|
||||
#[clap(short = 'a', long = "activity")]
|
||||
activity: String,
|
||||
},
|
||||
/// Reboot the device
|
||||
|
||||
@@ -66,7 +66,8 @@ fn main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
LocalCommand::Run { package, activity } => {
|
||||
device.run_activity(&package, &activity)?;
|
||||
let output = device.run_activity(&package, &activity)?;
|
||||
std::io::stdout().write_all(&output)?;
|
||||
}
|
||||
LocalCommand::HostFeatures => {
|
||||
let features = device
|
||||
@@ -219,7 +220,8 @@ fn main() -> Result<()> {
|
||||
log::info!("Uploaded {filename} to {path}");
|
||||
}
|
||||
UsbCommands::Run { package, activity } => {
|
||||
device.run_activity(&package, &activity)?;
|
||||
let output = device.run_activity(&package, &activity)?;
|
||||
std::io::stdout().write_all(&output)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,14 @@ 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<()> {
|
||||
/// Run `activity` from `package` on device. Return the command output.
|
||||
fn run_activity(&mut self, package: &str, activity: &str) -> Result<Vec<u8>> {
|
||||
let mut output = Vec::new();
|
||||
self.shell_command(
|
||||
["am", "start", &format!("{package}/{package}.{activity}")],
|
||||
std::io::stdout(),
|
||||
)
|
||||
&mut output,
|
||||
)?;
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user