android_tools/emulator/
mod.rs

1mod emulator_enum;
2mod emulator_tools;
3
4use crate::{error::*, sdk_path_from_env};
5use std::process::Command;
6
7pub use emulator_enum::*;
8pub use emulator_tools::*;
9
10#[derive(Clone, Copy)]
11pub struct Emulator;
12
13impl Emulator {
14    pub fn emulator(self) -> EmulatorTools {
15        EmulatorTools::new()
16    }
17}
18
19/// Find `emulator` executable binary file in SDK and initialize it
20pub fn emulator_tool() -> Result<Command> {
21    if let Ok(emulator_tools) = which::which(bin!("emulator")) {
22        return Ok(Command::new(emulator_tools));
23    }
24    let sdk_path = sdk_path_from_env()?;
25    let build_tools = sdk_path.join("emulator");
26    let emulator = build_tools.join(bin!("emulator"));
27    Ok(Command::new(emulator))
28}