Loading services/core/java/com/android/server/wm/ActivityRecord.java +14 −5 Original line number Original line Diff line number Diff line Loading @@ -521,7 +521,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A static final int STARTING_WINDOW_SHOWN = 1; static final int STARTING_WINDOW_SHOWN = 1; static final int STARTING_WINDOW_REMOVED = 2; static final int STARTING_WINDOW_REMOVED = 2; int mStartingWindowState = STARTING_WINDOW_NOT_SHOWN; int mStartingWindowState = STARTING_WINDOW_NOT_SHOWN; boolean mTaskOverlay = false; // Task is always on-top of other activities in the task. private boolean mTaskOverlay = false; // Task is always on-top of other activities in the task. // Marking the reason why this activity is being relaunched. Mainly used to track that this // Marking the reason why this activity is being relaunched. Mainly used to track that this // activity is being relaunched to fulfill a resize request due to compatibility issues, e.g. in // activity is being relaunched to fulfill a resize request due to compatibility issues, e.g. in Loading Loading @@ -1222,7 +1222,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } } ActivityStack getStack() { ActivityStack getStack() { return task != null ? task.getTaskStack() : null; return task != null ? task.getStack() : null; } } @Override @Override Loading Loading @@ -1269,8 +1269,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (getDisplayContent() != null) { if (getDisplayContent() != null) { getDisplayContent().mClosingApps.remove(this); getDisplayContent().mClosingApps.remove(this); } } } else if (mLastParent != null && mLastParent.getTaskStack() != null) { } else if (mLastParent != null && mLastParent.getStack() != null) { task.getTaskStack().mExitingActivities.remove(this); task.getStack().mExitingActivities.remove(this); } } final ActivityStack stack = getStack(); final ActivityStack stack = getStack(); Loading Loading @@ -5523,7 +5523,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (stack == null) { if (stack == null) { return INVALID_DISPLAY; return INVALID_DISPLAY; } } return stack.mDisplayId; return stack.getDisplayId(); } } final boolean isDestroyable() { final boolean isDestroyable() { Loading Loading @@ -7451,6 +7451,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return this == rootActivity; return this == rootActivity; } } void setTaskOverlay(boolean taskOverlay) { mTaskOverlay = taskOverlay; setAlwaysOnTop(mTaskOverlay); } boolean isTaskOverlay() { return mTaskOverlay; } @Override @Override public String toString() { public String toString() { if (stringName != null) { if (stringName != null) { Loading services/core/java/com/android/server/wm/ActivityStack.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -310,7 +310,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn int mCurrentUser; int mCurrentUser; /** The attached Display's unique identifier, or -1 if detached */ /** The attached Display's unique identifier, or -1 if detached */ int mDisplayId; private int mDisplayId; // Id of the previous display the stack was on. // Id of the previous display the stack was on. int mPrevDisplayId = INVALID_DISPLAY; int mPrevDisplayId = INVALID_DISPLAY; Loading Loading @@ -1013,6 +1013,10 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn return getDisplayContent(); return getDisplayContent(); } } int getDisplayId() { return mDisplayId; } /** /** * Defers updating the bounds of the stack. If the stack was resized/repositioned while * Defers updating the bounds of the stack. If the stack was resized/repositioned while * deferring, the bounds will update in {@link #continueUpdateBounds()}. * deferring, the bounds will update in {@link #continueUpdateBounds()}. Loading Loading @@ -1082,7 +1086,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn } } private ActivityRecord topRunningNonOverlayTaskActivity() { private ActivityRecord topRunningNonOverlayTaskActivity() { return getActivity((r) -> (r.canBeTopRunning() && !r.mTaskOverlay)); return getActivity((r) -> (r.canBeTopRunning() && !r.isTaskOverlay())); } } ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) { ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) { Loading services/core/java/com/android/server/wm/ActivityStackSupervisor.java +9 −5 Original line number Original line Diff line number Diff line Loading @@ -571,14 +571,14 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } } } } void setNextTaskIdForUserLocked(int taskId, int userId) { void setNextTaskIdForUser(int taskId, int userId) { final int currentTaskId = mCurTaskIdForUser.get(userId, -1); final int currentTaskId = mCurTaskIdForUser.get(userId, -1); if (taskId > currentTaskId) { if (taskId > currentTaskId) { mCurTaskIdForUser.put(userId, taskId); mCurTaskIdForUser.put(userId, taskId); } } } } static int nextTaskIdForUser(int taskId, int userId) { private static int nextTaskIdForUser(int taskId, int userId) { int nextTaskId = taskId + 1; int nextTaskId = taskId + 1; if (nextTaskId == (userId + 1) * MAX_TASK_IDS_PER_USER) { if (nextTaskId == (userId + 1) * MAX_TASK_IDS_PER_USER) { // Wrap around as there will be smaller task ids that are available now. // Wrap around as there will be smaller task ids that are available now. Loading @@ -587,7 +587,11 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { return nextTaskId; return nextTaskId; } } int getNextTaskIdForUserLocked(int userId) { int getNextTaskIdForUser() { return getNextTaskIdForUser(mRootWindowContainer.mCurrentUser); } int getNextTaskIdForUser(int userId) { final int currentTaskId = mCurTaskIdForUser.get(userId, userId * MAX_TASK_IDS_PER_USER); final int currentTaskId = mCurTaskIdForUser.get(userId, userId * MAX_TASK_IDS_PER_USER); // for a userId u, a taskId can only be in the range // for a userId u, a taskId can only be in the range // [u*MAX_TASK_IDS_PER_USER, (u+1)*MAX_TASK_IDS_PER_USER-1], so if MAX_TASK_IDS_PER_USER // [u*MAX_TASK_IDS_PER_USER, (u+1)*MAX_TASK_IDS_PER_USER-1], so if MAX_TASK_IDS_PER_USER Loading Loading @@ -1955,7 +1959,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { // Ensure that we're not moving a task to a dynamic stack if device doesn't support // Ensure that we're not moving a task to a dynamic stack if device doesn't support // multi-display. // multi-display. if (stack.mDisplayId != DEFAULT_DISPLAY && !mService.mSupportsMultiDisplay) { if (stack.getDisplayId() != DEFAULT_DISPLAY && !mService.mSupportsMultiDisplay) { throw new IllegalArgumentException("Device doesn't support multi-display, can not" throw new IllegalArgumentException("Device doesn't support multi-display, can not" + " reparent task=" + task + " to stackId=" + stackId); + " reparent task=" + task + " to stackId=" + stackId); } } Loading Loading @@ -2443,7 +2447,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { // Handle incorrect launch/move to secondary display if needed. // Handle incorrect launch/move to secondary display if needed. if (isSecondaryDisplayPreferred) { if (isSecondaryDisplayPreferred) { final int actualDisplayId = task.getStack().mDisplayId; final int actualDisplayId = task.getDisplayId(); if (!task.canBeLaunchedOnDisplay(actualDisplayId)) { if (!task.canBeLaunchedOnDisplay(actualDisplayId)) { throw new IllegalStateException("Task resolved to incompatible display"); throw new IllegalStateException("Task resolved to incompatible display"); } } Loading services/core/java/com/android/server/wm/ActivityStarter.java +9 −8 Original line number Original line Diff line number Diff line Loading @@ -1073,7 +1073,8 @@ class ActivityStarter { mRootWindowContainer.getTopDisplayFocusedStack(); mRootWindowContainer.getTopDisplayFocusedStack(); Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false) + "} from uid " + callingUid + " on display " true, false) + "} from uid " + callingUid + " on display " + (focusedStack == null ? DEFAULT_DISPLAY : focusedStack.mDisplayId)); + (focusedStack == null ? DEFAULT_DISPLAY : focusedStack.getDisplayId())); } } } } } } Loading Loading @@ -1576,7 +1577,7 @@ class ActivityStarter { final ActivityRecord topTaskActivity = final ActivityRecord topTaskActivity = mStartActivity.getTask().topRunningActivityLocked(); mStartActivity.getTask().topRunningActivityLocked(); if (!mTargetStack.isFocusable() if (!mTargetStack.isFocusable() || (topTaskActivity != null && topTaskActivity.mTaskOverlay || (topTaskActivity != null && topTaskActivity.isTaskOverlay() && mStartActivity != topTaskActivity)) { && mStartActivity != topTaskActivity)) { // If the activity is not focusable, we can't resume it, but still would like to // If the activity is not focusable, we can't resume it, but still would like to // make sure it becomes visible as it starts (this will also trigger entry // make sure it becomes visible as it starts (this will also trigger entry Loading Loading @@ -2044,7 +2045,7 @@ class ActivityStarter { if (mOptions != null) { if (mOptions != null) { if (mOptions.getLaunchTaskId() != -1 && mOptions.getTaskOverlay()) { if (mOptions.getLaunchTaskId() != -1 && mOptions.getTaskOverlay()) { r.mTaskOverlay = true; r.setTaskOverlay(true); if (!mOptions.canTaskOverlayResume()) { if (!mOptions.canTaskOverlayResume()) { final Task task = mRootWindowContainer.anyTaskForId( final Task task = mRootWindowContainer.anyTaskForId( mOptions.getLaunchTaskId()); mOptions.getLaunchTaskId()); Loading Loading @@ -2293,7 +2294,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.mDisplayId) { if (mPreferredDisplayId == mTargetStack.getDisplayId()) { 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 @@ -2343,7 +2344,7 @@ class ActivityStarter { } } mMovedToFront = launchStack != launchStack.getDisplay() mMovedToFront = launchStack != launchStack.getDisplay() .getTopStackInWindowingMode(launchStack.getWindowingMode()); .getTopStackInWindowingMode(launchStack.getWindowingMode()); } else if (launchStack.mDisplayId != mTargetStack.mDisplayId) { } else if (launchStack.getDisplayId() != mTargetStack.getDisplayId()) { // Target and computed stacks are on different displays and we've // Target and computed stacks are on different displays and we've // found a matching task - move the existing instance to that display and // found a matching task - move the existing instance to that display and // move it to front. // move it to front. Loading Loading @@ -2392,7 +2393,7 @@ class ActivityStarter { private void setNewTask(Task taskToAffiliate) { private void setNewTask(Task taskToAffiliate) { final boolean toTop = !mLaunchTaskBehind && !mAvoidMoveToFront; final boolean toTop = !mLaunchTaskBehind && !mAvoidMoveToFront; final Task task = mTargetStack.createTask( final Task task = mTargetStack.createTask( mSupervisor.getNextTaskIdForUserLocked(mStartActivity.mUserId), mSupervisor.getNextTaskIdForUser(mStartActivity.mUserId), mNewTaskInfo != null ? mNewTaskInfo : mStartActivity.info, mNewTaskInfo != null ? mNewTaskInfo : mStartActivity.info, mNewTaskIntent != null ? mNewTaskIntent : mIntent, mVoiceSession, mNewTaskIntent != null ? mNewTaskIntent : mIntent, mVoiceSession, mVoiceInteractor, toTop, mStartActivity, mSourceRecord, mOptions); mVoiceInteractor, toTop, mStartActivity, mSourceRecord, mOptions); Loading Loading @@ -2545,12 +2546,12 @@ class ActivityStarter { // Dynamic stacks behave similarly to the fullscreen stack and can contain any // Dynamic stacks behave similarly to the fullscreen stack and can contain any // resizeable task. // resizeable task. canUseFocusedStack = !focusedStack.isOnHomeDisplay() canUseFocusedStack = !focusedStack.isOnHomeDisplay() && r.canBeLaunchedOnDisplay(focusedStack.mDisplayId); && r.canBeLaunchedOnDisplay(focusedStack.getDisplayId()); } } } } return canUseFocusedStack && !newTask return canUseFocusedStack && !newTask // Using the focus stack isn't important enough to override the preferred display. // Using the focus stack isn't important enough to override the preferred display. && (mPreferredDisplayId == focusedStack.mDisplayId); && (mPreferredDisplayId == focusedStack.getDisplayId()); } } private ActivityStack getLaunchStack(ActivityRecord r, int launchFlags, Task task, private ActivityStack getLaunchStack(ActivityRecord r, int launchFlags, Task task, Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -2043,8 +2043,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { public int getDisplayId(IBinder activityToken) throws RemoteException { public int getDisplayId(IBinder activityToken) throws RemoteException { synchronized (mGlobalLock) { synchronized (mGlobalLock) { final ActivityStack stack = ActivityRecord.getStackLocked(activityToken); final ActivityStack stack = ActivityRecord.getStackLocked(activityToken); if (stack != null && stack.mDisplayId != INVALID_DISPLAY) { if (stack != null && stack.getDisplayId() != INVALID_DISPLAY) { return stack.mDisplayId; return stack.getDisplayId(); } } return DEFAULT_DISPLAY; return DEFAULT_DISPLAY; } } Loading Loading @@ -3202,7 +3202,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { final ActivityStack stack = r.getActivityStack(); final ActivityStack stack = r.getActivityStack(); final Task task = stack.createTask( final Task task = stack.createTask( mStackSupervisor.getNextTaskIdForUserLocked(r.mUserId), ainfo, intent, mStackSupervisor.getNextTaskIdForUser(r.mUserId), ainfo, intent, null /* voiceSession */, null /* voiceInteractor */, !ON_TOP); null /* voiceSession */, null /* voiceInteractor */, !ON_TOP); if (!mRecentTasks.addToBottom(task)) { if (!mRecentTasks.addToBottom(task)) { // The app has too many tasks already and we can't add any more // The app has too many tasks already and we can't add any more Loading Loading @@ -4312,7 +4312,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { if (params.hasSetAspectRatio() if (params.hasSetAspectRatio() && !mWindowManager.isValidPictureInPictureAspectRatio( && !mWindowManager.isValidPictureInPictureAspectRatio( r.getActivityStack().mDisplayId, params.getAspectRatio())) { r.getDisplayId(), params.getAspectRatio())) { final float minAspectRatio = mContext.getResources().getFloat( final float minAspectRatio = mContext.getResources().getFloat( com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio); com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio); final float maxAspectRatio = mContext.getResources().getFloat( final float maxAspectRatio = mContext.getResources().getFloat( Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +14 −5 Original line number Original line Diff line number Diff line Loading @@ -521,7 +521,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A static final int STARTING_WINDOW_SHOWN = 1; static final int STARTING_WINDOW_SHOWN = 1; static final int STARTING_WINDOW_REMOVED = 2; static final int STARTING_WINDOW_REMOVED = 2; int mStartingWindowState = STARTING_WINDOW_NOT_SHOWN; int mStartingWindowState = STARTING_WINDOW_NOT_SHOWN; boolean mTaskOverlay = false; // Task is always on-top of other activities in the task. private boolean mTaskOverlay = false; // Task is always on-top of other activities in the task. // Marking the reason why this activity is being relaunched. Mainly used to track that this // Marking the reason why this activity is being relaunched. Mainly used to track that this // activity is being relaunched to fulfill a resize request due to compatibility issues, e.g. in // activity is being relaunched to fulfill a resize request due to compatibility issues, e.g. in Loading Loading @@ -1222,7 +1222,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } } ActivityStack getStack() { ActivityStack getStack() { return task != null ? task.getTaskStack() : null; return task != null ? task.getStack() : null; } } @Override @Override Loading Loading @@ -1269,8 +1269,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (getDisplayContent() != null) { if (getDisplayContent() != null) { getDisplayContent().mClosingApps.remove(this); getDisplayContent().mClosingApps.remove(this); } } } else if (mLastParent != null && mLastParent.getTaskStack() != null) { } else if (mLastParent != null && mLastParent.getStack() != null) { task.getTaskStack().mExitingActivities.remove(this); task.getStack().mExitingActivities.remove(this); } } final ActivityStack stack = getStack(); final ActivityStack stack = getStack(); Loading Loading @@ -5523,7 +5523,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (stack == null) { if (stack == null) { return INVALID_DISPLAY; return INVALID_DISPLAY; } } return stack.mDisplayId; return stack.getDisplayId(); } } final boolean isDestroyable() { final boolean isDestroyable() { Loading Loading @@ -7451,6 +7451,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return this == rootActivity; return this == rootActivity; } } void setTaskOverlay(boolean taskOverlay) { mTaskOverlay = taskOverlay; setAlwaysOnTop(mTaskOverlay); } boolean isTaskOverlay() { return mTaskOverlay; } @Override @Override public String toString() { public String toString() { if (stringName != null) { if (stringName != null) { Loading
services/core/java/com/android/server/wm/ActivityStack.java +6 −2 Original line number Original line Diff line number Diff line Loading @@ -310,7 +310,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn int mCurrentUser; int mCurrentUser; /** The attached Display's unique identifier, or -1 if detached */ /** The attached Display's unique identifier, or -1 if detached */ int mDisplayId; private int mDisplayId; // Id of the previous display the stack was on. // Id of the previous display the stack was on. int mPrevDisplayId = INVALID_DISPLAY; int mPrevDisplayId = INVALID_DISPLAY; Loading Loading @@ -1013,6 +1013,10 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn return getDisplayContent(); return getDisplayContent(); } } int getDisplayId() { return mDisplayId; } /** /** * Defers updating the bounds of the stack. If the stack was resized/repositioned while * Defers updating the bounds of the stack. If the stack was resized/repositioned while * deferring, the bounds will update in {@link #continueUpdateBounds()}. * deferring, the bounds will update in {@link #continueUpdateBounds()}. Loading Loading @@ -1082,7 +1086,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn } } private ActivityRecord topRunningNonOverlayTaskActivity() { private ActivityRecord topRunningNonOverlayTaskActivity() { return getActivity((r) -> (r.canBeTopRunning() && !r.mTaskOverlay)); return getActivity((r) -> (r.canBeTopRunning() && !r.isTaskOverlay())); } } ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) { ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) { Loading
services/core/java/com/android/server/wm/ActivityStackSupervisor.java +9 −5 Original line number Original line Diff line number Diff line Loading @@ -571,14 +571,14 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } } } } void setNextTaskIdForUserLocked(int taskId, int userId) { void setNextTaskIdForUser(int taskId, int userId) { final int currentTaskId = mCurTaskIdForUser.get(userId, -1); final int currentTaskId = mCurTaskIdForUser.get(userId, -1); if (taskId > currentTaskId) { if (taskId > currentTaskId) { mCurTaskIdForUser.put(userId, taskId); mCurTaskIdForUser.put(userId, taskId); } } } } static int nextTaskIdForUser(int taskId, int userId) { private static int nextTaskIdForUser(int taskId, int userId) { int nextTaskId = taskId + 1; int nextTaskId = taskId + 1; if (nextTaskId == (userId + 1) * MAX_TASK_IDS_PER_USER) { if (nextTaskId == (userId + 1) * MAX_TASK_IDS_PER_USER) { // Wrap around as there will be smaller task ids that are available now. // Wrap around as there will be smaller task ids that are available now. Loading @@ -587,7 +587,11 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { return nextTaskId; return nextTaskId; } } int getNextTaskIdForUserLocked(int userId) { int getNextTaskIdForUser() { return getNextTaskIdForUser(mRootWindowContainer.mCurrentUser); } int getNextTaskIdForUser(int userId) { final int currentTaskId = mCurTaskIdForUser.get(userId, userId * MAX_TASK_IDS_PER_USER); final int currentTaskId = mCurTaskIdForUser.get(userId, userId * MAX_TASK_IDS_PER_USER); // for a userId u, a taskId can only be in the range // for a userId u, a taskId can only be in the range // [u*MAX_TASK_IDS_PER_USER, (u+1)*MAX_TASK_IDS_PER_USER-1], so if MAX_TASK_IDS_PER_USER // [u*MAX_TASK_IDS_PER_USER, (u+1)*MAX_TASK_IDS_PER_USER-1], so if MAX_TASK_IDS_PER_USER Loading Loading @@ -1955,7 +1959,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { // Ensure that we're not moving a task to a dynamic stack if device doesn't support // Ensure that we're not moving a task to a dynamic stack if device doesn't support // multi-display. // multi-display. if (stack.mDisplayId != DEFAULT_DISPLAY && !mService.mSupportsMultiDisplay) { if (stack.getDisplayId() != DEFAULT_DISPLAY && !mService.mSupportsMultiDisplay) { throw new IllegalArgumentException("Device doesn't support multi-display, can not" throw new IllegalArgumentException("Device doesn't support multi-display, can not" + " reparent task=" + task + " to stackId=" + stackId); + " reparent task=" + task + " to stackId=" + stackId); } } Loading Loading @@ -2443,7 +2447,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { // Handle incorrect launch/move to secondary display if needed. // Handle incorrect launch/move to secondary display if needed. if (isSecondaryDisplayPreferred) { if (isSecondaryDisplayPreferred) { final int actualDisplayId = task.getStack().mDisplayId; final int actualDisplayId = task.getDisplayId(); if (!task.canBeLaunchedOnDisplay(actualDisplayId)) { if (!task.canBeLaunchedOnDisplay(actualDisplayId)) { throw new IllegalStateException("Task resolved to incompatible display"); throw new IllegalStateException("Task resolved to incompatible display"); } } Loading
services/core/java/com/android/server/wm/ActivityStarter.java +9 −8 Original line number Original line Diff line number Diff line Loading @@ -1073,7 +1073,8 @@ class ActivityStarter { mRootWindowContainer.getTopDisplayFocusedStack(); mRootWindowContainer.getTopDisplayFocusedStack(); Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false) + "} from uid " + callingUid + " on display " true, false) + "} from uid " + callingUid + " on display " + (focusedStack == null ? DEFAULT_DISPLAY : focusedStack.mDisplayId)); + (focusedStack == null ? DEFAULT_DISPLAY : focusedStack.getDisplayId())); } } } } } } Loading Loading @@ -1576,7 +1577,7 @@ class ActivityStarter { final ActivityRecord topTaskActivity = final ActivityRecord topTaskActivity = mStartActivity.getTask().topRunningActivityLocked(); mStartActivity.getTask().topRunningActivityLocked(); if (!mTargetStack.isFocusable() if (!mTargetStack.isFocusable() || (topTaskActivity != null && topTaskActivity.mTaskOverlay || (topTaskActivity != null && topTaskActivity.isTaskOverlay() && mStartActivity != topTaskActivity)) { && mStartActivity != topTaskActivity)) { // If the activity is not focusable, we can't resume it, but still would like to // If the activity is not focusable, we can't resume it, but still would like to // make sure it becomes visible as it starts (this will also trigger entry // make sure it becomes visible as it starts (this will also trigger entry Loading Loading @@ -2044,7 +2045,7 @@ class ActivityStarter { if (mOptions != null) { if (mOptions != null) { if (mOptions.getLaunchTaskId() != -1 && mOptions.getTaskOverlay()) { if (mOptions.getLaunchTaskId() != -1 && mOptions.getTaskOverlay()) { r.mTaskOverlay = true; r.setTaskOverlay(true); if (!mOptions.canTaskOverlayResume()) { if (!mOptions.canTaskOverlayResume()) { final Task task = mRootWindowContainer.anyTaskForId( final Task task = mRootWindowContainer.anyTaskForId( mOptions.getLaunchTaskId()); mOptions.getLaunchTaskId()); Loading Loading @@ -2293,7 +2294,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.mDisplayId) { if (mPreferredDisplayId == mTargetStack.getDisplayId()) { 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 @@ -2343,7 +2344,7 @@ class ActivityStarter { } } mMovedToFront = launchStack != launchStack.getDisplay() mMovedToFront = launchStack != launchStack.getDisplay() .getTopStackInWindowingMode(launchStack.getWindowingMode()); .getTopStackInWindowingMode(launchStack.getWindowingMode()); } else if (launchStack.mDisplayId != mTargetStack.mDisplayId) { } else if (launchStack.getDisplayId() != mTargetStack.getDisplayId()) { // Target and computed stacks are on different displays and we've // Target and computed stacks are on different displays and we've // found a matching task - move the existing instance to that display and // found a matching task - move the existing instance to that display and // move it to front. // move it to front. Loading Loading @@ -2392,7 +2393,7 @@ class ActivityStarter { private void setNewTask(Task taskToAffiliate) { private void setNewTask(Task taskToAffiliate) { final boolean toTop = !mLaunchTaskBehind && !mAvoidMoveToFront; final boolean toTop = !mLaunchTaskBehind && !mAvoidMoveToFront; final Task task = mTargetStack.createTask( final Task task = mTargetStack.createTask( mSupervisor.getNextTaskIdForUserLocked(mStartActivity.mUserId), mSupervisor.getNextTaskIdForUser(mStartActivity.mUserId), mNewTaskInfo != null ? mNewTaskInfo : mStartActivity.info, mNewTaskInfo != null ? mNewTaskInfo : mStartActivity.info, mNewTaskIntent != null ? mNewTaskIntent : mIntent, mVoiceSession, mNewTaskIntent != null ? mNewTaskIntent : mIntent, mVoiceSession, mVoiceInteractor, toTop, mStartActivity, mSourceRecord, mOptions); mVoiceInteractor, toTop, mStartActivity, mSourceRecord, mOptions); Loading Loading @@ -2545,12 +2546,12 @@ class ActivityStarter { // Dynamic stacks behave similarly to the fullscreen stack and can contain any // Dynamic stacks behave similarly to the fullscreen stack and can contain any // resizeable task. // resizeable task. canUseFocusedStack = !focusedStack.isOnHomeDisplay() canUseFocusedStack = !focusedStack.isOnHomeDisplay() && r.canBeLaunchedOnDisplay(focusedStack.mDisplayId); && r.canBeLaunchedOnDisplay(focusedStack.getDisplayId()); } } } } return canUseFocusedStack && !newTask return canUseFocusedStack && !newTask // Using the focus stack isn't important enough to override the preferred display. // Using the focus stack isn't important enough to override the preferred display. && (mPreferredDisplayId == focusedStack.mDisplayId); && (mPreferredDisplayId == focusedStack.getDisplayId()); } } private ActivityStack getLaunchStack(ActivityRecord r, int launchFlags, Task task, private ActivityStack getLaunchStack(ActivityRecord r, int launchFlags, Task task, Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -2043,8 +2043,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { public int getDisplayId(IBinder activityToken) throws RemoteException { public int getDisplayId(IBinder activityToken) throws RemoteException { synchronized (mGlobalLock) { synchronized (mGlobalLock) { final ActivityStack stack = ActivityRecord.getStackLocked(activityToken); final ActivityStack stack = ActivityRecord.getStackLocked(activityToken); if (stack != null && stack.mDisplayId != INVALID_DISPLAY) { if (stack != null && stack.getDisplayId() != INVALID_DISPLAY) { return stack.mDisplayId; return stack.getDisplayId(); } } return DEFAULT_DISPLAY; return DEFAULT_DISPLAY; } } Loading Loading @@ -3202,7 +3202,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { final ActivityStack stack = r.getActivityStack(); final ActivityStack stack = r.getActivityStack(); final Task task = stack.createTask( final Task task = stack.createTask( mStackSupervisor.getNextTaskIdForUserLocked(r.mUserId), ainfo, intent, mStackSupervisor.getNextTaskIdForUser(r.mUserId), ainfo, intent, null /* voiceSession */, null /* voiceInteractor */, !ON_TOP); null /* voiceSession */, null /* voiceInteractor */, !ON_TOP); if (!mRecentTasks.addToBottom(task)) { if (!mRecentTasks.addToBottom(task)) { // The app has too many tasks already and we can't add any more // The app has too many tasks already and we can't add any more Loading Loading @@ -4312,7 +4312,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { if (params.hasSetAspectRatio() if (params.hasSetAspectRatio() && !mWindowManager.isValidPictureInPictureAspectRatio( && !mWindowManager.isValidPictureInPictureAspectRatio( r.getActivityStack().mDisplayId, params.getAspectRatio())) { r.getDisplayId(), params.getAspectRatio())) { final float minAspectRatio = mContext.getResources().getFloat( final float minAspectRatio = mContext.getResources().getFloat( com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio); com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio); final float maxAspectRatio = mContext.getResources().getFloat( final float maxAspectRatio = mContext.getResources().getFloat( Loading