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

Commit eb0573ea authored by Charles Chen's avatar Charles Chen Committed by Automerger Merge Worker
Browse files

Merge "Fix IME switch dialog crash on Dual rootDA display" into sc-dev am: c8bf38ce

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14305130

Change-Id: I38c6e982c855c5320cc265290449a69f01145d0c
parents fe4dd78d c8bf38ce
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -37,7 +37,8 @@ import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams.WindowType;

import com.android.internal.util.Preconditions;
import java.util.Objects;

/**
 * Base class for presentations.
 * <p>
@@ -153,7 +154,7 @@ public class Presentation extends Dialog {

    private final Display mDisplay;
    private final DisplayManager mDisplayManager;
    private final Handler mHandler = new Handler(Preconditions.checkNotNull(Looper.myLooper(),
    private final Handler mHandler = new Handler(Objects.requireNonNull(Looper.myLooper(),
            "Presentation must be constructed on a looper thread."));

    /**
+1 −1
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ public class Preconditions {
     *     be converted to a string using {@link String#valueOf(Object)}
     * @return the non-null reference that was validated
     * @throws NullPointerException if {@code reference} is null
     * @deprecated - use {@link java.util.Objects.requireNonNull} instead.
     * @deprecated - use {@link java.util.Objects#requireNonNull} instead.
     */
    @Deprecated
    @UnsupportedAppUsage
+2 −2
Original line number Diff line number Diff line
@@ -74,8 +74,8 @@ public abstract class DisplayAreaPolicy {
     */
    public abstract void addWindow(WindowToken token);

    /** Gets the {@link DisplayArea} which a {@link WindowToken} is about to be attached to. */
    public abstract DisplayArea.Tokens getDisplayAreaForWindowToken(int type, Bundle options,
    /** Gets the {@link DisplayArea} with given window type and launched options */
    public abstract DisplayArea.Tokens findAreaForWindowType(int type, Bundle options,
            boolean ownerCanManageAppTokens, boolean roundedCornerOverlay);

    /**
+8 −8
Original line number Diff line number Diff line
@@ -756,7 +756,14 @@ class DisplayAreaPolicyBuilder {
        @VisibleForTesting
        DisplayArea.Tokens findAreaForToken(WindowToken token) {
            return mSelectRootForWindowFunc.apply(token.windowType, token.mOptions)
                    .findAreaForToken(token);
                    .findAreaForTokenInLayer(token);
        }

        @Override
        public DisplayArea.Tokens findAreaForWindowType(int type, Bundle options,
                boolean ownerCanManageAppTokens, boolean roundedCornerOverlay) {
            return mSelectRootForWindowFunc.apply(type, options).findAreaForWindowTypeInLayer(type,
                    ownerCanManageAppTokens, roundedCornerOverlay);
        }

        @VisibleForTesting
@@ -794,13 +801,6 @@ class DisplayAreaPolicyBuilder {
        public TaskDisplayArea getDefaultTaskDisplayArea() {
            return mDefaultTaskDisplayArea;
        }

        @Override
        public DisplayArea.Tokens getDisplayAreaForWindowToken(int type, Bundle options,
                boolean ownerCanManageAppTokens, boolean roundedCornerOverlay) {
            return mSelectRootForWindowFunc.apply(type, options).findAreaForToken(type,
                    ownerCanManageAppTokens, roundedCornerOverlay);
        }
    }

    static class PendingArea {
+22 −11
Original line number Diff line number Diff line
@@ -1123,15 +1123,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            token.mDisplayContent = this;
            // Add non-app token to container hierarchy on the display. App tokens are added through
            // the parent container managing them (e.g. Tasks).
            switch (token.windowType) {
                case TYPE_INPUT_METHOD:
                case TYPE_INPUT_METHOD_DIALOG:
                    mImeWindowsContainer.addChild(token);
                    break;
                default:
                    mDisplayAreaPolicy.addWindow(token);
                    break;
            }
            final DisplayArea.Tokens da = findAreaForToken(token).asTokens();
            da.addChild(token);
        }
    }

@@ -5982,7 +5975,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return mMagnificationSpec;
    }

    DisplayArea getAreaForWindowToken(int windowType, Bundle options,
    DisplayArea findAreaForWindowType(int windowType, Bundle options,
            boolean ownerCanManageAppToken, boolean roundedCornerOverlay) {
        // TODO(b/159767464): figure out how to find an appropriate TDA.
        if (windowType >= FIRST_APPLICATION_WINDOW && windowType <= LAST_APPLICATION_WINDOW) {
@@ -5994,10 +5987,28 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (windowType == TYPE_INPUT_METHOD || windowType == TYPE_INPUT_METHOD_DIALOG) {
            return getImeContainer();
        }
        return mDisplayAreaPolicy.getDisplayAreaForWindowToken(windowType, options,
        return mDisplayAreaPolicy.findAreaForWindowType(windowType, options,
                ownerCanManageAppToken, roundedCornerOverlay);
    }

    /**
     * Finds the {@link DisplayArea} for the {@link WindowToken} to attach to.
     * <p>
     * Note that the differences between this API and
     * {@link RootDisplayArea#findAreaForTokenInLayer(WindowToken)} is that this API finds a
     * {@link DisplayArea} in {@link DisplayContent} level, which may find a {@link DisplayArea}
     * from multiple {@link RootDisplayArea RootDisplayAreas} under this {@link DisplayContent}'s
     * hierarchy, while {@link RootDisplayArea#findAreaForTokenInLayer(WindowToken)} finds a
     * {@link DisplayArea.Tokens} from a {@link DisplayArea.Tokens} list mapped to window layers.
     * </p>
     *
     * @see DisplayContent#findAreaForTokenInLayer(WindowToken)
     */
    DisplayArea findAreaForToken(WindowToken windowToken) {
        return findAreaForWindowType(windowToken.getWindowType(), windowToken.mOptions,
                windowToken.mOwnerCanManageAppTokens, windowToken.mRoundedCornerOverlay);
    }

    @Override
    DisplayContent asDisplayContent() {
        return this;
Loading