From 437319e18b119e3b0c1d351e200aa92bbe8eb04d Mon Sep 17 00:00:00 2001 From: Mariia Sandrikova Date: Thu, 13 May 2021 18:26:52 +0100 Subject: [PATCH] Don't clear size compat mode on fold/unfold. With ag/14036667, the displays are turned off during fold and unfold transitions. While screen is off, ActivityRecord#mVisibleRequested is set to false and mCompatDisplatInsets is cleared in onConfigurationChanged > restartProcessIfVisible > clearSizeCompatMode. As a result, unresizable activities don't enter size compat mode after fold/unfold as they should. To address this checking that visibleIgnoringKeyguard is set to false before clearing mCompatDisplayInsets. Fix: 187338605 Test: atest SizeCompatMode Change-Id: I75ea5bba106d04c849e6b7ab446f77fcd8928981 --- services/core/java/com/android/server/wm/ActivityRecord.java | 5 ++++- .../wmtests/src/com/android/server/wm/SizeCompatTests.java | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 667a4fa0ae263..15625bb850620 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7483,7 +7483,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (mVisibleRequested) { // It may toggle the UI for user to restart the size compatibility mode activity. display.handleActivitySizeCompatModeIfNeeded(this); - } else if (mCompatDisplayInsets != null) { + } else if (mCompatDisplayInsets != null && !visibleIgnoringKeyguard) { + // visibleIgnoringKeyguard is checked to avoid clearing mCompatDisplayInsets during + // displays change. Displays are turned off during the change so mVisibleRequested + // can be false. // The override changes can only be obtained from display, because we don't have the // difference of full configuration in each hierarchy. final int displayChanges = display.getCurrentOverrideConfigurationChanges(); diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 0925e12224bef..9bd62c09ac473 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -521,6 +521,7 @@ public class SizeCompatTests extends WindowTestsBase { mActivity.setState(STOPPED, "testSizeCompatMode"); mActivity.mVisibleRequested = false; + mActivity.visibleIgnoringKeyguard = false; mActivity.app.setReportedProcState(ActivityManager.PROCESS_STATE_CACHED_ACTIVITY); // Simulate the display changes orientation.