Shut down game, adb and BlueStacks after capture
This commit is contained in:
parent
3de8bf1f80
commit
f829ad52a4
2 changed files with 27 additions and 0 deletions
|
|
@ -9,6 +9,8 @@
|
|||
serial = "127.0.0.1:5555"
|
||||
# How long to wait for the emulator to come online before giving up
|
||||
wait_secs = 180
|
||||
# Close BlueStacks automatically after the capture finished
|
||||
shutdown_bluestacks = true
|
||||
|
||||
[paths]
|
||||
# Path to adb.exe (empty = auto-detect from LOCALAPPDATA, then PATH)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ struct CaptureConfig {
|
|||
struct DeviceConfig {
|
||||
serial: String,
|
||||
wait_secs: u64,
|
||||
shutdown_bluestacks: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
|
@ -76,6 +77,7 @@ impl Default for DeviceConfig {
|
|||
Self {
|
||||
serial: "127.0.0.1:5555".to_string(),
|
||||
wait_secs: 180,
|
||||
shutdown_bluestacks: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -728,6 +730,14 @@ async fn command_run(config: &CaptureConfig) -> Result<()> {
|
|||
let _ = adb(config, &["reverse", remove_socket.as_str()]);
|
||||
println!("device proxy settings restored");
|
||||
|
||||
println!("stopping {GAME_PACKAGE}");
|
||||
let _ = adb_shell(config, &format!("am force-stop {GAME_PACKAGE}"));
|
||||
let _ = run_adb(config, &["kill-server"]);
|
||||
println!("adb stopped");
|
||||
if config.device.shutdown_bluestacks {
|
||||
close_bluestacks();
|
||||
}
|
||||
|
||||
match outcome {
|
||||
Ok(()) => {
|
||||
println!("capture finished, run `cargo run --bin records -- best` to analyze");
|
||||
|
|
@ -811,6 +821,21 @@ async fn command_clean(config: &CaptureConfig) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn close_bluestacks() {
|
||||
let silent = |args: &[&str]| {
|
||||
let _ = Command::new("taskkill")
|
||||
.args(args)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.status();
|
||||
};
|
||||
silent(&["/IM", "HD-Player.exe"]);
|
||||
std::thread::sleep(Duration::from_secs(5));
|
||||
silent(&["/F", "/IM", "HD-Player.exe"]);
|
||||
println!("BlueStacks closed");
|
||||
}
|
||||
|
||||
fn print_usage() {
|
||||
println!(
|
||||
"usage: capture <command>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue