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

Commit 3db473fb 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: I014c3f314db5fe6c166e9833f5e8cadb15d01e96
parents df1bec85 c8bf38ce
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -37,7 +37,8 @@ import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams.WindowType;
import android.view.WindowManager.LayoutParams.WindowType;


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

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


    private final Display mDisplay;
    private final Display mDisplay;
    private final DisplayManager mDisplayManager;
    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."));
            "Presentation must be constructed on a looper thread."));


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


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


    /**
    /**
+8 −8
Original line number Original line Diff line number Diff line
@@ -756,7 +756,14 @@ class DisplayAreaPolicyBuilder {
        @VisibleForTesting
        @VisibleForTesting
        DisplayArea.Tokens findAreaForToken(WindowToken token) {
        DisplayArea.Tokens findAreaForToken(WindowToken token) {
            return mSelectRootForWindowFunc.apply(token.windowType, token.mOptions)
            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
        @VisibleForTesting
@@ -794,13 +801,6 @@ class DisplayAreaPolicyBuilder {
        public TaskDisplayArea getDefaultTaskDisplayArea() {
        public TaskDisplayArea getDefaultTaskDisplayArea() {
            return mDefaultTaskDisplayArea;
            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 {
    static class PendingArea {
+22 −11
Original line number Original line Diff line number Diff line
@@ -1123,15 +1123,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            token.mDisplayContent = this;
            token.mDisplayContent = this;
            // Add non-app token to container hierarchy on the display. App tokens are added through
            // Add non-app token to container hierarchy on the display. App tokens are added through
            // the parent container managing them (e.g. Tasks).
            // the parent container managing them (e.g. Tasks).
            switch (token.windowType) {
            final DisplayArea.Tokens da = findAreaForToken(token).asTokens();
                case TYPE_INPUT_METHOD:
            da.addChild(token);
                case TYPE_INPUT_METHOD_DIALOG:
                    mImeWindowsContainer.addChild(token);
                    break;
                default:
                    mDisplayAreaPolicy.addWindow(token);
                    break;
            }
        }
        }
    }
    }


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


    DisplayArea getAreaForWindowToken(int windowType, Bundle options,
    DisplayArea findAreaForWindowType(int windowType, Bundle options,
            boolean ownerCanManageAppToken, boolean roundedCornerOverlay) {
            boolean ownerCanManageAppToken, boolean roundedCornerOverlay) {
        // TODO(b/159767464): figure out how to find an appropriate TDA.
        // TODO(b/159767464): figure out how to find an appropriate TDA.
        if (windowType >= FIRST_APPLICATION_WINDOW && windowType <= LAST_APPLICATION_WINDOW) {
        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) {
        if (windowType == TYPE_INPUT_METHOD || windowType == TYPE_INPUT_METHOD_DIALOG) {
            return getImeContainer();
            return getImeContainer();
        }
        }
        return mDisplayAreaPolicy.getDisplayAreaForWindowToken(windowType, options,
        return mDisplayAreaPolicy.findAreaForWindowType(windowType, options,
                ownerCanManageAppToken, roundedCornerOverlay);
                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
    @Override
    DisplayContent asDisplayContent() {
    DisplayContent asDisplayContent() {
        return this;
        return this;
Loading