Merge "Also apply freeze-task-list when starting an activity" into qt-r1-dev
am: 2cc5346954
Change-Id: Ie556c0e246dffcfaa8ca8556974abde2e843883f
This commit is contained in:
@@ -187,6 +187,7 @@ class ActivityStarter {
|
|||||||
private boolean mNoAnimation;
|
private boolean mNoAnimation;
|
||||||
private boolean mKeepCurTransition;
|
private boolean mKeepCurTransition;
|
||||||
private boolean mAvoidMoveToFront;
|
private boolean mAvoidMoveToFront;
|
||||||
|
private boolean mFrozeTaskList;
|
||||||
|
|
||||||
// We must track when we deliver the new intent since multiple code paths invoke
|
// We must track when we deliver the new intent since multiple code paths invoke
|
||||||
// {@link #deliverNewIntent}. This is due to early returns in the code path. This flag is used
|
// {@link #deliverNewIntent}. This is due to early returns in the code path. This flag is used
|
||||||
@@ -483,6 +484,7 @@ class ActivityStarter {
|
|||||||
mNoAnimation = starter.mNoAnimation;
|
mNoAnimation = starter.mNoAnimation;
|
||||||
mKeepCurTransition = starter.mKeepCurTransition;
|
mKeepCurTransition = starter.mKeepCurTransition;
|
||||||
mAvoidMoveToFront = starter.mAvoidMoveToFront;
|
mAvoidMoveToFront = starter.mAvoidMoveToFront;
|
||||||
|
mFrozeTaskList = starter.mFrozeTaskList;
|
||||||
|
|
||||||
mVoiceSession = starter.mVoiceSession;
|
mVoiceSession = starter.mVoiceSession;
|
||||||
mVoiceInteractor = starter.mVoiceInteractor;
|
mVoiceInteractor = starter.mVoiceInteractor;
|
||||||
@@ -1093,6 +1095,14 @@ class ActivityStarter {
|
|||||||
|
|
||||||
void postStartActivityProcessing(ActivityRecord r, int result,
|
void postStartActivityProcessing(ActivityRecord r, int result,
|
||||||
ActivityStack startedActivityStack) {
|
ActivityStack startedActivityStack) {
|
||||||
|
if (!ActivityManager.isStartResultSuccessful(result)) {
|
||||||
|
if (mFrozeTaskList) {
|
||||||
|
// If we specifically froze the task list as part of starting an activity, then
|
||||||
|
// reset the frozen list state if it failed to start. This is normally otherwise
|
||||||
|
// called when the freeze-timeout has elapsed.
|
||||||
|
mSupervisor.mRecentTasks.resetFreezeTaskListReorderingOnTimeout();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ActivityManager.isStartResultFatalError(result)) {
|
if (ActivityManager.isStartResultFatalError(result)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1485,6 +1495,14 @@ class ActivityStarter {
|
|||||||
mLaunchParams.hasPreferredDisplay() ? mLaunchParams.mPreferredDisplayId
|
mLaunchParams.hasPreferredDisplay() ? mLaunchParams.mPreferredDisplayId
|
||||||
: DEFAULT_DISPLAY;
|
: DEFAULT_DISPLAY;
|
||||||
|
|
||||||
|
// If requested, freeze the task list
|
||||||
|
if (mOptions != null && mOptions.freezeRecentTasksReordering()
|
||||||
|
&& mSupervisor.mRecentTasks.isCallerRecents(r.launchedFromUid)
|
||||||
|
&& !mSupervisor.mRecentTasks.isFreezeTaskListReorderingSet()) {
|
||||||
|
mFrozeTaskList = true;
|
||||||
|
mSupervisor.mRecentTasks.setFreezeTaskListReordering();
|
||||||
|
}
|
||||||
|
|
||||||
// Do not start home activity if it cannot be launched on preferred display. We are not
|
// Do not start home activity if it cannot be launched on preferred display. We are not
|
||||||
// doing this in ActivityStackSupervisor#canPlaceEntityOnDisplay because it might
|
// doing this in ActivityStackSupervisor#canPlaceEntityOnDisplay because it might
|
||||||
// fallback to launch on other displays.
|
// fallback to launch on other displays.
|
||||||
@@ -1775,6 +1793,7 @@ class ActivityStarter {
|
|||||||
mNoAnimation = false;
|
mNoAnimation = false;
|
||||||
mKeepCurTransition = false;
|
mKeepCurTransition = false;
|
||||||
mAvoidMoveToFront = false;
|
mAvoidMoveToFront = false;
|
||||||
|
mFrozeTaskList = false;
|
||||||
|
|
||||||
mVoiceSession = null;
|
mVoiceSession = null;
|
||||||
mVoiceInteractor = null;
|
mVoiceInteractor = null;
|
||||||
|
|||||||
@@ -842,4 +842,51 @@ public class ActivityStarterTests extends ActivityTestsBase {
|
|||||||
// Ensure the activity is moved to secondary display.
|
// Ensure the activity is moved to secondary display.
|
||||||
assertEquals(secondaryDisplay, topActivity.getDisplay());
|
assertEquals(secondaryDisplay, topActivity.getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test ensures that starting an activity with the freeze-task-list activity option will
|
||||||
|
* actually freeze the task list
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testFreezeTaskListActivityOption() {
|
||||||
|
RecentTasks recentTasks = mock(RecentTasks.class);
|
||||||
|
mService.mStackSupervisor.setRecentTasks(recentTasks);
|
||||||
|
doReturn(true).when(recentTasks).isCallerRecents(anyInt());
|
||||||
|
|
||||||
|
final ActivityStarter starter = prepareStarter(0 /* flags */);
|
||||||
|
final ActivityOptions options = ActivityOptions.makeBasic();
|
||||||
|
options.setFreezeRecentTasksReordering();
|
||||||
|
|
||||||
|
starter.setReason("testFreezeTaskListActivityOption")
|
||||||
|
.setActivityOptions(new SafeActivityOptions(options))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
verify(recentTasks, times(1)).setFreezeTaskListReordering();
|
||||||
|
verify(recentTasks, times(0)).resetFreezeTaskListReorderingOnTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test ensures that if we froze the task list as a part of starting an activity that fails
|
||||||
|
* to start, that we also reset the task list.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testFreezeTaskListActivityOptionFailedStart_expectResetFreezeTaskList() {
|
||||||
|
RecentTasks recentTasks = mock(RecentTasks.class);
|
||||||
|
mService.mStackSupervisor.setRecentTasks(recentTasks);
|
||||||
|
doReturn(true).when(recentTasks).isCallerRecents(anyInt());
|
||||||
|
|
||||||
|
final ActivityStarter starter = prepareStarter(0 /* flags */);
|
||||||
|
final ActivityOptions options = ActivityOptions.makeBasic();
|
||||||
|
options.setFreezeRecentTasksReordering();
|
||||||
|
|
||||||
|
starter.setReason("testFreezeTaskListActivityOptionFailedStart")
|
||||||
|
.setActivityOptions(new SafeActivityOptions(options))
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
// Simulate a failed start
|
||||||
|
starter.postStartActivityProcessing(null, START_ABORTED, null);
|
||||||
|
|
||||||
|
verify(recentTasks, times(1)).setFreezeTaskListReordering();
|
||||||
|
verify(recentTasks, times(1)).resetFreezeTaskListReorderingOnTimeout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user