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

Method wm_display_metrics_for_serial

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

Source from the content-addressed store, hash-verified

959 }
960
961 fn wm_display_metrics_for_serial(
962 &self,
963 serial: &str,
964 ) -> Result<AndroidDisplayMetrics, AppError> {
965 let output = self.run_adb(["-s", serial, "shell", "wm", "size"])?;
966 let size = output
967 .split_whitespace()
968 .find(|part| part.contains('x'))
969 .ok_or_else(|| AppError::native("Android emulator did not report a screen size."))?;
970 let (width, height) = size
971 .split_once('x')
972 .ok_or_else(|| AppError::native("Android emulator reported an invalid screen size."))?;
973 let width = width
974 .parse::<f64>()
975 .map_err(|_| AppError::native("Android emulator reported an invalid width."))?;
976 let height = height
977 .parse::<f64>()
978 .map_err(|_| AppError::native("Android emulator reported an invalid height."))?;
979 Ok(AndroidDisplayMetrics {
980 width,
981 height,
982 rotation_quarter_turns: 0,
983 corner_radii: AndroidCornerRadii::ZERO,
984 })
985 }
986
987 fn invalidate_display_metrics_for_serial(&self, serial: &str) {
988 android_display_metrics_cache()

Callers 1

Calls 1

run_adbMethod · 0.80

Tested by

no test coverage detected