diff options
| author | 2023-09-20 23:13:43 +0800 | |
|---|---|---|
| committer | 2023-09-21 11:39:17 +0000 | |
| commit | 37e0fd63c3928c076b93a9b19fd76972b01a6c60 (patch) | |
| tree | 1c942e5dfec7fc054166f58a78a786bebf89df75 | |
| parent | d64343cb4c27f7fdb0e054585306f411a99814cb (diff) | |
Only increase pending relaunch count if schedule is success
Otherwise the client won't report finishRelaunching to decrease
mPendingRelaunchCount and cause ActivityRecord#isSyncFinished
to return false.
Also skip pre-loading recents(home) if its process is still cached
(e.g. intermediate state when switching user). Otherwise the
transaction may be failed by frozen state.
Bug: 301034389
Test: atest RecentsAnimationTest#testPreloadRecentsActivity
Test: Create multiple users with using different font size, wallpaper,
dark theme. Launch several apps on each users. Switch between
the users multiple times. There won't be transition timeout when
returning from other apps to home.
Merged-In: Ia2761e1e9fadf98ab952440ae884c12cc78697c8
Change-Id: Ia2761e1e9fadf98ab952440ae884c12cc78697c8
4 files changed, 12 insertions, 10 deletions
diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 7d5c06cbed1a..13cf82e51b22 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -2047,12 +2047,6 @@ "group": "WM_DEBUG_WINDOW_TRANSITIONS_MIN", "at": "com\/android\/server\/wm\/TransitionController.java" }, - "-262984451": { - "message": "Relaunch failed %s", - "level": "INFO", - "group": "WM_DEBUG_STATES", - "at": "com\/android\/server\/wm\/ActivityRecord.java" - }, "-251259736": { "message": "No longer freezing: %s", "level": "VERBOSE", diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index d231cf300806..ca3a84752fc4 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -9854,7 +9854,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A ProtoLog.i(WM_DEBUG_STATES, "Moving to %s Relaunching %s callers=%s" , (andResume ? "RESUMED" : "PAUSED"), this, Debug.getCallers(6)); forceNewConfig = false; - startRelaunching(); final ClientTransactionItem callbackItem = ActivityRelaunchItem.obtain(pendingResults, pendingNewIntents, configChangeFlags, new MergedConfiguration(getProcessGlobalConfiguration(), @@ -9871,11 +9870,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A transaction.addCallback(callbackItem); transaction.setLifecycleStateRequest(lifecycleItem); mAtmService.getLifecycleManager().scheduleTransaction(transaction); + startRelaunching(); // Note: don't need to call pauseIfSleepingLocked() here, because the caller will only // request resume if this activity is currently resumed, which implies we aren't // sleeping. } catch (RemoteException e) { - ProtoLog.i(WM_DEBUG_STATES, "Relaunch failed %s", e); + Slog.w(TAG, "Failed to relaunch " + this + ": " + e); } if (andResume) { diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java index be9058840492..ee05e355e8ef 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimation.java +++ b/services/core/java/com/android/server/wm/RecentsAnimation.java @@ -16,6 +16,7 @@ package com.android.server.wm; +import static android.app.ActivityManager.PROCESS_STATE_CACHED_ACTIVITY; import static android.app.ActivityManager.START_TASK_TO_FRONT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; @@ -117,6 +118,11 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan return; } if (targetActivity.attachedToProcess()) { + if (targetActivity.app.getCurrentProcState() >= PROCESS_STATE_CACHED_ACTIVITY) { + Slog.v(TAG, "Skip preload recents for cached proc " + targetActivity.app); + // The process may be frozen that cannot receive binder call. + return; + } // The activity may be relaunched if it cannot handle the current configuration // changes. The activity will be paused state if it is relaunched, otherwise it // keeps the original stopped state. diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java index de3a526573f8..491d5b56c8e2 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java @@ -16,6 +16,7 @@ package com.android.server.wm; +import static android.app.ActivityManager.PROCESS_STATE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; @@ -148,8 +149,9 @@ public class RecentsAnimationTest extends WindowTestsBase { anyInt() /* startFlags */, any() /* profilerInfo */); // Assume its process is alive because the caller should be the recents service. - mSystemServicesTestRule.addProcess(aInfo.packageName, aInfo.processName, 12345 /* pid */, - aInfo.applicationInfo.uid); + final WindowProcessController proc = mSystemServicesTestRule.addProcess(aInfo.packageName, + aInfo.processName, 12345 /* pid */, aInfo.applicationInfo.uid); + proc.setCurrentProcState(PROCESS_STATE_HOME); Intent recentsIntent = new Intent().setComponent(mRecentsComponent); // Null animation indicates to preload. |