Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f341755 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Support non-standard activity type on secondary display"

parents f0c438c3 6322c422
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -421,11 +421,16 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        final int windowingMode = stack.getWindowingMode();

        if (activityType == ACTIVITY_TYPE_HOME) {
            // TODO(b/111363427) Rollback to throws exceptions once we figure out how to properly
            // deal with home type stack when external display removed
            if (mHomeStack != null && mHomeStack != stack) {
                throw new IllegalArgumentException("addStackReferenceIfNeeded: home stack="
                // throw new IllegalArgumentException("addStackReferenceIfNeeded: home stack="
                //         + mHomeStack + " already exist on display=" + this + " stack=" + stack);
                Slog.e(TAG, "addStackReferenceIfNeeded: home stack="
                        + mHomeStack + " already exist on display=" + this + " stack=" + stack);
            }
            } else {
                mHomeStack = stack;
            }
        } else if (activityType == ACTIVITY_TYPE_RECENTS) {
            if (mRecentsStack != null && mRecentsStack != stack) {
                throw new IllegalArgumentException("addStackReferenceIfNeeded: recents stack="
+9 −11
Original line number Diff line number Diff line
@@ -2502,8 +2502,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        }
        if (displayId != INVALID_DISPLAY && canLaunchOnDisplay(r, displayId)) {
            if (r != null) {
                // TODO: This should also take in the windowing mode and activity type into account.
                stack = (T) getValidLaunchStackOnDisplay(displayId, r);
                stack = (T) getValidLaunchStackOnDisplay(displayId, r, options);
                if (stack != null) {
                    return stack;
                }
@@ -2548,12 +2547,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            }
        }

        if (display == null
                || !canLaunchOnDisplay(r, display.mDisplayId)
                // TODO: Can be removed once we figure-out how non-standard types should launch
                // outside the default display.
                || (activityType != ACTIVITY_TYPE_STANDARD
                && activityType != ACTIVITY_TYPE_UNDEFINED)) {
        if (display == null || !canLaunchOnDisplay(r, display.mDisplayId)) {
            display = getDefaultDisplay();
        }

@@ -2575,7 +2569,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
     * @param r Activity that should be launched there.
     * @return Existing stack if there is a valid one, new dynamic stack if it is valid or null.
     */
    ActivityStack getValidLaunchStackOnDisplay(int displayId, @NonNull ActivityRecord r) {
    ActivityStack getValidLaunchStackOnDisplay(int displayId, @NonNull ActivityRecord r,
            @Nullable ActivityOptions options) {
        final ActivityDisplay activityDisplay = getActivityDisplayOrCreateLocked(displayId);
        if (activityDisplay == null) {
            throw new IllegalArgumentException(
@@ -2597,7 +2592,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        // If there is no valid stack on the external display - check if new dynamic stack will do.
        if (displayId != DEFAULT_DISPLAY) {
            return activityDisplay.createStack(
                    r.getWindowingMode(), r.getActivityType(), true /*onTop*/);
                    options != null ? options.getLaunchWindowingMode() : r.getWindowingMode(),
                    options != null ? options.getLaunchActivityType() : r.getActivityType(),
                    true /*onTop*/);
        }

        Slog.w(TAG, "getValidLaunchStackOnDisplay: can't launch on displayId " + displayId);
@@ -2698,7 +2695,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
            if (displayId == currentFocus) {
                continue;
            }
            final ActivityStack stack = getValidLaunchStackOnDisplay(displayId, r);
            final ActivityStack stack = getValidLaunchStackOnDisplay(displayId, r,
                    null /* options */);
            if (stack != null) {
                return stack;
            }
+2 −2
Original line number Diff line number Diff line
@@ -2103,7 +2103,7 @@ class ActivityStarter {
            if (mTargetStack == null && targetDisplayId != sourceStack.mDisplayId) {
                // Can't use target display, lets find a stack on the source display.
                mTargetStack = mSupervisor.getValidLaunchStackOnDisplay(
                        sourceStack.mDisplayId, mStartActivity);
                        sourceStack.mDisplayId, mStartActivity, mOptions);
            }
            if (mTargetStack == null) {
                // There are no suitable stacks on the target and source display(s). Look on all
@@ -2326,7 +2326,7 @@ class ActivityStarter {

        if (mPreferredDisplayId != DEFAULT_DISPLAY) {
            // Try to put the activity in a stack on a secondary display.
            stack = mSupervisor.getValidLaunchStackOnDisplay(mPreferredDisplayId, r);
            stack = mSupervisor.getValidLaunchStackOnDisplay(mPreferredDisplayId, r, aOptions);
            if (stack == null) {
                // If source display is not suitable - look for topmost valid stack in the system.
                if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS,
+7 −2
Original line number Diff line number Diff line
@@ -3387,12 +3387,17 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        private void addStackReferenceIfNeeded(TaskStack stack) {
            if (stack.isActivityTypeHome()) {
                // TODO(b/111363427) Rollback to throws exceptions once we figure out how to
                // properly deal with home type stack when external display removed
                if (mHomeStack != null) {
                    throw new IllegalArgumentException("addStackReferenceIfNeeded: home stack="
                    // throw new IllegalArgumentException("addStackReferenceIfNeeded: home stack="
                    //        + mHomeStack + " already exist on display=" + this + " stack=" + stack);
                    Slog.e(TAG, "addStackReferenceIfNeeded: home stack="
                            + mHomeStack + " already exist on display=" + this + " stack=" + stack);
                }
                } else {
                    mHomeStack = stack;
                }
            }
            final int windowingMode = stack.getWindowingMode();
            if (windowingMode == WINDOWING_MODE_PINNED) {
                if (mPinnedStack != null) {