Merge "Do not finish activity if with taskOverlay" into tm-dev am: 690aa5d521
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16985577 Change-Id: I94f9b610d7ba7d45382481f6255423cea4fdc3b2
This commit is contained in:
@@ -2196,8 +2196,9 @@ class ActivityStarter {
|
|||||||
// removed from calling performClearTaskLocked (For example, if it is being brought out
|
// removed from calling performClearTaskLocked (For example, if it is being brought out
|
||||||
// of history or if it is finished immediately), thus disassociating the task. Also note
|
// of history or if it is finished immediately), thus disassociating the task. Also note
|
||||||
// that mReuseTask is reset as a result of {@link Task#performClearTaskLocked}
|
// that mReuseTask is reset as a result of {@link Task#performClearTaskLocked}
|
||||||
// launching another activity.
|
// launching another activity. Keep the task-overlay activity because the targetTask
|
||||||
targetTask.performClearTaskLocked();
|
// will be reused to launch new activity.
|
||||||
|
targetTask.performClearTaskForReuse(true /* excludingTaskOverlay*/);
|
||||||
targetTask.setIntent(mStartActivity);
|
targetTask.setIntent(mStartActivity);
|
||||||
mAddingToTask = true;
|
mAddingToTask = true;
|
||||||
} else if ((mLaunchFlags & FLAG_ACTIVITY_CLEAR_TOP) != 0
|
} else if ((mLaunchFlags & FLAG_ACTIVITY_CLEAR_TOP) != 0
|
||||||
@@ -2207,8 +2208,7 @@ class ActivityStarter {
|
|||||||
// In this situation we want to remove all activities from the task up to the one
|
// In this situation we want to remove all activities from the task up to the one
|
||||||
// being started. In most cases this means we are resetting the task to its initial
|
// being started. In most cases this means we are resetting the task to its initial
|
||||||
// state.
|
// state.
|
||||||
final ActivityRecord top = targetTask.performClearTaskForReuseLocked(mStartActivity,
|
final ActivityRecord top = targetTask.performClearTop(mStartActivity, mLaunchFlags);
|
||||||
mLaunchFlags);
|
|
||||||
|
|
||||||
if (top != null) {
|
if (top != null) {
|
||||||
if (top.isRootOfTask()) {
|
if (top.isRootOfTask()) {
|
||||||
|
|||||||
@@ -1605,7 +1605,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
|
|||||||
task.mTransitionController.requestCloseTransitionIfNeeded(task);
|
task.mTransitionController.requestCloseTransitionIfNeeded(task);
|
||||||
task.mInRemoveTask = true;
|
task.mInRemoveTask = true;
|
||||||
try {
|
try {
|
||||||
task.performClearTask(reason);
|
task.removeActivities(reason, false /* excludingTaskOverlay */);
|
||||||
cleanUpRemovedTaskLocked(task, killProcess, removeFromRecents);
|
cleanUpRemovedTaskLocked(task, killProcess, removeFromRecents);
|
||||||
mService.getLockTaskController().clearLockedTask(task);
|
mService.getLockTaskController().clearLockedTask(task);
|
||||||
mService.getTaskChangeNotificationController().notifyTaskStackChanged();
|
mService.getTaskChangeNotificationController().notifyTaskStackChanged();
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ public class LockTaskController {
|
|||||||
if (mLockTaskModeTasks.isEmpty()) {
|
if (mLockTaskModeTasks.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
task.performClearTaskLocked();
|
task.performClearTaskForReuse(false /* excludingTaskOverlay*/);
|
||||||
mSupervisor.mRootWindowContainer.resumeFocusedTasksTopActivities();
|
mSupervisor.mRootWindowContainer.resumeFocusedTasksTopActivities();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,7 +740,7 @@ public class LockTaskController {
|
|||||||
ProtoLog.d(WM_DEBUG_LOCKTASK, "onLockTaskPackagesUpdated: removing %s"
|
ProtoLog.d(WM_DEBUG_LOCKTASK, "onLockTaskPackagesUpdated: removing %s"
|
||||||
+ " mLockTaskAuth()=%s", lockedTask, lockedTask.lockTaskAuthToString());
|
+ " mLockTaskAuth()=%s", lockedTask, lockedTask.lockTaskAuthToString());
|
||||||
removeLockedTask(lockedTask);
|
removeLockedTask(lockedTask);
|
||||||
lockedTask.performClearTaskLocked();
|
lockedTask.performClearTaskForReuse(false /* excludingTaskOverlay*/);
|
||||||
taskChanged = true;
|
taskChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1584,19 +1584,23 @@ class Task extends TaskFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Completely remove all activities associated with an existing task. */
|
/** Completely remove all activities associated with an existing task. */
|
||||||
void performClearTask(String reason) {
|
void removeActivities(String reason, boolean excludingTaskOverlay) {
|
||||||
clearPinnedTaskIfNeed();
|
clearPinnedTaskIfNeed();
|
||||||
// Broken down into to cases to avoid object create due to capturing mStack.
|
// Broken down into to cases to avoid object create due to capturing mStack.
|
||||||
if (getRootTask() == null) {
|
if (getRootTask() == null) {
|
||||||
forAllActivities((r) -> {
|
forAllActivities((r) -> {
|
||||||
if (r.finishing) return;
|
if (r.finishing || (excludingTaskOverlay && r.isTaskOverlay())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Task was restored from persistent storage.
|
// Task was restored from persistent storage.
|
||||||
r.takeFromHistory();
|
r.takeFromHistory();
|
||||||
removeChild(r, reason);
|
removeChild(r, reason);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
forAllActivities((r) -> {
|
forAllActivities((r) -> {
|
||||||
if (r.finishing) return;
|
if (r.finishing || (excludingTaskOverlay && r.isTaskOverlay())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Prevent the transition from being executed too early if the top activity is
|
// Prevent the transition from being executed too early if the top activity is
|
||||||
// resumed but the mVisibleRequested of any other activity is true, the transition
|
// resumed but the mVisibleRequested of any other activity is true, the transition
|
||||||
// should wait until next activity resumed.
|
// should wait until next activity resumed.
|
||||||
@@ -1613,26 +1617,24 @@ class Task extends TaskFragment {
|
|||||||
/**
|
/**
|
||||||
* Completely remove all activities associated with an existing task.
|
* Completely remove all activities associated with an existing task.
|
||||||
*/
|
*/
|
||||||
void performClearTaskLocked() {
|
void performClearTaskForReuse(boolean excludingTaskOverlay) {
|
||||||
mReuseTask = true;
|
mReuseTask = true;
|
||||||
mTaskSupervisor.beginDeferResume();
|
mTaskSupervisor.beginDeferResume();
|
||||||
try {
|
try {
|
||||||
performClearTask("clear-task-all");
|
removeActivities("clear-task-all", excludingTaskOverlay);
|
||||||
} finally {
|
} finally {
|
||||||
mTaskSupervisor.endDeferResume();
|
mTaskSupervisor.endDeferResume();
|
||||||
mReuseTask = false;
|
mReuseTask = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivityRecord performClearTaskForReuseLocked(ActivityRecord newR, int launchFlags) {
|
ActivityRecord performClearTop(ActivityRecord newR, int launchFlags) {
|
||||||
mReuseTask = true;
|
|
||||||
mTaskSupervisor.beginDeferResume();
|
mTaskSupervisor.beginDeferResume();
|
||||||
final ActivityRecord result;
|
final ActivityRecord result;
|
||||||
try {
|
try {
|
||||||
result = performClearTaskLocked(newR, launchFlags);
|
result = clearTopActivities(newR, launchFlags);
|
||||||
} finally {
|
} finally {
|
||||||
mTaskSupervisor.endDeferResume();
|
mTaskSupervisor.endDeferResume();
|
||||||
mReuseTask = false;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1648,7 +1650,7 @@ class Task extends TaskFragment {
|
|||||||
* @return Returns the old activity that should be continued to be used,
|
* @return Returns the old activity that should be continued to be used,
|
||||||
* or {@code null} if none was found.
|
* or {@code null} if none was found.
|
||||||
*/
|
*/
|
||||||
private ActivityRecord performClearTaskLocked(ActivityRecord newR, int launchFlags) {
|
private ActivityRecord clearTopActivities(ActivityRecord newR, int launchFlags) {
|
||||||
final ActivityRecord r = findActivityInHistory(newR.mActivityComponent);
|
final ActivityRecord r = findActivityInHistory(newR.mActivityComponent);
|
||||||
if (r == null) return null;
|
if (r == null) return null;
|
||||||
|
|
||||||
@@ -1675,7 +1677,7 @@ class Task extends TaskFragment {
|
|||||||
// Stop operation once we reach the boundary activity.
|
// Stop operation once we reach the boundary activity.
|
||||||
if (r == boundaryActivity) return true;
|
if (r == boundaryActivity) return true;
|
||||||
|
|
||||||
if (!r.finishing) {
|
if (!r.finishing && !r.isTaskOverlay()) {
|
||||||
final ActivityOptions opts = r.getOptions();
|
final ActivityOptions opts = r.getOptions();
|
||||||
if (opts != null) {
|
if (opts != null) {
|
||||||
r.clearOptionsAnimation();
|
r.clearOptionsAnimation();
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class AppTransitionControllerTest extends WindowTestsBase {
|
|||||||
behind.setState(ActivityRecord.State.STARTED, "test");
|
behind.setState(ActivityRecord.State.STARTED, "test");
|
||||||
behind.mVisibleRequested = true;
|
behind.mVisibleRequested = true;
|
||||||
|
|
||||||
task.performClearTask("test");
|
task.removeActivities("test", false /* excludingTaskOverlay */);
|
||||||
assertFalse(mDisplayContent.mAppTransition.isReady());
|
assertFalse(mDisplayContent.mAppTransition.isReady());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ public class LockTaskControllerTest {
|
|||||||
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist);
|
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist);
|
||||||
|
|
||||||
// THEN the task running that package should be stopped
|
// THEN the task running that package should be stopped
|
||||||
verify(tr2).performClearTaskLocked();
|
verify(tr2).performClearTaskForReuse(false /* excludingTaskOverlay*/);
|
||||||
assertFalse(mLockTaskController.isTaskLocked(tr2));
|
assertFalse(mLockTaskController.isTaskLocked(tr2));
|
||||||
// THEN the other task should remain locked
|
// THEN the other task should remain locked
|
||||||
assertEquals(LOCK_TASK_MODE_LOCKED, mLockTaskController.getLockTaskModeState());
|
assertEquals(LOCK_TASK_MODE_LOCKED, mLockTaskController.getLockTaskModeState());
|
||||||
@@ -569,7 +569,7 @@ public class LockTaskControllerTest {
|
|||||||
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist);
|
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist);
|
||||||
|
|
||||||
// THEN the last task should be cleared, and the system should quit LockTask mode
|
// THEN the last task should be cleared, and the system should quit LockTask mode
|
||||||
verify(tr1).performClearTaskLocked();
|
verify(tr1).performClearTaskForReuse(false /* excludingTaskOverlay*/);
|
||||||
assertFalse(mLockTaskController.isTaskLocked(tr1));
|
assertFalse(mLockTaskController.isTaskLocked(tr1));
|
||||||
assertEquals(LOCK_TASK_MODE_NONE, mLockTaskController.getLockTaskModeState());
|
assertEquals(LOCK_TASK_MODE_NONE, mLockTaskController.getLockTaskModeState());
|
||||||
verifyLockTaskStopped(times(1));
|
verifyLockTaskStopped(times(1));
|
||||||
|
|||||||
Reference in New Issue
Block a user