From d0bb2106d0f2007f41f8517e4d0347100ae09894 Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Tue, 5 Sep 2023 20:55:33 +0000 Subject: Consider only external displays as pending This prevents foldable devices from seeing internal displays as pending, otherwise the enable dialog would be shown on felix as well after boot. Bug: 299154872 Test: DisplayRepositoryTest Change-Id: Ica21700a68fedc225ac8e4629071308425bde0f1 --- .../display/data/repository/DisplayRepository.kt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'packages/SystemUI/src') diff --git a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt index f68078a8a340..739932a0bd29 100644 --- a/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/display/data/repository/DisplayRepository.kt @@ -174,24 +174,35 @@ constructor( initialValue = emptySet() ) + private val connectedExternalDisplayIds: Flow> = + connectedDisplayIds + .map { connectedDisplayIds -> + connectedDisplayIds + .filter { id -> displayManager.getDisplay(id)?.type == Display.TYPE_EXTERNAL } + .toSet() + } + .flowOn(backgroundCoroutineDispatcher) + .debugLog("connectedExternalDisplayIds") + /** * Pending displays are the ones connected, but not enabled and not ignored. A connected display * is ignored after the user makes the decision to use it or not. For now, the initial decision * from the user is final and not reversible. */ private val pendingDisplayIds: Flow> = - combine(enabledDisplayIds, connectedDisplayIds, ignoredDisplayIds) { + combine(enabledDisplayIds, connectedExternalDisplayIds, ignoredDisplayIds) { enabledDisplaysIds, - connectedDisplayIds, + connectedExternalDisplayIds, ignoredDisplayIds -> if (DEBUG) { Log.d( TAG, - "combining enabled: $enabledDisplaysIds, " + - "connected: $connectedDisplayIds, ignored: $ignoredDisplayIds" + "combining enabled=$enabledDisplaysIds, " + + "connectedExternalDisplayIds=$connectedExternalDisplayIds, " + + "ignored=$ignoredDisplayIds" ) } - connectedDisplayIds - enabledDisplaysIds - ignoredDisplayIds + connectedExternalDisplayIds - enabledDisplaysIds - ignoredDisplayIds } .debugLog("pendingDisplayIds") -- cgit v1.2.3-59-g8ed1b