Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions android-emulator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.1] - 2026-04-01

### Added

- `EmulatorClient::shutdown()` API to request the emulator to perform a graceful shutdown.

### Changes

- `Emulator::terminate()` renamed to `Emulator::kill()` to avoid confusion with the gRPC `Terminate` state that can be requested.

### Fixes

- Look for an 'emulator.exe' binary on Windows
- Ensure that the emulator process is spawned in a job object on Windows, so that emulator.exe and qemu processes can be killed together.

## [0.1.0] - 2026-02-09

### Added

- Initial public release of `android-emulator` crate, providing a Rust interface
to control Android emulators via gRPC.

[unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/olivierlacan/keep-a-changelog/releases/tag/v0.1.0
[unreleased]: https://github.com/rust-mobile/android-emulator-rs/compare/v0.1.1...HEAD
[0.1.1]: https://github.com/rust-mobile/android-emulator-rs/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/rust-mobile/android-emulator-rs/releases/tag/v0.1.0
25 changes: 22 additions & 3 deletions android-emulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-mobile/android-emulator-rs"
documentation = "https://docs.rs/android-emulator"
readme = "README.md"
version = "0.1.0"
version = "0.1.1"
edition = "2024"
include = ["/README.md", "/LICENSE*", "/src/**", "/proto/**", "/examples/**"]

Expand All @@ -15,7 +15,7 @@ tonic = "0.14"
tonic-prost = "0.14"
prost = "0.14"
prost-types = "0.14"
tokio = { version = "1", features = ["fs", "time"] }
tokio = { version = "1", features = ["fs", "time", "process", "io-util"] }
thiserror = "2"
dirs = "5"
adb_client = "3.1"
Expand All @@ -26,12 +26,31 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
uuid = { version = "1", features = ["v4"] }

[target.'cfg(windows)'.dependencies]
win32job = "2"
windows = { version = "0.62", features = [
"Win32_Foundation",
"Win32_System_Threading",
"Win32_System_Diagnostics_ToolHelp",
"Win32_System_JobObjects",
] }

[dev-dependencies]
serial_test = "3"
tokio = { version = "1", features = [
"rt",
"rt-multi-thread",
"time",
"macros",
"process",
"io-util",
] }
test-log = { version = "0.2", features = ["trace"] }
console-subscriber = "0.5"
tracing-subscriber = { version = "0.3", features = [
"fmt",
"env-filter",
"tracing-log",
] }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tokio_unstable)'] }
8 changes: 5 additions & 3 deletions android-emulator/examples/custom_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use std::time::Duration;

#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();

let avds = list_avds().await?;
if avds.is_empty() {
eprintln!(
Expand Down Expand Up @@ -80,9 +82,9 @@ async fn main() -> Result<()> {
result
);

// Terminate the emulator
println!("Terminating emulator...");
instance.terminate().await?;
// Kill the emulator
println!("Killing emulator...");
instance.kill().await?;

Ok(())
}
2 changes: 2 additions & 0 deletions android-emulator/examples/list_emulators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::time::Duration;

#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();

println!("Looking for running emulators...");
let emulators = list_emulators().await?;

Expand Down
10 changes: 6 additions & 4 deletions android-emulator/examples/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use android_emulator::{EmulatorConfig, list_avds, list_emulators};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt::init();

println!("Android Emulator Screenshot Example\n");

let emulators = list_emulators().await?;
Expand Down Expand Up @@ -111,12 +113,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
std::fs::write(filename, &screenshot.image)?;
println!("\nScreenshot saved to: {}", filename);

// Clean up: terminate emulator if we started it
// Clean up: kill emulator if we started it
if instance.is_owned() {
println!("\nTerminating emulator we started...");
instance.terminate().await?;
println!("\nKilling emulator we started...");
instance.kill().await?;
} else {
println!("\nNot terminating emulator since we did not start it");
println!("\nNot killing emulator since we did not start it");
}

Ok(())
Expand Down
13 changes: 10 additions & 3 deletions android-emulator/examples/start_emulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt::init();

let avds = list_avds().await?;
if avds.is_empty() {
eprintln!(
Expand Down Expand Up @@ -46,7 +48,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
Err(e) => {
eprintln!("Error: {}", e);
instance.terminate().await?;
instance.kill().await?;
return Ok(());
}
};
Expand Down Expand Up @@ -118,6 +120,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Touch released");

println!("\nWaiting for emulator to fully boot...");

let elapsed = client
.wait_until_booted(std::time::Duration::from_secs(260), None)
.await?;
Expand All @@ -127,8 +130,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(" uptime: {} ms", status.uptime);
println!(" booted: {:?}", status.booted);

println!("\nTerminating emulator...");
instance.terminate().await?;
println!("\nInitiating graceful shutdown...");
client.shutdown(None).await?;

println!("VM shutdown complete, killing process...");
instance.kill().await?;

println!("Emulator shutdown complete");
Ok(())
}
Loading
Loading