MAOS.git
Publicgit clone https://git.maproj.org/MAOS.gitMAOS.git / patches / frameworks_libs_systemui.patch
frameworks_libs_systemui.patch46 lines · 2.4 KiBRaw
| 1 | diff --git a/displaylib/src/com/android/app/displaylib/DisplayRepository.kt b/displaylib/src/com/android/app/displaylib/DisplayRepository.kt |
| 2 | index 4617ca3c..cfc04f16 100644 |
| 3 | --- a/displaylib/src/com/android/app/displaylib/DisplayRepository.kt |
| 4 | +++ b/displaylib/src/com/android/app/displaylib/DisplayRepository.kt |
| 5 | @@ -361,9 +361,7 @@ constructor( |
| 6 | connectedDisplayIds |
| 7 | .map { connectedDisplayIds -> |
| 8 | traceSection("$TAG#filteringExternalDisplays") { |
| 9 | - connectedDisplayIds |
| 10 | - .filter { id -> getDisplayType(id) == Display.TYPE_EXTERNAL } |
| 11 | - .toSet() |
| 12 | + connectedDisplayIds.filter { id -> isExternallyPresented(id) }.toSet() |
| 13 | } |
| 14 | } |
| 15 | .flowOn(backgroundCoroutineDispatcher) |
| 16 | @@ -372,6 +370,30 @@ constructor( |
| 17 | private fun getDisplayType(displayId: Int): Int? = |
| 18 | traceSection("$TAG#getDisplayType") { displayManager.getDisplay(displayId)?.type } |
| 19 | |
| 20 | + /** |
| 21 | + * Whether this display is shown to the user on something other than the built-in screen, and |
| 22 | + * so is worth asking about when it connects. |
| 23 | + * |
| 24 | + * [Display.TYPE_EXTERNAL] is the physical case. A virtual display counts when it carries |
| 25 | + * `FLAG_ALLOWS_CONTENT_MODE_SWITCH`, which means its owner is driving a real sink - a cast |
| 26 | + * receiver, say - and the display can genuinely be either a mirror or a second desktop. That |
| 27 | + * is exactly the question the connection dialog exists to ask, and without this it was only |
| 28 | + * ever asked about displays with a cable. |
| 29 | + * |
| 30 | + * Deliberately narrow: an ordinary virtual display, of which there are many and most of them |
| 31 | + * invisible, does not carry that flag and is not offered. |
| 32 | + */ |
| 33 | + private fun isExternallyPresented(displayId: Int): Boolean = |
| 34 | + traceSection("$TAG#isExternallyPresented") { |
| 35 | + val display = displayManager.getDisplay(displayId) ?: return@traceSection false |
| 36 | + when (display.type) { |
| 37 | + Display.TYPE_EXTERNAL -> true |
| 38 | + Display.TYPE_VIRTUAL -> |
| 39 | + (display.flags and Display.FLAG_ALLOWS_CONTENT_MODE_SWITCH) != 0 |
| 40 | + else -> false |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | private fun getDisplayFromDisplayManager(displayId: Int): Display? = |
| 45 | traceSection("$TAG#getDisplay") { displayManager.getDisplay(displayId) } |
| 46 |