Ensure that we always resume task overlay activities if requested.
- Distinguish between task overlays that need to be resumed and
those that should not.
Bug: 34240533
Test: Open PiP, tap to show menu.
Change-Id: Ibdb54d544c501a492260f02cdc2de40c5c1a66d1
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index 1e7f4f0..04510da 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -177,6 +177,13 @@
private static final String KEY_TASK_OVERLAY = "android.activity.taskOverlay";
/**
+ * See {@link #setTaskOverlay}.
+ * @hide
+ */
+ private static final String KEY_TASK_OVERLAY_CAN_RESUME =
+ "android.activity.taskOverlayCanResume";
+
+ /**
* Where the docked stack should be positioned.
* @hide
*/
@@ -252,6 +259,7 @@
private int mLaunchTaskId = -1;
private int mDockCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
private boolean mTaskOverlay;
+ private boolean mTaskOverlayCanResume;
private AppTransitionAnimationSpec mAnimSpecs[];
private int mRotationAnimationHint = -1;
@@ -862,6 +870,7 @@
mLaunchStackId = opts.getInt(KEY_LAUNCH_STACK_ID, INVALID_STACK_ID);
mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1);
mTaskOverlay = opts.getBoolean(KEY_TASK_OVERLAY, false);
+ mTaskOverlayCanResume = opts.getBoolean(KEY_TASK_OVERLAY_CAN_RESUME, false);
mDockCreateMode = opts.getInt(KEY_DOCK_CREATE_MODE, DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT);
if (opts.containsKey(KEY_ANIM_SPECS)) {
Parcelable[] specs = opts.getParcelableArray(KEY_ANIM_SPECS);
@@ -1071,12 +1080,13 @@
/**
* Set's whether the activity launched with this option should be a task overlay. That is the
- * activity will always be the top activity of the task and doesn't cause the task to be moved
- * to the front when it is added.
+ * activity will always be the top activity of the task. If {@param canResume} is true, then
+ * the task will also not be moved to the front of the stack.
* @hide
*/
- public void setTaskOverlay(boolean taskOverlay) {
+ public void setTaskOverlay(boolean taskOverlay, boolean canResume) {
mTaskOverlay = taskOverlay;
+ mTaskOverlayCanResume = canResume;
}
/**
@@ -1086,6 +1096,13 @@
return mTaskOverlay;
}
+ /**
+ * @hide
+ */
+ public boolean canTaskOverlayResume() {
+ return mTaskOverlayCanResume;
+ }
+
/** @hide */
public int getDockCreateMode() {
return mDockCreateMode;
@@ -1241,6 +1258,7 @@
b.putInt(KEY_LAUNCH_STACK_ID, mLaunchStackId);
b.putInt(KEY_LAUNCH_TASK_ID, mLaunchTaskId);
b.putBoolean(KEY_TASK_OVERLAY, mTaskOverlay);
+ b.putBoolean(KEY_TASK_OVERLAY_CAN_RESUME, mTaskOverlayCanResume);
b.putInt(KEY_DOCK_CREATE_MODE, mDockCreateMode);
if (mAnimSpecs != null) {
b.putParcelableArray(KEY_ANIM_SPECS, mAnimSpecs);
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
index 22fceff..2c41a08 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
@@ -48,7 +48,7 @@
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchTaskId(taskId);
- options.setTaskOverlay(true);
+ options.setTaskOverlay(true, false /* canResume */);
mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
}
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
index 0350cc6..e1cc6c1 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
@@ -133,7 +133,7 @@
ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
options.setLaunchTaskId(
pinnedStackInfo.taskIds[pinnedStackInfo.taskIds.length - 1]);
- options.setTaskOverlay(true);
+ options.setTaskOverlay(true, true /* canResume */);
mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
} else {
Log.e(TAG, "No PIP tasks found");
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java b/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java
index 5920f46..17b494e 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java
@@ -112,7 +112,7 @@
Intent intent = new Intent(mContext, ForcedResizableInfoActivity.class);
ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchTaskId(mPendingTaskIds.valueAt(i));
- options.setTaskOverlay(true);
+ options.setTaskOverlay(true, false /* canResume */);
mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
}
mPendingTaskIds.clear();
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index f401863..547e0b2 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -1236,16 +1236,19 @@
mDoResume = false;
}
- if (mOptions != null && mOptions.getLaunchTaskId() != -1 && mOptions.getTaskOverlay()) {
+ if (mOptions != null && mOptions.getLaunchTaskId() != -1
+ && mOptions.getTaskOverlay()) {
r.mTaskOverlay = true;
- final TaskRecord task = mSupervisor.anyTaskForIdLocked(mOptions.getLaunchTaskId());
- final ActivityRecord top = task != null ? task.getTopActivity() : null;
- if (top != null && top.state != RESUMED) {
+ if (!mOptions.canTaskOverlayResume()) {
+ final TaskRecord task = mSupervisor.anyTaskForIdLocked(mOptions.getLaunchTaskId());
+ final ActivityRecord top = task != null ? task.getTopActivity() : null;
+ if (top != null && top.state != RESUMED) {
- // The caller specifies that we'd like to be avoided to be moved to the front, so be
- // it!
- mDoResume = false;
- mAvoidMoveToFront = true;
+ // The caller specifies that we'd like to be avoided to be moved to the front,
+ // so be it!
+ mDoResume = false;
+ mAvoidMoveToFront = true;
+ }
}
}