From d68978988b8c769000490526c0a942030d38f854 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Wed, 1 Dec 2021 12:59:56 -0800 Subject: [PATCH] Don't restart processes that host visible activities We chose to restart processes of background activities that can't handle the new configuration changes, but the process may also host foreground activities and by restarting the process foreground activities may also be interrupted. Therefore we should skip restarting the process that has visible activities as well. Bug: 208266661 Test: atest SizeCompatTests#testResetNonVisibleActivity Change-Id: Ifc50999ffad5640be3c6e34062786f2cc1ebf8b5 --- services/core/java/com/android/server/wm/ActivityRecord.java | 3 ++- .../wmtests/src/com/android/server/wm/SizeCompatTests.java | 1 + 2 files changed, 3 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 ffc70da54b7d5..5a82af30e2be9 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7981,7 +7981,8 @@ 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 && !visibleIgnoringKeyguard) { + } else if (mCompatDisplayInsets != null && !visibleIgnoringKeyguard + && (app == null || !app.hasVisibleActivities())) { // visibleIgnoringKeyguard is checked to avoid clearing mCompatDisplayInsets during // displays change. Displays are turned off during the change so mVisibleRequested // can be false. 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 2954d783c1499..645d804b3cfc5 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -535,6 +535,7 @@ public class SizeCompatTests extends WindowTestsBase { mActivity.mVisibleRequested = false; mActivity.visibleIgnoringKeyguard = false; mActivity.app.setReportedProcState(ActivityManager.PROCESS_STATE_CACHED_ACTIVITY); + mActivity.app.computeProcessActivityState(); // Simulate the display changes orientation. final Configuration rotatedConfig = rotateDisplay(display, ROTATION_90);