parseWmDensity function

int? parseWmDensity(
  1. String output
)

Reads the density Android uses for layout from adb shell wm density: the override density when set, else the physical density. Returns null when neither is present.

Implementation

int? parseWmDensity(String output) {
  int? read(String label) {
    final m = RegExp('$label density:\\s*(\\d+)').firstMatch(output);
    return m == null ? null : int.tryParse(m.group(1)!);
  }

  final density = read('Override') ?? read('Physical');
  return density != null && density > 0 ? density : null;
}