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

Commit 29b5e40a authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Support of restart process of non-top visible activity"

parents 0deb47fd 8ef7d3fa
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import static com.android.server.wm.ActivityRecord.State.DESTROYING;
import static com.android.server.wm.ActivityRecord.State.PAUSING;
import static com.android.server.wm.ActivityRecord.State.RESTARTING_PROCESS;
import static com.android.server.wm.ActivityRecord.State.RESUMED;
import static com.android.server.wm.ActivityRecord.State.STOPPING;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_ALL;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_SWITCH;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
@@ -240,11 +241,21 @@ class ActivityClientController extends IActivityClientController.Stub {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "activityStopped");
            r = ActivityRecord.isInRootTaskLocked(token);
            if (r != null) {
                if (!r.isState(STOPPING, RESTARTING_PROCESS)
                        && mTaskSupervisor.hasScheduledRestartTimeouts(r)) {
                    // Recover the restarting state which was replaced by other lifecycle changes.
                    r.setState(RESTARTING_PROCESS, "continue-restart");
                }
                if (r.attachedToProcess() && r.isState(RESTARTING_PROCESS)) {
                    // The activity was requested to restart from
                    // {@link #restartActivityProcessIfVisible}.
                    restartingName = r.app.mName;
                    restartingUid = r.app.mUid;
                    // Make EnsureActivitiesVisibleHelper#makeVisibleAndRestartIfNeeded not skip
                    // restarting non-top activity.
                    if (r != r.getTask().topRunningActivity()) {
                        r.setVisibleRequested(false);
                    }
                }
                r.activityStopped(icicle, persistentState, description);
            }
+4 −0
Original line number Diff line number Diff line
@@ -2297,6 +2297,10 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        mHandler.sendEmptyMessageDelayed(SLEEP_TIMEOUT_MSG, SLEEP_TIMEOUT);
    }

    boolean hasScheduledRestartTimeouts(ActivityRecord r) {
        return mHandler.hasMessages(RESTART_ACTIVITY_PROCESS_TIMEOUT_MSG, r);
    }

    void removeRestartTimeouts(ActivityRecord r) {
        mHandler.removeMessages(RESTART_ACTIVITY_PROCESS_TIMEOUT_MSG, r);
    }
+9 −0
Original line number Diff line number Diff line
@@ -295,6 +295,15 @@ public class SizeCompatTests extends WindowTestsBase {

        assertEquals(RESTARTING_PROCESS, mActivity.getState());
        assertNotEquals(originalOverrideBounds, mActivity.getBounds());

        // Even if the state is changed (e.g. a floating activity on top is finished and make it
        // resume), the restart procedure should recover the state and continue to kill the process.
        mActivity.setState(RESUMED, "anyStateChange");
        doReturn(true).when(mSupervisor).hasScheduledRestartTimeouts(mActivity);
        mAtm.mActivityClientController.activityStopped(mActivity.token, null /* icicle */,
                null /* persistentState */, null /* description */);
        assertEquals(RESTARTING_PROCESS, mActivity.getState());
        verify(mSupervisor).removeRestartTimeouts(mActivity);
    }

    @Test