Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37e0fd63 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

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
parent d64343cb
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -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",
+2 −2
Original line number Diff line number Diff line
@@ -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) {
+6 −0
Original line number Diff line number Diff line
@@ -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.
+4 −2
Original line number Diff line number Diff line
@@ -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.