use crate::{BootClaim, EmulatorState, boot_claim, booted_udids};
pub(crate) async fn claim_before_boot(simctl: &smix_simctl::SimctlClient, udid: &str) -> BootClaim {
let was_up = booted_udids(simctl).await.contains(&udid.to_uppercase());
boot_claim(if was_up {
EmulatorState::AlreadyRunning
} else {
EmulatorState::WasOff
})
}
pub(crate) fn record_simulator_boot(udid: &str, claim: BootClaim) {
let recorded = smix_capsule::runner::machine_leases().and_then(|leases| {
smix_lease::store::record_boot(&leases, udid, claim == BootClaim::ClaimAsOurs)
.map_err(|e| e.to_string())
});
if let Err(e) = recorded {
eprintln!("warning: boot not recorded in the device ledger: {e}");
}
}