MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / display_metrics_for_serial

Method display_metrics_for_serial

packages/server/src/android.rs:943–959  ·  view source on GitHub ↗
(&self, serial: &str)

Source from the content-addressed store, hash-verified

941 }
942
943 fn display_metrics_for_serial(&self, serial: &str) -> Result<AndroidDisplayMetrics, AppError> {
944 let cache = android_display_metrics_cache();
945 if let Some((updated_at, metrics)) = cache.lock().unwrap().get(serial) {
946 if updated_at.elapsed() < SCREEN_SIZE_CACHE_TTL {
947 return Ok(*metrics);
948 }
949 }
950 let output = self.run_adb(["-s", serial, "shell", "dumpsys", "display"])?;
951 let metrics = parse_android_display_metrics(&output)
952 .or_else(|| self.wm_display_metrics_for_serial(serial).ok())
953 .ok_or_else(|| AppError::native("Android emulator did not report display metrics."))?;
954 cache
955 .lock()
956 .unwrap()
957 .insert(serial.to_owned(), (Instant::now(), metrics));
958 Ok(metrics)
959 }
960
961 fn wm_display_metrics_for_serial(
962 &self,

Callers 5

chrome_profileMethod · 0.80
device_valueMethod · 0.80

Calls 6

run_adbMethod · 0.80
insertMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected