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

Commit 9be3c7bd authored by Phil Weaver's avatar Phil Weaver
Browse files

Eliminate side effects of a11y window title.

ag/898112 added passing the window title to accessibility. To do that,
it also updated copy of the title in WindowManager.LayoutParams. That
was a behavior change, and the change broke cts tests that enforce that
the title in LayoutParams matches its expected format.

This change restores the previous behavior and adds a separate field to
LayoutParams to old an up-to-date title to pass to accessibility.

Bug: 28002185
Change-Id: Ia5b549113600b7c4fcc80b76c3f3a944dddaf483
parent b4cc4489
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1701,6 +1701,14 @@ public interface WindowManager extends ViewManager {
         */
        public int accessibilityIdOfAnchor = -1;

        /**
         * The window title isn't kept in sync with what is displayed in the title bar, so we
         * separately track the currently shown title to provide to accessibility.
         *
         * @hide
         */
        public CharSequence accessibilityTitle;

        public LayoutParams() {
            super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            type = TYPE_APPLICATION;
@@ -1749,6 +1757,7 @@ public interface WindowManager extends ViewManager {
                title = "";

            mTitle = TextUtils.stringOrSpannedString(title);
            accessibilityTitle = mTitle;
        }

        public final CharSequence getTitle() {
@@ -1808,6 +1817,7 @@ public interface WindowManager extends ViewManager {
            out.writeInt(hasManualSurfaceInsets ? 1 : 0);
            out.writeInt(needsMenuKey);
            out.writeInt(accessibilityIdOfAnchor);
            TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
        }

        public static final Parcelable.Creator<LayoutParams> CREATOR
@@ -1859,6 +1869,7 @@ public interface WindowManager extends ViewManager {
            hasManualSurfaceInsets = in.readInt() != 0;
            needsMenuKey = in.readInt();
            accessibilityIdOfAnchor = in.readInt();
            accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
        }

        @SuppressWarnings({"PointlessBitwiseExpression"})
@@ -1900,6 +1911,8 @@ public interface WindowManager extends ViewManager {
        /** {@hide} */
        public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24;
        /** {@hide} */
        public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25;
        /** {@hide} */
        public static final int EVERYTHING_CHANGED = 0xffffffff;

        // internal buffer to backup/restore parameters under compatibility mode.
@@ -2065,6 +2078,13 @@ public interface WindowManager extends ViewManager {
                changes |= ACCESSIBILITY_ANCHOR_CHANGED;
            }

            if (!Objects.equals(accessibilityTitle, o.accessibilityTitle)
                    && o.accessibilityTitle != null) {
                // NOTE: accessibilityTitle only copied if the originator set one.
                accessibilityTitle = o.accessibilityTitle;
                changes |= ACCESSIBILITY_TITLE_CHANGED;
            }

            return changes;
        }

+2 −2
Original line number Diff line number Diff line
@@ -516,8 +516,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        }
        mTitle = title;
        WindowManager.LayoutParams params = getAttributes();
        if (!TextUtils.equals(title, params.getTitle())) {
            params.setTitle(title);
        if (!TextUtils.equals(title, params.accessibilityTitle)) {
            params.accessibilityTitle = TextUtils.stringOrSpannedString(title);
            dispatchWindowAttributesChanged(getAttributes());
        }
    }
+4 −1
Original line number Diff line number Diff line
@@ -1214,7 +1214,10 @@ final class AccessibilityController {
            window.type = windowState.mAttrs.type;
            window.layer = windowState.mLayer;
            window.token = windowState.mClient.asBinder();
            window.title = windowState.mAttrs.accessibilityTitle;
            if (window.title == null) {
                window.title = windowState.mAttrs.getTitle();
            }
            window.accessibilityIdOfAnchor = windowState.mAttrs.accessibilityIdOfAnchor;

            WindowState attachedWindow = windowState.mAttachedWindow;