From 4f140f96e892b6cfd3f30ac711951b9fb276d713 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 7 Oct 2021 14:44:01 +0100 Subject: [PATCH] Use displayId to determine CHANGE_ACTIVE_SCREEN - Currently CHANGE_ACTIVE_SCREEN is dispatched when rotating too, which is incorrect. mScreenSizeDp is different in portrait and landscape, and varies more than swapping width/height due to different insets applied. Therefore, use the change of unique display id as a signal instead. Fix: 202366729 Test: Rotate device, overview stays Test: Unfold devices, overview goes away Change-Id: Id8a7d4a1e237717521bfc5a5a67f23c4ee801c61 --- src/com/android/launcher3/util/DisplayController.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index 931ecb8086..2068c296dd 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -243,7 +243,7 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S } int change = 0; - if (!newInfo.mScreenSizeDp.equals(oldInfo.mScreenSizeDp)) { + if (!newInfo.displayId.equals(oldInfo.displayId)) { change |= CHANGE_ACTIVE_SCREEN; } if (newInfo.rotation != oldInfo.rotation) { @@ -296,6 +296,7 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S public final Point currentSize; + public String displayId; public final Set supportedBounds = new ArraySet<>(); private final Map> mPerDisplayBounds = new ArrayMap<>(); private final ArrayMap mInternalDisplays; @@ -319,17 +320,17 @@ public class DisplayController implements DisplayListener, ComponentCallbacks, S currentSize = new Point(); display.getRealSize(currentSize); - String myDisplayId = ApiWrapper.getUniqueId(display); + displayId = ApiWrapper.getUniqueId(display); Set currentSupportedBounds = getSupportedBoundsForDisplay(display, currentSize); - mPerDisplayBounds.put(myDisplayId, currentSupportedBounds); + mPerDisplayBounds.put(displayId, currentSupportedBounds); supportedBounds.addAll(currentSupportedBounds); if (ApiWrapper.isInternalDisplay(display) && internalDisplays.size() > 1) { int displayCount = internalDisplays.size(); for (int i = 0; i < displayCount; i++) { String displayKey = internalDisplays.keyAt(i); - if (TextUtils.equals(myDisplayId, displayKey)) { + if (TextUtils.equals(displayId, displayKey)) { continue; }