Loading core/java/android/app/ActivityOptions.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,7 @@ import android.view.RemoteAnimationAdapter; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.Window; import android.view.Window; import android.window.WindowContainerToken; import java.util.ArrayList; import java.util.ArrayList; Loading Loading @@ -183,6 +184,14 @@ public class ActivityOptions { */ */ private static final String KEY_CALLER_DISPLAY_ID = "android.activity.callerDisplayId"; private static final String KEY_CALLER_DISPLAY_ID = "android.activity.callerDisplayId"; /** * The task display area token the activity should be launched into. * @see #setLaunchTaskDisplayArea(WindowContainerToken) * @hide */ private static final String KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN = "android.activity.launchTaskDisplayAreaToken"; /** /** * The windowing mode the activity should be launched into. * The windowing mode the activity should be launched into. * @hide * @hide Loading Loading @@ -334,6 +343,7 @@ public class ActivityOptions { private PendingIntent mUsageTimeReport; private PendingIntent mUsageTimeReport; private int mLaunchDisplayId = INVALID_DISPLAY; private int mLaunchDisplayId = INVALID_DISPLAY; private int mCallerDisplayId = INVALID_DISPLAY; private int mCallerDisplayId = INVALID_DISPLAY; private WindowContainerToken mLaunchTaskDisplayArea; @WindowConfiguration.WindowingMode @WindowConfiguration.WindowingMode private int mLaunchWindowingMode = WINDOWING_MODE_UNDEFINED; private int mLaunchWindowingMode = WINDOWING_MODE_UNDEFINED; @WindowConfiguration.ActivityType @WindowConfiguration.ActivityType Loading Loading @@ -974,6 +984,7 @@ public class ActivityOptions { mLockTaskMode = opts.getBoolean(KEY_LOCK_TASK_MODE, false); mLockTaskMode = opts.getBoolean(KEY_LOCK_TASK_MODE, false); mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY); mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY); mCallerDisplayId = opts.getInt(KEY_CALLER_DISPLAY_ID, INVALID_DISPLAY); mCallerDisplayId = opts.getInt(KEY_CALLER_DISPLAY_ID, INVALID_DISPLAY); mLaunchTaskDisplayArea = opts.getParcelable(KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN); mLaunchWindowingMode = opts.getInt(KEY_LAUNCH_WINDOWING_MODE, WINDOWING_MODE_UNDEFINED); mLaunchWindowingMode = opts.getInt(KEY_LAUNCH_WINDOWING_MODE, WINDOWING_MODE_UNDEFINED); mLaunchActivityType = opts.getInt(KEY_LAUNCH_ACTIVITY_TYPE, ACTIVITY_TYPE_UNDEFINED); mLaunchActivityType = opts.getInt(KEY_LAUNCH_ACTIVITY_TYPE, ACTIVITY_TYPE_UNDEFINED); mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1); mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1); Loading Loading @@ -1244,6 +1255,18 @@ public class ActivityOptions { return this; return this; } } /** @hide */ public WindowContainerToken getLaunchTaskDisplayArea() { return mLaunchTaskDisplayArea; } /** @hide */ public ActivityOptions setLaunchTaskDisplayArea( WindowContainerToken windowContainerToken) { mLaunchTaskDisplayArea = windowContainerToken; return this; } /** @hide */ /** @hide */ public int getLaunchWindowingMode() { public int getLaunchWindowingMode() { return mLaunchWindowingMode; return mLaunchWindowingMode; Loading Loading @@ -1568,6 +1591,9 @@ public class ActivityOptions { if (mCallerDisplayId != INVALID_DISPLAY) { if (mCallerDisplayId != INVALID_DISPLAY) { b.putInt(KEY_CALLER_DISPLAY_ID, mCallerDisplayId); b.putInt(KEY_CALLER_DISPLAY_ID, mCallerDisplayId); } } if (mLaunchTaskDisplayArea != null) { b.putParcelable(KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN, mLaunchTaskDisplayArea); } if (mLaunchWindowingMode != WINDOWING_MODE_UNDEFINED) { if (mLaunchWindowingMode != WINDOWING_MODE_UNDEFINED) { b.putInt(KEY_LAUNCH_WINDOWING_MODE, mLaunchWindowingMode); b.putInt(KEY_LAUNCH_WINDOWING_MODE, mLaunchWindowingMode); } } Loading services/core/java/com/android/server/wm/ActivityRecord.java +8 −1 Original line number Original line Diff line number Diff line Loading @@ -292,6 +292,7 @@ import android.view.SurfaceControl.Transaction; import android.view.WindowManager; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams; import android.view.animation.Animation; import android.view.animation.Animation; import android.window.WindowContainerToken; import com.android.internal.R; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -432,6 +433,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final boolean stateNotNeeded; // As per ActivityInfo.flags final boolean stateNotNeeded; // As per ActivityInfo.flags @VisibleForTesting @VisibleForTesting int mHandoverLaunchDisplayId = INVALID_DISPLAY; // Handover launch display id to next activity. int mHandoverLaunchDisplayId = INVALID_DISPLAY; // Handover launch display id to next activity. @VisibleForTesting TaskDisplayArea mHandoverTaskDisplayArea; // Handover launch task display area. private final boolean componentSpecified; // did caller specify an explicit component? private final boolean componentSpecified; // did caller specify an explicit component? final boolean rootVoiceInteraction; // was this the root activity of a voice interaction? final boolean rootVoiceInteraction; // was this the root activity of a voice interaction? Loading Loading @@ -1657,7 +1660,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (usageReport != null) { if (usageReport != null) { appTimeTracker = new AppTimeTracker(usageReport); appTimeTracker = new AppTimeTracker(usageReport); } } // Gets launch display id from options. It returns INVALID_DISPLAY if not set. // Gets launch task display area and display id from options. Returns // null/INVALID_DISPLAY if not set. final WindowContainerToken daToken = options.getLaunchTaskDisplayArea(); mHandoverTaskDisplayArea = daToken != null ? (TaskDisplayArea) WindowContainer.fromBinder(daToken.asBinder()) : null; mHandoverLaunchDisplayId = options.getLaunchDisplayId(); mHandoverLaunchDisplayId = options.getLaunchDisplayId(); } } } } Loading services/core/java/com/android/server/wm/ActivityStackSupervisor.java +7 −12 Original line number Original line Diff line number Diff line Loading @@ -1053,6 +1053,13 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { return true; return true; } } /** Check if caller is allowed to launch activities on specified task display area. */ boolean isCallerAllowedToLaunchOnTaskDisplayArea(int callingPid, int callingUid, TaskDisplayArea taskDisplayArea, ActivityInfo aInfo) { return isCallerAllowedToLaunchOnDisplay(callingPid, callingUid, taskDisplayArea != null ? taskDisplayArea.getDisplayId() : DEFAULT_DISPLAY, aInfo); } /** Check if caller is allowed to launch activities on specified display. */ /** Check if caller is allowed to launch activities on specified display. */ boolean isCallerAllowedToLaunchOnDisplay(int callingPid, int callingUid, int launchDisplayId, boolean isCallerAllowedToLaunchOnDisplay(int callingPid, int callingUid, int launchDisplayId, ActivityInfo aInfo) { ActivityInfo aInfo) { Loading Loading @@ -2133,18 +2140,6 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { WindowManagerService.WINDOW_FREEZE_TIMEOUT_DURATION); WindowManagerService.WINDOW_FREEZE_TIMEOUT_DURATION); } } // TODO(b/152116619): Remove after complete switch to TaskDisplayArea void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode, int preferredDisplayId, ActivityStack actualStack) { final DisplayContent preferredDisplayContent = mRootWindowContainer .getDisplayContent(preferredDisplayId); final TaskDisplayArea preferredDisplayArea = preferredDisplayContent != null ? preferredDisplayContent.getDefaultTaskDisplayArea() : null; handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredDisplayArea, actualStack); } void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode, void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode, TaskDisplayArea preferredTaskDisplayArea, ActivityStack actualStack) { TaskDisplayArea preferredTaskDisplayArea, ActivityStack actualStack) { handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredTaskDisplayArea, handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredTaskDisplayArea, Loading services/core/java/com/android/server/wm/ActivityStartController.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -184,8 +184,8 @@ public class ActivityStartController { } } final int displayId = taskDisplayArea.getDisplayId(); final int displayId = taskDisplayArea.getDisplayId(); options.setLaunchDisplayId(displayId); options.setLaunchDisplayId(displayId); // TODO(b/152116619): Enable after complete switch to WindowContainerToken options.setLaunchTaskDisplayArea(taskDisplayArea.mRemoteToken //options.setLaunchWindowContainerToken(taskDisplayArea.getWindowContainerToken()); .toWindowContainerToken()); // The home activity will be started later, defer resuming to avoid unneccerary operations // The home activity will be started later, defer resuming to avoid unneccerary operations // (e.g. start home recursively) when creating home stack. // (e.g. start home recursively) when creating home stack. Loading services/core/java/com/android/server/wm/ActivityStarter.java +26 −25 Original line number Original line Diff line number Diff line Loading @@ -55,7 +55,6 @@ import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TOP; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.os.Process.INVALID_UID; import static android.os.Process.INVALID_UID; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static com.android.server.wm.ActivityStack.ActivityState.RESUMED; import static com.android.server.wm.ActivityStack.ActivityState.RESUMED; import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME; import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME; Loading Loading @@ -167,8 +166,8 @@ class ActivityStarter { private int mStartFlags; private int mStartFlags; private ActivityRecord mSourceRecord; private ActivityRecord mSourceRecord; // The display to launch the activity onto, barring any strong reason to do otherwise. // The task display area to launch the activity onto, barring any strong reason to do otherwise. private int mPreferredDisplayId; private TaskDisplayArea mPreferredTaskDisplayArea; // The windowing mode to apply to the root task, if possible // The windowing mode to apply to the root task, if possible private int mPreferredWindowingMode; private int mPreferredWindowingMode; Loading Loading @@ -538,7 +537,7 @@ class ActivityStarter { mDoResume = starter.mDoResume; mDoResume = starter.mDoResume; mStartFlags = starter.mStartFlags; mStartFlags = starter.mStartFlags; mSourceRecord = starter.mSourceRecord; mSourceRecord = starter.mSourceRecord; mPreferredDisplayId = starter.mPreferredDisplayId; mPreferredTaskDisplayArea = starter.mPreferredTaskDisplayArea; mPreferredWindowingMode = starter.mPreferredWindowingMode; mPreferredWindowingMode = starter.mPreferredWindowingMode; mInTask = starter.mInTask; mInTask = starter.mInTask; Loading Loading @@ -1631,7 +1630,7 @@ class ActivityStarter { // Update the recent tasks list immediately when the activity starts // Update the recent tasks list immediately when the activity starts mSupervisor.mRecentTasks.add(mStartActivity.getTask()); mSupervisor.mRecentTasks.add(mStartActivity.getTask()); mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.getTask(), mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.getTask(), mPreferredWindowingMode, mPreferredDisplayId, mTargetStack); mPreferredWindowingMode, mPreferredTaskDisplayArea, mTargetStack); return START_SUCCESS; return START_SUCCESS; } } Loading Loading @@ -1684,9 +1683,9 @@ class ActivityStarter { mSupervisor.getLaunchParamsController().calculate(targetTask, r.info.windowLayout, r, mSupervisor.getLaunchParamsController().calculate(targetTask, r.info.windowLayout, r, sourceRecord, mOptions, PHASE_BOUNDS, mLaunchParams); sourceRecord, mOptions, PHASE_BOUNDS, mLaunchParams); mPreferredDisplayId = mLaunchParams.hasPreferredDisplay() mPreferredTaskDisplayArea = mLaunchParams.hasPreferredTaskDisplayArea() ? mLaunchParams.mPreferredDisplayId ? mLaunchParams.mPreferredTaskDisplayArea : DEFAULT_DISPLAY; : mRootWindowContainer.getDefaultTaskDisplayArea(); mPreferredWindowingMode = mLaunchParams.mWindowingMode; mPreferredWindowingMode = mLaunchParams.mWindowingMode; } } Loading @@ -1703,11 +1702,13 @@ class ActivityStarter { // 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. if (r.isActivityTypeHome() && !mRootWindowContainer.canStartHomeOnDisplay(r.info, if (r.isActivityTypeHome()) { mPreferredDisplayId, true /* allowInstrumenting */)) { if (!mRootWindowContainer.canStartHomeOnDisplayArea(r.info, mPreferredTaskDisplayArea, Slog.w(TAG, "Cannot launch home on display " + mPreferredDisplayId); true /* allowInstrumenting */)) { Slog.w(TAG, "Cannot launch home on display area " + mPreferredTaskDisplayArea); return START_CANCELED; return START_CANCELED; } } } if (mRestrictedBgActivity && (newTask || !targetTask.isUidPresent(mCallingUid)) if (mRestrictedBgActivity && (newTask || !targetTask.isUidPresent(mCallingUid)) && handleBackgroundActivityAbort(mStartActivity)) { && handleBackgroundActivityAbort(mStartActivity)) { Loading Loading @@ -1841,10 +1842,10 @@ class ActivityStarter { && top.attachedToProcess() && top.attachedToProcess() && ((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0 && ((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0 || isLaunchModeOneOf(LAUNCH_SINGLE_TOP, LAUNCH_SINGLE_TASK)) || isLaunchModeOneOf(LAUNCH_SINGLE_TOP, LAUNCH_SINGLE_TASK)) // This allows home activity to automatically launch on secondary display when // This allows home activity to automatically launch on secondary task display area // display added, if home was the top activity on default display, instead of // when it was added, if home was the top activity on default task display area, // sending new intent to the home activity on default display. // instead of sending new intent to the home activity on default display area. && (!top.isActivityTypeHome() || top.getDisplayId() == mPreferredDisplayId); && (!top.isActivityTypeHome() || top.getDisplayArea() == mPreferredTaskDisplayArea); if (!dontStart) { if (!dontStart) { return START_SUCCESS; return START_SUCCESS; } } Loading @@ -1866,7 +1867,7 @@ class ActivityStarter { // Don't use mStartActivity.task to show the toast. We're not starting a new activity but // Don't use mStartActivity.task to show the toast. We're not starting a new activity but // reusing 'top'. Fields in mStartActivity may not be fully initialized. // reusing 'top'. Fields in mStartActivity may not be fully initialized. mSupervisor.handleNonResizableTaskIfNeeded(top.getTask(), mSupervisor.handleNonResizableTaskIfNeeded(top.getTask(), mLaunchParams.mWindowingMode, mPreferredDisplayId, topStack); mLaunchParams.mWindowingMode, mPreferredTaskDisplayArea, topStack); return START_DELIVERED_TO_TOP; return START_DELIVERED_TO_TOP; } } Loading Loading @@ -2010,7 +2011,7 @@ class ActivityStarter { mDoResume = false; mDoResume = false; mStartFlags = 0; mStartFlags = 0; mSourceRecord = null; mSourceRecord = null; mPreferredDisplayId = INVALID_DISPLAY; mPreferredTaskDisplayArea = null; mPreferredWindowingMode = WINDOWING_MODE_UNDEFINED; mPreferredWindowingMode = WINDOWING_MODE_UNDEFINED; mInTask = null; mInTask = null; Loading Loading @@ -2060,9 +2061,9 @@ class ActivityStarter { // after we located a reusable task (which might be resided in another display). // after we located a reusable task (which might be resided in another display). mSupervisor.getLaunchParamsController().calculate(inTask, r.info.windowLayout, r, mSupervisor.getLaunchParamsController().calculate(inTask, r.info.windowLayout, r, sourceRecord, options, PHASE_DISPLAY, mLaunchParams); sourceRecord, options, PHASE_DISPLAY, mLaunchParams); mPreferredDisplayId = mLaunchParams.hasPreferredDisplay() mPreferredTaskDisplayArea = mLaunchParams.hasPreferredTaskDisplayArea() ? mLaunchParams.mPreferredDisplayId ? mLaunchParams.mPreferredTaskDisplayArea : DEFAULT_DISPLAY; : mRootWindowContainer.getDefaultTaskDisplayArea(); mPreferredWindowingMode = mLaunchParams.mWindowingMode; mPreferredWindowingMode = mLaunchParams.mWindowingMode; mLaunchMode = r.launchMode; mLaunchMode = r.launchMode; Loading Loading @@ -2334,14 +2335,14 @@ class ActivityStarter { } else { } else { // Otherwise find the best task to put the activity in. // Otherwise find the best task to put the activity in. intentActivity = intentActivity = mRootWindowContainer.findTask(mStartActivity, mPreferredDisplayId); mRootWindowContainer.findTask(mStartActivity, mPreferredTaskDisplayArea); } } } } if (intentActivity != null if (intentActivity != null && (mStartActivity.isActivityTypeHome() || intentActivity.isActivityTypeHome()) && (mStartActivity.isActivityTypeHome() || intentActivity.isActivityTypeHome()) && intentActivity.getDisplayId() != mPreferredDisplayId) { && intentActivity.getDisplayArea() != mPreferredTaskDisplayArea) { // Do not reuse home activity on other displays. // Do not reuse home activity on other display areas. intentActivity = null; intentActivity = null; } } Loading @@ -2363,7 +2364,7 @@ class ActivityStarter { // the same behavior as if a new instance was being started, which means not bringing it // the same behavior as if a new instance was being started, which means not bringing it // to the front if the caller is not itself in the front. // to the front if the caller is not itself in the front. final boolean differentTopTask; final boolean differentTopTask; if (mPreferredDisplayId == mTargetStack.getDisplayId()) { if (mTargetStack.getDisplayArea() == mPreferredTaskDisplayArea) { final ActivityStack focusStack = mTargetStack.getDisplay().getFocusedStack(); final ActivityStack focusStack = mTargetStack.getDisplay().getFocusedStack(); final ActivityRecord curTop = (focusStack == null) final ActivityRecord curTop = (focusStack == null) ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop); ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop); Loading Loading
core/java/android/app/ActivityOptions.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,7 @@ import android.view.RemoteAnimationAdapter; import android.view.View; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup; import android.view.Window; import android.view.Window; import android.window.WindowContainerToken; import java.util.ArrayList; import java.util.ArrayList; Loading Loading @@ -183,6 +184,14 @@ public class ActivityOptions { */ */ private static final String KEY_CALLER_DISPLAY_ID = "android.activity.callerDisplayId"; private static final String KEY_CALLER_DISPLAY_ID = "android.activity.callerDisplayId"; /** * The task display area token the activity should be launched into. * @see #setLaunchTaskDisplayArea(WindowContainerToken) * @hide */ private static final String KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN = "android.activity.launchTaskDisplayAreaToken"; /** /** * The windowing mode the activity should be launched into. * The windowing mode the activity should be launched into. * @hide * @hide Loading Loading @@ -334,6 +343,7 @@ public class ActivityOptions { private PendingIntent mUsageTimeReport; private PendingIntent mUsageTimeReport; private int mLaunchDisplayId = INVALID_DISPLAY; private int mLaunchDisplayId = INVALID_DISPLAY; private int mCallerDisplayId = INVALID_DISPLAY; private int mCallerDisplayId = INVALID_DISPLAY; private WindowContainerToken mLaunchTaskDisplayArea; @WindowConfiguration.WindowingMode @WindowConfiguration.WindowingMode private int mLaunchWindowingMode = WINDOWING_MODE_UNDEFINED; private int mLaunchWindowingMode = WINDOWING_MODE_UNDEFINED; @WindowConfiguration.ActivityType @WindowConfiguration.ActivityType Loading Loading @@ -974,6 +984,7 @@ public class ActivityOptions { mLockTaskMode = opts.getBoolean(KEY_LOCK_TASK_MODE, false); mLockTaskMode = opts.getBoolean(KEY_LOCK_TASK_MODE, false); mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY); mLaunchDisplayId = opts.getInt(KEY_LAUNCH_DISPLAY_ID, INVALID_DISPLAY); mCallerDisplayId = opts.getInt(KEY_CALLER_DISPLAY_ID, INVALID_DISPLAY); mCallerDisplayId = opts.getInt(KEY_CALLER_DISPLAY_ID, INVALID_DISPLAY); mLaunchTaskDisplayArea = opts.getParcelable(KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN); mLaunchWindowingMode = opts.getInt(KEY_LAUNCH_WINDOWING_MODE, WINDOWING_MODE_UNDEFINED); mLaunchWindowingMode = opts.getInt(KEY_LAUNCH_WINDOWING_MODE, WINDOWING_MODE_UNDEFINED); mLaunchActivityType = opts.getInt(KEY_LAUNCH_ACTIVITY_TYPE, ACTIVITY_TYPE_UNDEFINED); mLaunchActivityType = opts.getInt(KEY_LAUNCH_ACTIVITY_TYPE, ACTIVITY_TYPE_UNDEFINED); mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1); mLaunchTaskId = opts.getInt(KEY_LAUNCH_TASK_ID, -1); Loading Loading @@ -1244,6 +1255,18 @@ public class ActivityOptions { return this; return this; } } /** @hide */ public WindowContainerToken getLaunchTaskDisplayArea() { return mLaunchTaskDisplayArea; } /** @hide */ public ActivityOptions setLaunchTaskDisplayArea( WindowContainerToken windowContainerToken) { mLaunchTaskDisplayArea = windowContainerToken; return this; } /** @hide */ /** @hide */ public int getLaunchWindowingMode() { public int getLaunchWindowingMode() { return mLaunchWindowingMode; return mLaunchWindowingMode; Loading Loading @@ -1568,6 +1591,9 @@ public class ActivityOptions { if (mCallerDisplayId != INVALID_DISPLAY) { if (mCallerDisplayId != INVALID_DISPLAY) { b.putInt(KEY_CALLER_DISPLAY_ID, mCallerDisplayId); b.putInt(KEY_CALLER_DISPLAY_ID, mCallerDisplayId); } } if (mLaunchTaskDisplayArea != null) { b.putParcelable(KEY_LAUNCH_TASK_DISPLAY_AREA_TOKEN, mLaunchTaskDisplayArea); } if (mLaunchWindowingMode != WINDOWING_MODE_UNDEFINED) { if (mLaunchWindowingMode != WINDOWING_MODE_UNDEFINED) { b.putInt(KEY_LAUNCH_WINDOWING_MODE, mLaunchWindowingMode); b.putInt(KEY_LAUNCH_WINDOWING_MODE, mLaunchWindowingMode); } } Loading
services/core/java/com/android/server/wm/ActivityRecord.java +8 −1 Original line number Original line Diff line number Diff line Loading @@ -292,6 +292,7 @@ import android.view.SurfaceControl.Transaction; import android.view.WindowManager; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams; import android.view.animation.Animation; import android.view.animation.Animation; import android.window.WindowContainerToken; import com.android.internal.R; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -432,6 +433,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final boolean stateNotNeeded; // As per ActivityInfo.flags final boolean stateNotNeeded; // As per ActivityInfo.flags @VisibleForTesting @VisibleForTesting int mHandoverLaunchDisplayId = INVALID_DISPLAY; // Handover launch display id to next activity. int mHandoverLaunchDisplayId = INVALID_DISPLAY; // Handover launch display id to next activity. @VisibleForTesting TaskDisplayArea mHandoverTaskDisplayArea; // Handover launch task display area. private final boolean componentSpecified; // did caller specify an explicit component? private final boolean componentSpecified; // did caller specify an explicit component? final boolean rootVoiceInteraction; // was this the root activity of a voice interaction? final boolean rootVoiceInteraction; // was this the root activity of a voice interaction? Loading Loading @@ -1657,7 +1660,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (usageReport != null) { if (usageReport != null) { appTimeTracker = new AppTimeTracker(usageReport); appTimeTracker = new AppTimeTracker(usageReport); } } // Gets launch display id from options. It returns INVALID_DISPLAY if not set. // Gets launch task display area and display id from options. Returns // null/INVALID_DISPLAY if not set. final WindowContainerToken daToken = options.getLaunchTaskDisplayArea(); mHandoverTaskDisplayArea = daToken != null ? (TaskDisplayArea) WindowContainer.fromBinder(daToken.asBinder()) : null; mHandoverLaunchDisplayId = options.getLaunchDisplayId(); mHandoverLaunchDisplayId = options.getLaunchDisplayId(); } } } } Loading
services/core/java/com/android/server/wm/ActivityStackSupervisor.java +7 −12 Original line number Original line Diff line number Diff line Loading @@ -1053,6 +1053,13 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { return true; return true; } } /** Check if caller is allowed to launch activities on specified task display area. */ boolean isCallerAllowedToLaunchOnTaskDisplayArea(int callingPid, int callingUid, TaskDisplayArea taskDisplayArea, ActivityInfo aInfo) { return isCallerAllowedToLaunchOnDisplay(callingPid, callingUid, taskDisplayArea != null ? taskDisplayArea.getDisplayId() : DEFAULT_DISPLAY, aInfo); } /** Check if caller is allowed to launch activities on specified display. */ /** Check if caller is allowed to launch activities on specified display. */ boolean isCallerAllowedToLaunchOnDisplay(int callingPid, int callingUid, int launchDisplayId, boolean isCallerAllowedToLaunchOnDisplay(int callingPid, int callingUid, int launchDisplayId, ActivityInfo aInfo) { ActivityInfo aInfo) { Loading Loading @@ -2133,18 +2140,6 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { WindowManagerService.WINDOW_FREEZE_TIMEOUT_DURATION); WindowManagerService.WINDOW_FREEZE_TIMEOUT_DURATION); } } // TODO(b/152116619): Remove after complete switch to TaskDisplayArea void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode, int preferredDisplayId, ActivityStack actualStack) { final DisplayContent preferredDisplayContent = mRootWindowContainer .getDisplayContent(preferredDisplayId); final TaskDisplayArea preferredDisplayArea = preferredDisplayContent != null ? preferredDisplayContent.getDefaultTaskDisplayArea() : null; handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredDisplayArea, actualStack); } void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode, void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode, TaskDisplayArea preferredTaskDisplayArea, ActivityStack actualStack) { TaskDisplayArea preferredTaskDisplayArea, ActivityStack actualStack) { handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredTaskDisplayArea, handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredTaskDisplayArea, Loading
services/core/java/com/android/server/wm/ActivityStartController.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -184,8 +184,8 @@ public class ActivityStartController { } } final int displayId = taskDisplayArea.getDisplayId(); final int displayId = taskDisplayArea.getDisplayId(); options.setLaunchDisplayId(displayId); options.setLaunchDisplayId(displayId); // TODO(b/152116619): Enable after complete switch to WindowContainerToken options.setLaunchTaskDisplayArea(taskDisplayArea.mRemoteToken //options.setLaunchWindowContainerToken(taskDisplayArea.getWindowContainerToken()); .toWindowContainerToken()); // The home activity will be started later, defer resuming to avoid unneccerary operations // The home activity will be started later, defer resuming to avoid unneccerary operations // (e.g. start home recursively) when creating home stack. // (e.g. start home recursively) when creating home stack. Loading
services/core/java/com/android/server/wm/ActivityStarter.java +26 −25 Original line number Original line Diff line number Diff line Loading @@ -55,7 +55,6 @@ import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TOP; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.os.Process.INVALID_UID; import static android.os.Process.INVALID_UID; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static com.android.server.wm.ActivityStack.ActivityState.RESUMED; import static com.android.server.wm.ActivityStack.ActivityState.RESUMED; import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME; import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME; Loading Loading @@ -167,8 +166,8 @@ class ActivityStarter { private int mStartFlags; private int mStartFlags; private ActivityRecord mSourceRecord; private ActivityRecord mSourceRecord; // The display to launch the activity onto, barring any strong reason to do otherwise. // The task display area to launch the activity onto, barring any strong reason to do otherwise. private int mPreferredDisplayId; private TaskDisplayArea mPreferredTaskDisplayArea; // The windowing mode to apply to the root task, if possible // The windowing mode to apply to the root task, if possible private int mPreferredWindowingMode; private int mPreferredWindowingMode; Loading Loading @@ -538,7 +537,7 @@ class ActivityStarter { mDoResume = starter.mDoResume; mDoResume = starter.mDoResume; mStartFlags = starter.mStartFlags; mStartFlags = starter.mStartFlags; mSourceRecord = starter.mSourceRecord; mSourceRecord = starter.mSourceRecord; mPreferredDisplayId = starter.mPreferredDisplayId; mPreferredTaskDisplayArea = starter.mPreferredTaskDisplayArea; mPreferredWindowingMode = starter.mPreferredWindowingMode; mPreferredWindowingMode = starter.mPreferredWindowingMode; mInTask = starter.mInTask; mInTask = starter.mInTask; Loading Loading @@ -1631,7 +1630,7 @@ class ActivityStarter { // Update the recent tasks list immediately when the activity starts // Update the recent tasks list immediately when the activity starts mSupervisor.mRecentTasks.add(mStartActivity.getTask()); mSupervisor.mRecentTasks.add(mStartActivity.getTask()); mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.getTask(), mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.getTask(), mPreferredWindowingMode, mPreferredDisplayId, mTargetStack); mPreferredWindowingMode, mPreferredTaskDisplayArea, mTargetStack); return START_SUCCESS; return START_SUCCESS; } } Loading Loading @@ -1684,9 +1683,9 @@ class ActivityStarter { mSupervisor.getLaunchParamsController().calculate(targetTask, r.info.windowLayout, r, mSupervisor.getLaunchParamsController().calculate(targetTask, r.info.windowLayout, r, sourceRecord, mOptions, PHASE_BOUNDS, mLaunchParams); sourceRecord, mOptions, PHASE_BOUNDS, mLaunchParams); mPreferredDisplayId = mLaunchParams.hasPreferredDisplay() mPreferredTaskDisplayArea = mLaunchParams.hasPreferredTaskDisplayArea() ? mLaunchParams.mPreferredDisplayId ? mLaunchParams.mPreferredTaskDisplayArea : DEFAULT_DISPLAY; : mRootWindowContainer.getDefaultTaskDisplayArea(); mPreferredWindowingMode = mLaunchParams.mWindowingMode; mPreferredWindowingMode = mLaunchParams.mWindowingMode; } } Loading @@ -1703,11 +1702,13 @@ class ActivityStarter { // 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. if (r.isActivityTypeHome() && !mRootWindowContainer.canStartHomeOnDisplay(r.info, if (r.isActivityTypeHome()) { mPreferredDisplayId, true /* allowInstrumenting */)) { if (!mRootWindowContainer.canStartHomeOnDisplayArea(r.info, mPreferredTaskDisplayArea, Slog.w(TAG, "Cannot launch home on display " + mPreferredDisplayId); true /* allowInstrumenting */)) { Slog.w(TAG, "Cannot launch home on display area " + mPreferredTaskDisplayArea); return START_CANCELED; return START_CANCELED; } } } if (mRestrictedBgActivity && (newTask || !targetTask.isUidPresent(mCallingUid)) if (mRestrictedBgActivity && (newTask || !targetTask.isUidPresent(mCallingUid)) && handleBackgroundActivityAbort(mStartActivity)) { && handleBackgroundActivityAbort(mStartActivity)) { Loading Loading @@ -1841,10 +1842,10 @@ class ActivityStarter { && top.attachedToProcess() && top.attachedToProcess() && ((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0 && ((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0 || isLaunchModeOneOf(LAUNCH_SINGLE_TOP, LAUNCH_SINGLE_TASK)) || isLaunchModeOneOf(LAUNCH_SINGLE_TOP, LAUNCH_SINGLE_TASK)) // This allows home activity to automatically launch on secondary display when // This allows home activity to automatically launch on secondary task display area // display added, if home was the top activity on default display, instead of // when it was added, if home was the top activity on default task display area, // sending new intent to the home activity on default display. // instead of sending new intent to the home activity on default display area. && (!top.isActivityTypeHome() || top.getDisplayId() == mPreferredDisplayId); && (!top.isActivityTypeHome() || top.getDisplayArea() == mPreferredTaskDisplayArea); if (!dontStart) { if (!dontStart) { return START_SUCCESS; return START_SUCCESS; } } Loading @@ -1866,7 +1867,7 @@ class ActivityStarter { // Don't use mStartActivity.task to show the toast. We're not starting a new activity but // Don't use mStartActivity.task to show the toast. We're not starting a new activity but // reusing 'top'. Fields in mStartActivity may not be fully initialized. // reusing 'top'. Fields in mStartActivity may not be fully initialized. mSupervisor.handleNonResizableTaskIfNeeded(top.getTask(), mSupervisor.handleNonResizableTaskIfNeeded(top.getTask(), mLaunchParams.mWindowingMode, mPreferredDisplayId, topStack); mLaunchParams.mWindowingMode, mPreferredTaskDisplayArea, topStack); return START_DELIVERED_TO_TOP; return START_DELIVERED_TO_TOP; } } Loading Loading @@ -2010,7 +2011,7 @@ class ActivityStarter { mDoResume = false; mDoResume = false; mStartFlags = 0; mStartFlags = 0; mSourceRecord = null; mSourceRecord = null; mPreferredDisplayId = INVALID_DISPLAY; mPreferredTaskDisplayArea = null; mPreferredWindowingMode = WINDOWING_MODE_UNDEFINED; mPreferredWindowingMode = WINDOWING_MODE_UNDEFINED; mInTask = null; mInTask = null; Loading Loading @@ -2060,9 +2061,9 @@ class ActivityStarter { // after we located a reusable task (which might be resided in another display). // after we located a reusable task (which might be resided in another display). mSupervisor.getLaunchParamsController().calculate(inTask, r.info.windowLayout, r, mSupervisor.getLaunchParamsController().calculate(inTask, r.info.windowLayout, r, sourceRecord, options, PHASE_DISPLAY, mLaunchParams); sourceRecord, options, PHASE_DISPLAY, mLaunchParams); mPreferredDisplayId = mLaunchParams.hasPreferredDisplay() mPreferredTaskDisplayArea = mLaunchParams.hasPreferredTaskDisplayArea() ? mLaunchParams.mPreferredDisplayId ? mLaunchParams.mPreferredTaskDisplayArea : DEFAULT_DISPLAY; : mRootWindowContainer.getDefaultTaskDisplayArea(); mPreferredWindowingMode = mLaunchParams.mWindowingMode; mPreferredWindowingMode = mLaunchParams.mWindowingMode; mLaunchMode = r.launchMode; mLaunchMode = r.launchMode; Loading Loading @@ -2334,14 +2335,14 @@ class ActivityStarter { } else { } else { // Otherwise find the best task to put the activity in. // Otherwise find the best task to put the activity in. intentActivity = intentActivity = mRootWindowContainer.findTask(mStartActivity, mPreferredDisplayId); mRootWindowContainer.findTask(mStartActivity, mPreferredTaskDisplayArea); } } } } if (intentActivity != null if (intentActivity != null && (mStartActivity.isActivityTypeHome() || intentActivity.isActivityTypeHome()) && (mStartActivity.isActivityTypeHome() || intentActivity.isActivityTypeHome()) && intentActivity.getDisplayId() != mPreferredDisplayId) { && intentActivity.getDisplayArea() != mPreferredTaskDisplayArea) { // Do not reuse home activity on other displays. // Do not reuse home activity on other display areas. intentActivity = null; intentActivity = null; } } Loading @@ -2363,7 +2364,7 @@ class ActivityStarter { // the same behavior as if a new instance was being started, which means not bringing it // the same behavior as if a new instance was being started, which means not bringing it // to the front if the caller is not itself in the front. // to the front if the caller is not itself in the front. final boolean differentTopTask; final boolean differentTopTask; if (mPreferredDisplayId == mTargetStack.getDisplayId()) { if (mTargetStack.getDisplayArea() == mPreferredTaskDisplayArea) { final ActivityStack focusStack = mTargetStack.getDisplay().getFocusedStack(); final ActivityStack focusStack = mTargetStack.getDisplay().getFocusedStack(); final ActivityRecord curTop = (focusStack == null) final ActivityRecord curTop = (focusStack == null) ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop); ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop); Loading