Loading services/core/java/com/android/server/wm/ActivityClientController.java +11 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } Loading services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +4 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
services/core/java/com/android/server/wm/ActivityClientController.java +11 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } Loading
services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +4 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading