MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / running_emulators

Method running_emulators

packages/server/src/android.rs:858–877  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

856 }
857
858 fn running_emulators(&self) -> Result<HashMap<String, String>, AppError> {
859 static CACHE: OnceLock<Mutex<TimedMap<String>>> = OnceLock::new();
860 let cache = CACHE.get_or_init(|| Mutex::new(None));
861 if let Some((updated_at, running)) = cache.lock().unwrap().as_ref() {
862 if updated_at.elapsed() < RUNNING_EMULATOR_CACHE_TTL {
863 return Ok(running.clone());
864 }
865 }
866 if !self.adb_path().exists() {
867 return Ok(HashMap::new());
868 }
869 let mut result = HashMap::new();
870 for serial in self.online_emulator_serials()? {
871 if let Some(name) = self.avd_name_for_serial(&serial) {
872 result.insert(name, serial);
873 }
874 }
875 *cache.lock().unwrap() = Some((Instant::now(), result.clone()));
876 Ok(result)
877 }
878
879 fn online_emulator_serials(&self) -> Result<Vec<String>, AppError> {
880 Ok(parse_online_emulator_serials(&self.run_adb(["devices"])?))

Callers 2

list_devicesMethod · 0.80
resolve_serialMethod · 0.80

Calls 5

adb_pathMethod · 0.80
avd_name_for_serialMethod · 0.80
insertMethod · 0.80
cloneMethod · 0.65

Tested by

no test coverage detected