maauto: fix trusted display flag via reflective fallback
- Commit
94ea1f63351a8392a746f158c56272ce91545389- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-12 23:39 UTC (2 months ago)
- Parents
3d7b69b
Diff
auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.ktindex 8f6b09c4ce..8cf704d613 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.kt@@ -90,7 +90,7 @@ class CarDisplay( // additionally requires ADD_TRUSTED_DISPLAY (the MAOS role); requesting it // without the permission throws, so it rides only on the trusted route. var flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION- if (trusted) flags = flags or DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUSTED+ if (trusted) flags = flags or trustedDisplayFlag() val display = displayManager.createVirtualDisplay( DISPLAY_NAME, width,@@ -592,6 +592,18 @@ class CarDisplay( const val DISPLAY_NAME = "MA Auto" const val TAG = "MaAuto.Display" + /**+ * `VIRTUAL_DISPLAY_FLAG_TRUSTED` by value: hidden before API 36, so read+ * reflectively. Falls back to PRESENTATION-only (private display) where+ * absent, preserving the private-by-default intent; the [Presentation]+ * owned by this app renders fine without it.+ */+ fun trustedDisplayFlag(): Int = try {+ DisplayManager::class.java.getField("VIRTUAL_DISPLAY_FLAG_TRUSTED").getInt(null)+ } catch (_: Exception) {+ 0+ }+ /** * Dev-build validity dump of the virtual display for the Phase 0 probe: * display id, real size, and whether the encoder input surface is live.