diff options
Diffstat (limited to 'com/android/server/am/ActivityDisplay.java')
-rw-r--r-- | com/android/server/am/ActivityDisplay.java | 150 |
1 files changed, 34 insertions, 116 deletions
diff --git a/com/android/server/am/ActivityDisplay.java b/com/android/server/am/ActivityDisplay.java index 6ed05552..8bcbfbef 100644 --- a/com/android/server/am/ActivityDisplay.java +++ b/com/android/server/am/ActivityDisplay.java @@ -16,7 +16,9 @@ package com.android.server.am; -import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; +import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; +import static android.app.ActivityManager.StackId.INVALID_STACK_ID; +import static android.app.ActivityManager.StackId.getStackIdForWindowingMode; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; @@ -46,14 +48,13 @@ import android.view.Display; import com.android.internal.annotations.VisibleForTesting; import com.android.server.wm.ConfigurationContainer; -import java.io.PrintWriter; import java.util.ArrayList; /** * Exactly one of these classes per Display in the system. Capable of holding zero or more * attached {@link ActivityStack}s. */ -class ActivityDisplay extends ConfigurationContainer<ActivityStack> { +class ActivityDisplay extends ConfigurationContainer { private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityDisplay" : TAG_AM; private static final String TAG_STACK = TAG + POSTFIX_STACK; @@ -67,7 +68,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { /** All of the stacks on this display. Order matters, topmost stack is in front of all other * stacks, bottommost behind. Accessed directly by ActivityManager package classes */ - private final ArrayList<ActivityStack> mStacks = new ArrayList<>(); + final ArrayList<ActivityStack> mStacks = new ArrayList<>(); /** Array of all UIDs that are present on the display. */ private IntArray mDisplayAccessUIDs = new IntArray(); @@ -79,13 +80,6 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { private boolean mSleeping; - // Cached reference to some special stacks we tend to get a lot so we don't need to loop - // through the list to find them. - private ActivityStack mHomeStack = null; - private ActivityStack mRecentsStack = null; - private ActivityStack mPinnedStack = null; - private ActivityStack mSplitScreenPrimaryStack = null; - ActivityDisplay(ActivityStackSupervisor supervisor, int displayId) { mSupervisor = supervisor; mDisplayId = displayId; @@ -104,7 +98,6 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { } if (DEBUG_STACK) Slog.v(TAG_STACK, "addChild: attaching " + stack + " to displayId=" + mDisplayId + " position=" + position); - addStackReferenceIfNeeded(stack); positionChildAt(stack, position); mSupervisor.mService.updateSleepIfNeededLocked(); } @@ -113,7 +106,6 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { if (DEBUG_STACK) Slog.v(TAG_STACK, "removeChild: detaching " + stack + " from displayId=" + mDisplayId); mStacks.remove(stack); - removeStackReferenceIfNeeded(stack); mSupervisor.mService.updateSleepIfNeededLocked(); } @@ -158,16 +150,6 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { * @see ConfigurationContainer#isCompatible(int, int) */ <T extends ActivityStack> T getStack(int windowingMode, int activityType) { - if (activityType == ACTIVITY_TYPE_HOME) { - return (T) mHomeStack; - } else if (activityType == ACTIVITY_TYPE_RECENTS) { - return (T) mRecentsStack; - } - if (windowingMode == WINDOWING_MODE_PINNED) { - return (T) mPinnedStack; - } else if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { - return (T) mSplitScreenPrimaryStack; - } for (int i = mStacks.size() - 1; i >= 0; --i) { final ActivityStack stack = mStacks.get(i); // TODO: Should undefined windowing and activity type be compatible with standard type? @@ -231,14 +213,10 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { if (windowingMode == WINDOWING_MODE_UNDEFINED) { // TODO: Should be okay to have stacks with with undefined windowing mode long term, but // have to set them to something for now due to logic that depending on them. - windowingMode = getWindowingMode(); // Put in current display's windowing mode - if (windowingMode == WINDOWING_MODE_UNDEFINED) { - // Else fullscreen for now... - windowingMode = WINDOWING_MODE_FULLSCREEN; - } + windowingMode = WINDOWING_MODE_FULLSCREEN; } - final boolean inSplitScreenMode = hasSplitScreenPrimaryStack(); + final boolean inSplitScreenMode = hasSplitScreenStack(); if (!inSplitScreenMode && windowingMode == WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY) { // Switch to fullscreen windowing mode if we are not in split-screen mode and we are @@ -250,7 +228,24 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { windowingMode = WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; } - final int stackId = mSupervisor.getNextStackId(); + int stackId = INVALID_STACK_ID; + if (mDisplayId == DEFAULT_DISPLAY && (activityType == ACTIVITY_TYPE_STANDARD + || activityType == ACTIVITY_TYPE_UNDEFINED)) { + // TODO: Will be removed once we are no longer using static stack ids. + stackId = getStackIdForWindowingMode(windowingMode); + if (stackId == INVALID_STACK_ID) { + // Whatever...put in fullscreen stack for now. + stackId = FULLSCREEN_WORKSPACE_STACK_ID; + } + final T stack = getStack(stackId); + if (stack != null) { + return stack; + } + } + + if (stackId == INVALID_STACK_ID) { + stackId = mSupervisor.getNextStackId(); + } final T stack = createStackUnchecked(windowingMode, activityType, stackId, onTop); @@ -296,7 +291,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { if (stack.getWindowingMode() != windowingMode) { continue; } - mSupervisor.removeStack(stack); + mSupervisor.removeStackLocked(stack.mStackId); } } } @@ -311,63 +306,12 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { for (int i = mStacks.size() - 1; i >= 0; --i) { final ActivityStack stack = mStacks.get(i); if (stack.getActivityType() == activityType) { - mSupervisor.removeStack(stack); + mSupervisor.removeStackLocked(stack.mStackId); } } } } - void onStackWindowingModeChanged(ActivityStack stack) { - removeStackReferenceIfNeeded(stack); - addStackReferenceIfNeeded(stack); - } - - private void addStackReferenceIfNeeded(ActivityStack stack) { - final int activityType = stack.getActivityType(); - final int windowingMode = stack.getWindowingMode(); - - if (activityType == ACTIVITY_TYPE_HOME) { - if (mHomeStack != null && mHomeStack != stack) { - throw new IllegalArgumentException("addStackReferenceIfNeeded: home stack=" - + mHomeStack + " already exist on display=" + this + " stack=" + stack); - } - mHomeStack = stack; - } else if (activityType == ACTIVITY_TYPE_RECENTS) { - if (mRecentsStack != null && mRecentsStack != stack) { - throw new IllegalArgumentException("addStackReferenceIfNeeded: recents stack=" - + mRecentsStack + " already exist on display=" + this + " stack=" + stack); - } - mRecentsStack = stack; - } - if (windowingMode == WINDOWING_MODE_PINNED) { - if (mPinnedStack != null && mPinnedStack != stack) { - throw new IllegalArgumentException("addStackReferenceIfNeeded: pinned stack=" - + mPinnedStack + " already exist on display=" + this - + " stack=" + stack); - } - mPinnedStack = stack; - } else if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { - if (mSplitScreenPrimaryStack != null && mSplitScreenPrimaryStack != stack) { - throw new IllegalArgumentException("addStackReferenceIfNeeded:" - + " split-screen-primary" + " stack=" + mSplitScreenPrimaryStack - + " already exist on display=" + this + " stack=" + stack); - } - mSplitScreenPrimaryStack = stack; - } - } - - private void removeStackReferenceIfNeeded(ActivityStack stack) { - if (stack == mHomeStack) { - mHomeStack = null; - } else if (stack == mRecentsStack) { - mRecentsStack = null; - } else if (stack == mPinnedStack) { - mPinnedStack = null; - } else if (stack == mSplitScreenPrimaryStack) { - mSplitScreenPrimaryStack = null; - } - } - /** Returns the top visible stack activity type that isn't in the exclude windowing mode. */ int getTopVisibleStackActivityType(int excludeWindowingMode) { for (int i = mStacks.size() - 1; i >= 0; --i) { @@ -382,42 +326,20 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { return ACTIVITY_TYPE_UNDEFINED; } - /** - * Get the topmost stack on the display. It may be different from focused stack, because - * focus may be on another display. - */ - ActivityStack getTopStack() { - return mStacks.isEmpty() ? null : mStacks.get(mStacks.size() - 1); + ActivityStack getSplitScreenStack() { + return getStack(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_UNDEFINED); } - boolean isTopStack(ActivityStack stack) { - return stack == getTopStack(); - } - - int getIndexOf(ActivityStack stack) { - return mStacks.indexOf(stack); - } - - void onLockTaskPackagesUpdated() { - for (int i = mStacks.size() - 1; i >= 0; --i) { - mStacks.get(i).onLockTaskPackagesUpdated(); - } - } - - ActivityStack getSplitScreenPrimaryStack() { - return mSplitScreenPrimaryStack; - } - - boolean hasSplitScreenPrimaryStack() { - return mSplitScreenPrimaryStack != null; + boolean hasSplitScreenStack() { + return getSplitScreenStack() != null; } PinnedActivityStack getPinnedStack() { - return (PinnedActivityStack) mPinnedStack; + return getStack(WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED); } boolean hasPinnedStack() { - return mPinnedStack != null; + return getPinnedStack() != null; } @Override @@ -431,7 +353,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { } @Override - protected ActivityStack getChildAt(int index) { + protected ConfigurationContainer getChildAt(int index) { return mStacks.get(index); } @@ -479,10 +401,6 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack> { mSleeping = asleep; } - public void dump(PrintWriter pw, String prefix) { - pw.println(prefix + "displayId=" + mDisplayId + " mStacks=" + mStacks); - } - public void writeToProto(ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); super.writeToProto(proto, CONFIGURATION_CONTAINER); |