Loading services/core/java/com/android/server/wm/ActivityRecord.java +9 −15 Original line number Diff line number Diff line Loading @@ -745,7 +745,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A synchronized (mAtmService.mGlobalLock) { Slog.w(TAG, "Activity stop timeout for " + ActivityRecord.this); if (isInHistory()) { activityStopped(null /*icicle*/, null /*persistentState*/, null /*description*/); activityStopped( null /*icicle*/, null /*persistentState*/, null /*description*/); } } } Loading Loading @@ -1286,17 +1287,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A updateColorTransform(); final ActivityStack oldStack = (oldTask != null) ? oldTask.getStack() : null; final ActivityStack newStack = (newTask != null) ? newTask.getStack() : null; // Inform old stack (if present) of activity removal and new stack (if set) of activity // addition. if (oldStack != newStack) { if (oldStack != null) { oldStack.onActivityRemovedFromStack(this); } if (newStack != null) { newStack.onActivityAddedToStack(this); if (oldTask != null) { oldTask.cleanUpActivityReferences(this); } if (newTask != null && isState(RESUMED)) { newTask.setResumedActivity(this, "onParentChanged"); } } Loading Loading @@ -2904,8 +2899,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Note: Call before {@link #removeFromHistory(String)}. */ void cleanUp(boolean cleanServices, boolean setState) { final ActivityStack stack = getActivityStack(); stack.onActivityRemovedFromStack(this); task.cleanUpActivityReferences(this); deferRelaunchUntilPaused = false; frozenBeforeDestroy = false; Loading Loading @@ -5833,7 +5827,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @Override boolean isWaitingForTransitionStart() { final DisplayContent dc = getDisplayContent(); return dc.mAppTransition.isTransitionSet() return dc != null && dc.mAppTransition.isTransitionSet() && (dc.mOpeningApps.contains(this) || dc.mClosingApps.contains(this) || dc.mChangingApps.contains(this)); Loading services/core/java/com/android/server/wm/ActivityStack.java +149 −485 File changed.Preview size limit exceeded, changes collapsed. Show changes services/core/java/com/android/server/wm/ActivityStackSupervisor.java +5 −5 Original line number Diff line number Diff line Loading @@ -419,7 +419,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { final PooledConsumer c = PooledLambda.obtainConsumer( MoveTaskToFullscreenHelper::processTask, this, PooledLambda.__(Task.class)); fromStack.forAllTasks(c, false); fromStack.forAllTasks(c, false /* traverseTopToBottom */, fromStack); c.recycle(); mToDisplay = null; mTopTask = null; Loading Loading @@ -1724,7 +1724,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } else { final PooledConsumer c = PooledLambda.obtainConsumer( ActivityStackSupervisor::processRemoveTask, this, PooledLambda.__(Task.class)); stack.forAllTasks(c); stack.forAllTasks(c, true /* traverseTopToBottom */, stack); c.recycle(); } } Loading Loading @@ -1849,14 +1849,14 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { boolean restoreRecentTaskLocked(Task task, ActivityOptions aOptions, boolean onTop) { final ActivityStack stack = mRootWindowContainer.getLaunchStack(null, aOptions, task, onTop); final ActivityStack currentStack = task.getStack(); final WindowContainer parent = task.getParent(); if (currentStack == stack) { if (parent == stack) { // Nothing else to do since it is already restored in the right stack. return true; } if (currentStack != null) { if (parent != null) { // Task has already been restored once. Just re-parent it to the new stack. task.reparent(stack, POSITION_TOP, true /*moveParents*/, "restoreRecentTaskLocked"); return true; Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +6 −6 Original line number Diff line number Diff line Loading @@ -306,7 +306,7 @@ import java.util.Set; */ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityTaskManagerService" : TAG_ATM; private static final String TAG_STACK = TAG + POSTFIX_STACK; static final String TAG_STACK = TAG + POSTFIX_STACK; static final String TAG_SWITCH = TAG + POSTFIX_SWITCH; private static final String TAG_IMMERSIVE = TAG + POSTFIX_IMMERSIVE; private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS; Loading Loading @@ -2057,8 +2057,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { public int getDisplayId(IBinder activityToken) throws RemoteException { synchronized (mGlobalLock) { final ActivityStack stack = ActivityRecord.getStackLocked(activityToken); if (stack != null && stack.getDisplayId() != INVALID_DISPLAY) { return stack.getDisplayId(); if (stack != null) { final int displayId = stack.getDisplayId(); return displayId != INVALID_DISPLAY ? displayId : DEFAULT_DISPLAY; } return DEFAULT_DISPLAY; } Loading Loading @@ -3216,8 +3217,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { final ActivityStack stack = r.getActivityStack(); final Task task = stack.createTask( mStackSupervisor.getNextTaskIdForUser(r.mUserId), ainfo, intent, null /* voiceSession */, null /* voiceInteractor */, !ON_TOP); mStackSupervisor.getNextTaskIdForUser(r.mUserId), ainfo, intent, !ON_TOP); if (!mRecentTasks.addToBottom(task)) { // The app has too many tasks already and we can't add any more stack.removeChild(task, "addAppTask"); Loading Loading @@ -4385,7 +4385,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { if (params.hasSetAspectRatio() && !mWindowManager.isValidPictureInPictureAspectRatio( r.getDisplayId(), params.getAspectRatio())) { r.getDisplay(), params.getAspectRatio())) { final float minAspectRatio = mContext.getResources().getFloat( com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio); final float maxAspectRatio = mContext.getResources().getFloat( Loading services/core/java/com/android/server/wm/DisplayContent.java +48 −24 Original line number Diff line number Diff line Loading @@ -167,8 +167,10 @@ import android.app.ActivityManagerInternal; import android.app.ActivityOptions; import android.app.WindowConfiguration; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo.ScreenOrientation; import android.content.pm.ApplicationInfo; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; Loading Loading @@ -4243,7 +4245,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo ArrayList<Task> getVisibleTasks() { final ArrayList<Task> visibleTasks = new ArrayList<>(); forAllTasks(task -> { if (task.isVisible()) { if (!task.isRootTask() && task.isVisible()) { visibleTasks.add(task); } }); Loading @@ -4262,38 +4264,50 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo private void addStackReferenceIfNeeded(ActivityStack stack) { if (stack.isActivityTypeHome()) { if (mHomeStack != null) { if (!stack.isDescendantOf(mHomeStack)) { throw new IllegalArgumentException("addStackReferenceIfNeeded: home stack=" + mHomeStack + " already exist on display=" + this + " stack=" + stack); + mHomeStack + " already exist on display=" + this + " stack=" + stack); } } else { mHomeStack = stack; } } else if (stack.isActivityTypeRecents()) { if (mRecentsStack != null && mRecentsStack != stack) { if (!stack.isDescendantOf(mRecentsStack)) { throw new IllegalArgumentException( "addStackReferenceIfNeeded: recents stack=" + mRecentsStack + " already exist on display=" + this + " stack=" + stack); } } else { mRecentsStack = stack; } } final int windowingMode = stack.getWindowingMode(); if (windowingMode == WINDOWING_MODE_PINNED) { if (mPinnedStack != null) { throw new IllegalArgumentException("addStackReferenceIfNeeded: pinned stack=" + mPinnedStack + " already exist on display=" + this + " stack=" + stack); if (!stack.isDescendantOf(mPinnedStack)) { throw new IllegalArgumentException( "addStackReferenceIfNeeded: pinned stack=" + mPinnedStack + " already exist on display=" + this + " stack=" + stack); } } else { mPinnedStack = stack; } } else if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { if (mSplitScreenPrimaryStack != null) { if (!stack.isDescendantOf(mSplitScreenPrimaryStack)) { throw new IllegalArgumentException("addStackReferenceIfNeeded:" + " split-screen-primary" + " stack=" + mSplitScreenPrimaryStack + " already exist on display=" + this + " stack=" + stack); } } else { mSplitScreenPrimaryStack = stack; mDisplayContent.onSplitScreenModeActivated(); mDividerControllerLocked.notifyDockedStackExistsChanged(true); } } } void removeStackReferenceIfNeeded(ActivityStack stack) { if (stack == mHomeStack) { Loading Loading @@ -5740,6 +5754,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return mAtmService.mStackSupervisor.getNextTaskIdForUser(); } ActivityStack createStack(int windowingMode, int activityType, boolean onTop) { return createStack(windowingMode, activityType, onTop, null /*info*/, null /*intent*/); } /** * Creates a stack matching the input windowing mode and activity type on this display. * @param windowingMode The windowing mode the stack should be created in. If Loading @@ -5751,13 +5769,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * @param onTop If true the stack will be created at the top of the display, else at the bottom. * @return The newly created stack. */ ActivityStack createStack(int windowingMode, int activityType, boolean onTop) { ActivityStack createStack(int windowingMode, int activityType, boolean onTop, ActivityInfo info, Intent intent) { if (mSingleTaskInstance && getStackCount() > 0) { // Create stack on default display instead since this display can only contain 1 stack. // TODO: Kinda a hack, but better that having the decision at each call point. Hoping // this goes away once ActivityView is no longer using virtual displays. return mRootWindowContainer.getDefaultDisplay().createStack( windowingMode, activityType, onTop); windowingMode, activityType, onTop, info, intent); } if (activityType == ACTIVITY_TYPE_UNDEFINED) { Loading Loading @@ -5785,18 +5804,23 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } final int stackId = getNextStackId(); return createStackUnchecked(windowingMode, activityType, stackId, onTop); return createStackUnchecked(windowingMode, activityType, stackId, onTop, info, intent); } @VisibleForTesting ActivityStack createStackUnchecked(int windowingMode, int activityType, int stackId, boolean onTop) { int stackId, boolean onTop, ActivityInfo info, Intent intent) { if (windowingMode == WINDOWING_MODE_PINNED && activityType != ACTIVITY_TYPE_STANDARD) { throw new IllegalArgumentException("Stack with windowing mode cannot with non standard " + "activity type."); } if (info == null) { info = new ActivityInfo(); info.applicationInfo = new ApplicationInfo(); } final ActivityStack stack = new ActivityStack(this, stackId, mRootWindowContainer.mStackSupervisor, activityType); mRootWindowContainer.mStackSupervisor, activityType, info, intent); addStack(stack, onTop ? POSITION_TOP : POSITION_BOTTOM); stack.setWindowingMode(windowingMode, false /* animate */, false /* showRecents */, false /* enteringSplitScreenMode */, false /* deferEnsuringVisibility */, Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +9 −15 Original line number Diff line number Diff line Loading @@ -745,7 +745,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A synchronized (mAtmService.mGlobalLock) { Slog.w(TAG, "Activity stop timeout for " + ActivityRecord.this); if (isInHistory()) { activityStopped(null /*icicle*/, null /*persistentState*/, null /*description*/); activityStopped( null /*icicle*/, null /*persistentState*/, null /*description*/); } } } Loading Loading @@ -1286,17 +1287,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A updateColorTransform(); final ActivityStack oldStack = (oldTask != null) ? oldTask.getStack() : null; final ActivityStack newStack = (newTask != null) ? newTask.getStack() : null; // Inform old stack (if present) of activity removal and new stack (if set) of activity // addition. if (oldStack != newStack) { if (oldStack != null) { oldStack.onActivityRemovedFromStack(this); } if (newStack != null) { newStack.onActivityAddedToStack(this); if (oldTask != null) { oldTask.cleanUpActivityReferences(this); } if (newTask != null && isState(RESUMED)) { newTask.setResumedActivity(this, "onParentChanged"); } } Loading Loading @@ -2904,8 +2899,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Note: Call before {@link #removeFromHistory(String)}. */ void cleanUp(boolean cleanServices, boolean setState) { final ActivityStack stack = getActivityStack(); stack.onActivityRemovedFromStack(this); task.cleanUpActivityReferences(this); deferRelaunchUntilPaused = false; frozenBeforeDestroy = false; Loading Loading @@ -5833,7 +5827,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @Override boolean isWaitingForTransitionStart() { final DisplayContent dc = getDisplayContent(); return dc.mAppTransition.isTransitionSet() return dc != null && dc.mAppTransition.isTransitionSet() && (dc.mOpeningApps.contains(this) || dc.mClosingApps.contains(this) || dc.mChangingApps.contains(this)); Loading
services/core/java/com/android/server/wm/ActivityStack.java +149 −485 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/core/java/com/android/server/wm/ActivityStackSupervisor.java +5 −5 Original line number Diff line number Diff line Loading @@ -419,7 +419,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { final PooledConsumer c = PooledLambda.obtainConsumer( MoveTaskToFullscreenHelper::processTask, this, PooledLambda.__(Task.class)); fromStack.forAllTasks(c, false); fromStack.forAllTasks(c, false /* traverseTopToBottom */, fromStack); c.recycle(); mToDisplay = null; mTopTask = null; Loading Loading @@ -1724,7 +1724,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } else { final PooledConsumer c = PooledLambda.obtainConsumer( ActivityStackSupervisor::processRemoveTask, this, PooledLambda.__(Task.class)); stack.forAllTasks(c); stack.forAllTasks(c, true /* traverseTopToBottom */, stack); c.recycle(); } } Loading Loading @@ -1849,14 +1849,14 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { boolean restoreRecentTaskLocked(Task task, ActivityOptions aOptions, boolean onTop) { final ActivityStack stack = mRootWindowContainer.getLaunchStack(null, aOptions, task, onTop); final ActivityStack currentStack = task.getStack(); final WindowContainer parent = task.getParent(); if (currentStack == stack) { if (parent == stack) { // Nothing else to do since it is already restored in the right stack. return true; } if (currentStack != null) { if (parent != null) { // Task has already been restored once. Just re-parent it to the new stack. task.reparent(stack, POSITION_TOP, true /*moveParents*/, "restoreRecentTaskLocked"); return true; Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +6 −6 Original line number Diff line number Diff line Loading @@ -306,7 +306,7 @@ import java.util.Set; */ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityTaskManagerService" : TAG_ATM; private static final String TAG_STACK = TAG + POSTFIX_STACK; static final String TAG_STACK = TAG + POSTFIX_STACK; static final String TAG_SWITCH = TAG + POSTFIX_SWITCH; private static final String TAG_IMMERSIVE = TAG + POSTFIX_IMMERSIVE; private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS; Loading Loading @@ -2057,8 +2057,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { public int getDisplayId(IBinder activityToken) throws RemoteException { synchronized (mGlobalLock) { final ActivityStack stack = ActivityRecord.getStackLocked(activityToken); if (stack != null && stack.getDisplayId() != INVALID_DISPLAY) { return stack.getDisplayId(); if (stack != null) { final int displayId = stack.getDisplayId(); return displayId != INVALID_DISPLAY ? displayId : DEFAULT_DISPLAY; } return DEFAULT_DISPLAY; } Loading Loading @@ -3216,8 +3217,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { final ActivityStack stack = r.getActivityStack(); final Task task = stack.createTask( mStackSupervisor.getNextTaskIdForUser(r.mUserId), ainfo, intent, null /* voiceSession */, null /* voiceInteractor */, !ON_TOP); mStackSupervisor.getNextTaskIdForUser(r.mUserId), ainfo, intent, !ON_TOP); if (!mRecentTasks.addToBottom(task)) { // The app has too many tasks already and we can't add any more stack.removeChild(task, "addAppTask"); Loading Loading @@ -4385,7 +4385,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { if (params.hasSetAspectRatio() && !mWindowManager.isValidPictureInPictureAspectRatio( r.getDisplayId(), params.getAspectRatio())) { r.getDisplay(), params.getAspectRatio())) { final float minAspectRatio = mContext.getResources().getFloat( com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio); final float maxAspectRatio = mContext.getResources().getFloat( Loading
services/core/java/com/android/server/wm/DisplayContent.java +48 −24 Original line number Diff line number Diff line Loading @@ -167,8 +167,10 @@ import android.app.ActivityManagerInternal; import android.app.ActivityOptions; import android.app.WindowConfiguration; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo.ScreenOrientation; import android.content.pm.ApplicationInfo; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; Loading Loading @@ -4243,7 +4245,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo ArrayList<Task> getVisibleTasks() { final ArrayList<Task> visibleTasks = new ArrayList<>(); forAllTasks(task -> { if (task.isVisible()) { if (!task.isRootTask() && task.isVisible()) { visibleTasks.add(task); } }); Loading @@ -4262,38 +4264,50 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo private void addStackReferenceIfNeeded(ActivityStack stack) { if (stack.isActivityTypeHome()) { if (mHomeStack != null) { if (!stack.isDescendantOf(mHomeStack)) { throw new IllegalArgumentException("addStackReferenceIfNeeded: home stack=" + mHomeStack + " already exist on display=" + this + " stack=" + stack); + mHomeStack + " already exist on display=" + this + " stack=" + stack); } } else { mHomeStack = stack; } } else if (stack.isActivityTypeRecents()) { if (mRecentsStack != null && mRecentsStack != stack) { if (!stack.isDescendantOf(mRecentsStack)) { throw new IllegalArgumentException( "addStackReferenceIfNeeded: recents stack=" + mRecentsStack + " already exist on display=" + this + " stack=" + stack); } } else { mRecentsStack = stack; } } final int windowingMode = stack.getWindowingMode(); if (windowingMode == WINDOWING_MODE_PINNED) { if (mPinnedStack != null) { throw new IllegalArgumentException("addStackReferenceIfNeeded: pinned stack=" + mPinnedStack + " already exist on display=" + this + " stack=" + stack); if (!stack.isDescendantOf(mPinnedStack)) { throw new IllegalArgumentException( "addStackReferenceIfNeeded: pinned stack=" + mPinnedStack + " already exist on display=" + this + " stack=" + stack); } } else { mPinnedStack = stack; } } else if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { if (mSplitScreenPrimaryStack != null) { if (!stack.isDescendantOf(mSplitScreenPrimaryStack)) { throw new IllegalArgumentException("addStackReferenceIfNeeded:" + " split-screen-primary" + " stack=" + mSplitScreenPrimaryStack + " already exist on display=" + this + " stack=" + stack); } } else { mSplitScreenPrimaryStack = stack; mDisplayContent.onSplitScreenModeActivated(); mDividerControllerLocked.notifyDockedStackExistsChanged(true); } } } void removeStackReferenceIfNeeded(ActivityStack stack) { if (stack == mHomeStack) { Loading Loading @@ -5740,6 +5754,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return mAtmService.mStackSupervisor.getNextTaskIdForUser(); } ActivityStack createStack(int windowingMode, int activityType, boolean onTop) { return createStack(windowingMode, activityType, onTop, null /*info*/, null /*intent*/); } /** * Creates a stack matching the input windowing mode and activity type on this display. * @param windowingMode The windowing mode the stack should be created in. If Loading @@ -5751,13 +5769,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * @param onTop If true the stack will be created at the top of the display, else at the bottom. * @return The newly created stack. */ ActivityStack createStack(int windowingMode, int activityType, boolean onTop) { ActivityStack createStack(int windowingMode, int activityType, boolean onTop, ActivityInfo info, Intent intent) { if (mSingleTaskInstance && getStackCount() > 0) { // Create stack on default display instead since this display can only contain 1 stack. // TODO: Kinda a hack, but better that having the decision at each call point. Hoping // this goes away once ActivityView is no longer using virtual displays. return mRootWindowContainer.getDefaultDisplay().createStack( windowingMode, activityType, onTop); windowingMode, activityType, onTop, info, intent); } if (activityType == ACTIVITY_TYPE_UNDEFINED) { Loading Loading @@ -5785,18 +5804,23 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } final int stackId = getNextStackId(); return createStackUnchecked(windowingMode, activityType, stackId, onTop); return createStackUnchecked(windowingMode, activityType, stackId, onTop, info, intent); } @VisibleForTesting ActivityStack createStackUnchecked(int windowingMode, int activityType, int stackId, boolean onTop) { int stackId, boolean onTop, ActivityInfo info, Intent intent) { if (windowingMode == WINDOWING_MODE_PINNED && activityType != ACTIVITY_TYPE_STANDARD) { throw new IllegalArgumentException("Stack with windowing mode cannot with non standard " + "activity type."); } if (info == null) { info = new ActivityInfo(); info.applicationInfo = new ApplicationInfo(); } final ActivityStack stack = new ActivityStack(this, stackId, mRootWindowContainer.mStackSupervisor, activityType); mRootWindowContainer.mStackSupervisor, activityType, info, intent); addStack(stack, onTop ? POSITION_TOP : POSITION_BOTTOM); stack.setWindowingMode(windowingMode, false /* animate */, false /* showRecents */, false /* enteringSplitScreenMode */, false /* deferEnsuringVisibility */, Loading