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"
|
serial = "127.0.0.1:5555"
|
||||||
# How long to wait for the emulator to come online before giving up
|
# How long to wait for the emulator to come online before giving up
|
||||||
wait_secs = 180
|
wait_secs = 180
|
||||||
|
# Close BlueStacks automatically after the capture finished
|
||||||
|
shutdown_bluestacks = true
|
||||||
|
|
||||||
[paths]
|
[paths]
|
||||||
# Path to adb.exe (empty = auto-detect from LOCALAPPDATA, then PATH)
|
# Path to adb.exe (empty = auto-detect from LOCALAPPDATA, then PATH)
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ struct CaptureConfig {
|
||||||
struct DeviceConfig {
|
struct DeviceConfig {
|
||||||
serial: String,
|
serial: String,
|
||||||
wait_secs: u64,
|
wait_secs: u64,
|
||||||
|
shutdown_bluestacks: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
|
@ -76,6 +77,7 @@ impl Default for DeviceConfig {
|
||||||
Self {
|
Self {
|
||||||
serial: "127.0.0.1:5555".to_string(),
|
serial: "127.0.0.1:5555".to_string(),
|
||||||
wait_secs: 180,
|
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()]);
|
let _ = adb(config, &["reverse", remove_socket.as_str()]);
|
||||||
println!("device proxy settings restored");
|
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 {
|
match outcome {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
println!("capture finished, run `cargo run --bin records -- best` to analyze");
|
println!("capture finished, run `cargo run --bin records -- best` to analyze");
|
||||||
|
|
@ -811,6 +821,21 @@ async fn command_clean(config: &CaptureConfig) -> Result<()> {
|
||||||
Ok(())
|
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() {
|
fn print_usage() {
|
||||||
println!(
|
println!(
|
||||||
"usage: capture <command>
|
"usage: capture <command>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue