summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2022-07-06 18:56:46 +0800
committer Riddle Hsu <riddlehsu@google.com> 2022-07-06 21:16:08 +0800
commita1a11d7044274fa12d712db96d70ddba80ee941c (patch)
tree0764e80b309a91df43686d4dd83be43170b04129
parentc6489d3c5bbf9ddf8337ff0acd76126abfb52054 (diff)
Do not set orientation changing just for screen off
The case happens when screen is off and insetsChanged is true when checking updateResizingWindowIfNeeded for wallpaper window. Then its draw state is set to DRAW_PENDING. But wallpaper won't report draw because its view visibility is always visible and unnecessary to perform relayout for server side visibility change. Then it stuck in DRAW_PENDING state so the surface doesn't show. The orientation changing should be restricted to only take effect for real orientation change, instead of a indirect redraw request. The common way to wait windows to be drawn for screen on should be waitForAllWindowsDrawn. Fixes: 236534213 Test: WindowStateTests#testRequestDrawIfNeeded Test: Launch a show-when-locked activity, enter lock screen and swipe up/down from bottom. Turn off/on screen. Unlock to home and see if wallpaper is visible. Change-Id: I468aa0d1cb2e946b780e09e05aa8746174335685
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java10
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java11
2 files changed, 16 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 06d41c0e8d35..d31dfeed389d 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1020,7 +1020,7 @@ public class WindowManagerService extends IWindowManager.Stub
private int mExitAnimId, mEnterAnimId;
/** The display that the rotation animation is applying to. */
- private int mFrozenDisplayId;
+ private int mFrozenDisplayId = INVALID_DISPLAY;
/** Skip repeated ActivityRecords initialization. Note that AppWindowsToken's version of this
* is a long initialized to Long.MIN_VALUE so that it doesn't match this value on startup. */
@@ -5968,10 +5968,10 @@ public class WindowManagerService extends IWindowManager.Stub
}
void makeWindowFreezingScreenIfNeededLocked(WindowState w) {
- // If the screen is currently frozen or off, then keep
- // it frozen/off until this window draws at its new
- // orientation.
- if (!w.mToken.okToDisplay() && mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
+ // If the screen is currently frozen, then keep it frozen until this window draws at its
+ // new orientation.
+ if (mFrozenDisplayId != INVALID_DISPLAY && mFrozenDisplayId == w.getDisplayId()
+ && mWindowsFreezingScreen != WINDOWS_FREEZING_SCREENS_TIMEOUT) {
ProtoLog.v(WM_DEBUG_ORIENTATION, "Changing surface while display frozen: %s", w);
w.setOrientationChanging(true);
if (mWindowsFreezingScreen == WINDOWS_FREEZING_SCREENS_NONE) {
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
index fb7400bc83ef..cfc0da7a4a15 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -720,6 +720,17 @@ public class WindowStateTests extends WindowTestsBase {
outWaitingForDrawn.clear();
invisibleApp.requestDrawIfNeeded(outWaitingForDrawn);
assertTrue(outWaitingForDrawn.isEmpty());
+
+ // Drawn state should not be changed for insets change when screen is off.
+ spyOn(mWm.mPolicy);
+ doReturn(false).when(mWm.mPolicy).isScreenOn();
+ makeWindowVisibleAndDrawn(startingApp);
+ startingApp.getConfiguration().orientation = 0; // Reset to be the same as last reported.
+ startingApp.getWindowFrames().setInsetsChanged(true);
+ startingApp.updateResizingWindowIfNeeded();
+ assertTrue(mWm.mResizingWindows.contains(startingApp));
+ assertTrue(startingApp.isDrawn());
+ assertFalse(startingApp.getOrientationChanging());
}
@UseTestDisplay(addWindows = W_ABOVE_ACTIVITY)