Allow to disable showing starting window when start from recents

For now only support startActivityFromRecents.
Use ActivityOptions#setDisableStartingWindow to disable showing the
starting window for current launch.

Bug: 202826469
Test: call setDisableStartingWindow in TaskView#launchTask, verify no
starting window for that launch.

Change-Id: I6151c1b4c45f424b46a957846539e3345d919de8
This commit is contained in:
wilsonshih
2022-06-09 11:47:19 +08:00
parent f201b1bc4d
commit 597e72635f
4 changed files with 32 additions and 2 deletions

View File

@@ -256,6 +256,12 @@ public class ActivityOptions extends ComponentOptions {
*/
private static final String KEY_LAUNCH_TASK_ID = "android.activity.launchTaskId";
/**
* See {@link #setDisableStartingWindow}.
* @hide
*/
private static final String KEY_DISABLE_STARTING_WINDOW = "android.activity.disableStarting";
/**
* See {@link #setPendingIntentLaunchFlags(int)}
* @hide
@@ -467,6 +473,7 @@ public class ActivityOptions extends ComponentOptions {
private PictureInPictureParams mLaunchIntoPipParams;
private boolean mDismissKeyguard;
private boolean mIgnorePendingIntentCreatorForegroundState;
private boolean mDisableStartingWindow;
/**
* Create an ActivityOptions specifying a custom animation to run when
@@ -1272,6 +1279,7 @@ public class ActivityOptions extends ComponentOptions {
mDismissKeyguard = opts.getBoolean(KEY_DISMISS_KEYGUARD);
mIgnorePendingIntentCreatorForegroundState = opts.getBoolean(
KEY_IGNORE_PENDING_INTENT_CREATOR_FOREGROUND_STATE);
mDisableStartingWindow = opts.getBoolean(KEY_DISABLE_STARTING_WINDOW);
}
/**
@@ -1670,6 +1678,22 @@ public class ActivityOptions extends ComponentOptions {
return mLaunchTaskId;
}
/**
* Sets whether recents disable showing starting window when activity launch.
* @hide
*/
@RequiresPermission(START_TASKS_FROM_RECENTS)
public void setDisableStartingWindow(boolean disable) {
mDisableStartingWindow = disable;
}
/**
* @hide
*/
public boolean getDisableStartingWindow() {
return mDisableStartingWindow;
}
/**
* Specifies intent flags to be applied for any activity started from a PendingIntent.
*
@@ -2178,6 +2202,9 @@ public class ActivityOptions extends ComponentOptions {
b.putBoolean(KEY_IGNORE_PENDING_INTENT_CREATOR_FOREGROUND_STATE,
mIgnorePendingIntentCreatorForegroundState);
}
if (mDisableStartingWindow) {
b.putBoolean(KEY_DISABLE_STARTING_WINDOW, mDisableStartingWindow);
}
return b;
}

View File

@@ -1481,7 +1481,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
handleNonResizableTaskIfNeeded(task, WINDOWING_MODE_UNDEFINED,
mRootWindowContainer.getDefaultTaskDisplayArea(), currentRootTask,
forceNonResizeable);
if (r != null) {
if (r != null && (options == null || !options.getDisableStartingWindow())) {
// Use a starting window to reduce the transition latency for reshowing the task.
// Note that with shell transition, this should be executed before requesting
// transition to avoid delaying the starting window.

View File

@@ -263,7 +263,7 @@ public class SafeActivityOptions {
ActivityOptions options, int callingPid, int callingUid) {
// If a launch task id is specified, then ensure that the caller is the recents
// component or has the START_TASKS_FROM_RECENTS permission
if (options.getLaunchTaskId() != INVALID_TASK_ID
if ((options.getLaunchTaskId() != INVALID_TASK_ID || options.getDisableStartingWindow())
&& !supervisor.mRecentTasks.isCallerRecents(callingUid)) {
final int startInTaskPerm = ActivityTaskManagerService.checkPermission(
START_TASKS_FROM_RECENTS, callingPid, callingUid);

View File

@@ -5049,6 +5049,9 @@ class Task extends TaskFragment {
== ActivityOptions.ANIM_SCENE_TRANSITION) {
doShow = false;
}
if (options != null && options.getDisableStartingWindow()) {
doShow = false;
}
if (r.mLaunchTaskBehind) {
// Don't do a starting window for mLaunchTaskBehind. More importantly make sure we
// tell WindowManager that r is visible even though it is at the back of the root