Merge "Introduce a flag removeWithTaskOrganizer." into sc-dev
This commit is contained in:
@@ -320,6 +320,10 @@ public class ActivityOptions {
|
||||
private static final String KEY_OVERRIDE_TASK_TRANSITION =
|
||||
"android:activity.overrideTaskTransition";
|
||||
|
||||
/** See {@link #setRemoveWithTaskOrganizer(boolean)}. */
|
||||
private static final String KEY_REMOVE_WITH_TASK_ORGANIZER =
|
||||
"android.activity.removeWithTaskOrganizer";
|
||||
|
||||
/**
|
||||
* @see #setLaunchCookie
|
||||
* @hide
|
||||
@@ -405,6 +409,7 @@ public class ActivityOptions {
|
||||
private IRemoteTransition mRemoteTransition;
|
||||
private boolean mOverrideTaskTransition;
|
||||
private int mSplashScreenThemeResId;
|
||||
private boolean mRemoveWithTaskOrganizer;
|
||||
|
||||
/**
|
||||
* Create an ActivityOptions specifying a custom animation to run when
|
||||
@@ -1155,6 +1160,7 @@ public class ActivityOptions {
|
||||
KEY_REMOTE_TRANSITION));
|
||||
mOverrideTaskTransition = opts.getBoolean(KEY_OVERRIDE_TASK_TRANSITION);
|
||||
mSplashScreenThemeResId = opts.getInt(KEY_SPLASH_SCREEN_THEME);
|
||||
mRemoveWithTaskOrganizer = opts.getBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1623,6 +1629,22 @@ public class ActivityOptions {
|
||||
return mOverrideTaskTransition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to remove the task when TaskOrganizer, which is managing it, is destroyed.
|
||||
* @hide
|
||||
*/
|
||||
public void setRemoveWithTaskOrganizer(boolean remove) {
|
||||
mRemoveWithTaskOrganizer = remove;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether to remove the task when TaskOrganizer, which is managing it, is destroyed.
|
||||
* @hide
|
||||
*/
|
||||
public boolean getRemoveWithTaskOranizer() {
|
||||
return mRemoveWithTaskOrganizer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the current values in this ActivityOptions from those supplied
|
||||
* in <var>otherOptions</var>. Any values
|
||||
@@ -1857,6 +1879,9 @@ public class ActivityOptions {
|
||||
if (mSplashScreenThemeResId != 0) {
|
||||
b.putInt(KEY_SPLASH_SCREEN_THEME, mSplashScreenThemeResId);
|
||||
}
|
||||
if (mRemoveWithTaskOrganizer) {
|
||||
b.putBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER, mRemoveWithTaskOrganizer);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
});
|
||||
options.setLaunchCookie(launchCookie);
|
||||
options.setLaunchWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
|
||||
options.setRemoveWithTaskOrganizer(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -835,6 +835,9 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
// Tracking cookie for the creation of this task.
|
||||
IBinder mLaunchCookie;
|
||||
|
||||
// The task will be removed when TaskOrganizer, which is managing the task, is destroyed.
|
||||
boolean mRemoveWithTaskOrganizer;
|
||||
|
||||
private Task(ActivityTaskManagerService atmService, int _taskId, Intent _intent,
|
||||
Intent _affinityIntent, String _affinity, String _rootAffinity,
|
||||
ComponentName _realActivity, ComponentName _origActivity, boolean _rootWasReset,
|
||||
@@ -846,7 +849,8 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
boolean supportsPictureInPicture, boolean _realActivitySuspended,
|
||||
boolean userSetupComplete, int minWidth, int minHeight, ActivityInfo info,
|
||||
IVoiceInteractionSession _voiceSession, IVoiceInteractor _voiceInteractor,
|
||||
boolean _createdByOrganizer, IBinder _launchCookie, boolean _deferTaskAppear) {
|
||||
boolean _createdByOrganizer, IBinder _launchCookie, boolean _deferTaskAppear,
|
||||
boolean _removeWithTaskOrganizer) {
|
||||
super(atmService.mWindowManager);
|
||||
|
||||
mAtmService = atmService;
|
||||
@@ -905,6 +909,7 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
mCreatedByOrganizer = _createdByOrganizer;
|
||||
mLaunchCookie = _launchCookie;
|
||||
mDeferTaskAppear = _deferTaskAppear;
|
||||
mRemoveWithTaskOrganizer = _removeWithTaskOrganizer;
|
||||
EventLogTags.writeWmTaskCreated(mTaskId, isRootTask() ? INVALID_TASK_ID : getRootTaskId());
|
||||
}
|
||||
|
||||
@@ -7845,6 +7850,7 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
private IBinder mLaunchCookie;
|
||||
private boolean mOnTop;
|
||||
private boolean mHasBeenVisible;
|
||||
private boolean mRemoveWithTaskOrganizer;
|
||||
|
||||
Builder(ActivityTaskManagerService atm) {
|
||||
mAtmService = atm;
|
||||
@@ -8140,6 +8146,9 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
mCallingPackage = mActivityInfo.packageName;
|
||||
mResizeMode = mActivityInfo.resizeMode;
|
||||
mSupportsPictureInPicture = mActivityInfo.supportsPictureInPicture();
|
||||
if (mActivityOptions != null) {
|
||||
mRemoveWithTaskOrganizer = mActivityOptions.getRemoveWithTaskOranizer();
|
||||
}
|
||||
|
||||
final Task task = buildInner();
|
||||
task.mHasBeenVisible = mHasBeenVisible;
|
||||
@@ -8178,7 +8187,7 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
mCallingPackage, mCallingFeatureId, mResizeMode, mSupportsPictureInPicture,
|
||||
mRealActivitySuspended, mUserSetupComplete, mMinWidth, mMinHeight,
|
||||
mActivityInfo, mVoiceSession, mVoiceInteractor, mCreatedByOrganizer,
|
||||
mLaunchCookie, mDeferTaskAppear);
|
||||
mLaunchCookie, mDeferTaskAppear, mRemoveWithTaskOrganizer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,18 +285,20 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean removeTask(Task t) {
|
||||
private boolean removeTask(Task t, boolean removeFromSystem) {
|
||||
mOrganizedTasks.remove(t);
|
||||
mInterceptBackPressedOnRootTasks.remove(t.mTaskId);
|
||||
|
||||
if (t.mTaskAppearedSent) {
|
||||
boolean taskAppearedSent = t.mTaskAppearedSent;
|
||||
if (taskAppearedSent) {
|
||||
if (t.getSurfaceControl() != null) {
|
||||
t.migrateToNewSurfaceControl();
|
||||
}
|
||||
t.mTaskAppearedSent = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (removeFromSystem) {
|
||||
mService.removeTask(t.mTaskId);
|
||||
}
|
||||
return taskAppearedSent;
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
@@ -311,7 +313,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
||||
if (mOrganizedTasks.contains(t)) {
|
||||
// updateTaskOrganizerState should remove the task from the list, but still
|
||||
// check it again to avoid while-loop isn't terminate.
|
||||
if (removeTask(t)) {
|
||||
if (removeTask(t, t.mRemoveWithTaskOrganizer)) {
|
||||
TaskOrganizerController.this.onTaskVanishedInternal(
|
||||
mOrganizer.mTaskOrganizer, t);
|
||||
}
|
||||
@@ -527,7 +529,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
||||
|
||||
void onTaskVanished(ITaskOrganizer organizer, Task task) {
|
||||
final TaskOrganizerState state = mTaskOrganizerStates.get(organizer.asBinder());
|
||||
if (state != null && state.removeTask(task)) {
|
||||
if (state != null && state.removeTask(task, false /* removeFromSystem */)) {
|
||||
onTaskVanishedInternal(organizer, task);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user