From f18a9641e6d1e7d7b8014ed207f74a4971c78ffa Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Wed, 20 Jan 2021 00:20:47 +0100 Subject: [PATCH] Don't recompute display mode during a mode switch When an app requests a display mode change, it's plausible that the next thing to happen is going to be a configuration change. During the configuration change, multiple windows that contributed to the selection of the display mode will no longer be displayed. This can lead to a device bouncing between two display modes for a while. We need to wait for windows to redraw and for the screen to unfreeze again before we next call DisplayManagerService.setDisplayProperties. Test: atest android.display.cts.DisplayTest Bug: 158316271 Change-Id: I58e4626e74a911a14cbcd426d1f09ef68303dafa --- .../java/com/android/server/wm/DisplayContent.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 73bcf47979fe2..a4c0762f8f924 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -4185,12 +4185,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp mInsetsStateController.getImeSourceProvider().checkShowImePostLayout(); mLastHasContent = mTmpApplySurfaceChangesTransactionState.displayHasContent; - mWmService.mDisplayManagerInternal.setDisplayProperties(mDisplayId, - mLastHasContent, - mTmpApplySurfaceChangesTransactionState.preferredRefreshRate, - mTmpApplySurfaceChangesTransactionState.preferredModeId, - mTmpApplySurfaceChangesTransactionState.preferMinimalPostProcessing, - true /* inTraversal, must call performTraversalInTrans... below */); + if (!mWmService.mDisplayFrozen) { + mWmService.mDisplayManagerInternal.setDisplayProperties(mDisplayId, + mLastHasContent, + mTmpApplySurfaceChangesTransactionState.preferredRefreshRate, + mTmpApplySurfaceChangesTransactionState.preferredModeId, + mTmpApplySurfaceChangesTransactionState.preferMinimalPostProcessing, + true /* inTraversal, must call performTraversalInTrans... below */); + } final boolean wallpaperVisible = mWallpaperController.isWallpaperVisible(); if (wallpaperVisible != mLastWallpaperVisible) {