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

Commit 71bb5aa0 authored by Jackal Guo's avatar Jackal Guo Committed by android-build-merger
Browse files

Merge "A11y support for windows in a re-parented display" into qt-r1-dev

am: 6d7b49be

Change-Id: Ib01e6faf2cfe84fd05de96beaede4bc3fd7b01ab
parents 9920baf0 6d7b49be
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -830,6 +830,32 @@ public final class AccessibilityInteractionController {
        return false;
    }

    private void adjustBoundsInScreenIfNeeded(List<AccessibilityNodeInfo> infos) {
        if (infos == null || shouldBypassAdjustBoundsInScreen()) {
            return;
        }
        final int infoCount = infos.size();
        for (int i = 0; i < infoCount; i++) {
            final AccessibilityNodeInfo info = infos.get(i);
            adjustBoundsInScreenIfNeeded(info);
        }
    }

    private void adjustBoundsInScreenIfNeeded(AccessibilityNodeInfo info) {
        if (info == null || shouldBypassAdjustBoundsInScreen()) {
            return;
        }
        final Rect boundsInScreen = mTempRect;
        info.getBoundsInScreen(boundsInScreen);
        boundsInScreen.offset(mViewRootImpl.mAttachInfo.mLocationInParentDisplay.x,
                mViewRootImpl.mAttachInfo.mLocationInParentDisplay.y);
        info.setBoundsInScreen(boundsInScreen);
    }

    private boolean shouldBypassAdjustBoundsInScreen() {
        return mViewRootImpl.mAttachInfo.mLocationInParentDisplay.equals(0, 0);
    }

    private void applyAppScaleAndMagnificationSpecIfNeeded(AccessibilityNodeInfo info,
            MagnificationSpec spec) {
        if (info == null) {
@@ -921,6 +947,7 @@ public final class AccessibilityInteractionController {
            MagnificationSpec spec, Region interactiveRegion) {
        try {
            mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0;
            adjustBoundsInScreenIfNeeded(infos);
            applyAppScaleAndMagnificationSpecIfNeeded(infos, spec);
            adjustIsVisibleToUserIfNeeded(infos, interactiveRegion);
            callback.setFindAccessibilityNodeInfosResult(infos, interactionId);
@@ -939,6 +966,7 @@ public final class AccessibilityInteractionController {
            MagnificationSpec spec, Region interactiveRegion) {
        try {
            mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = 0;
            adjustBoundsInScreenIfNeeded(info);
            applyAppScaleAndMagnificationSpecIfNeeded(info, spec);
            adjustIsVisibleToUserIfNeeded(info, interactiveRegion);
            callback.setFindAccessibilityNodeInfoResult(info, interactionId);
+7 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package android.view;

import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
@@ -56,6 +57,12 @@ oneway interface IWindow {
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
            in DisplayCutout.ParcelableWrapper displayCutout);

    /**
     * Called when the window location in parent display has changed. The offset will only be a
     * nonzero value if the window is on an embedded display that is re-parented to another window.
     */
    void locationInParentDisplayChanged(in Point offset);

    /**
     * Called when the window insets configuration has changed.
     */
+6 −0
Original line number Diff line number Diff line
@@ -28551,6 +28551,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         */
        boolean mHandlingPointerEvent;
        /**
         * The offset of this view's window when it's on an embedded display that is re-parented
         * to another window.
         */
        final Point mLocationInParentDisplay = new Point();
        /**
         * Global to the view hierarchy used as a temporary for dealing with
         * x/y points in the transparent region computations.
+32 −0
Original line number Diff line number Diff line
@@ -3982,6 +3982,13 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    void updateLocationInParentDisplay(int x, int y) {
        if (mAttachInfo != null
                && !mAttachInfo.mLocationInParentDisplay.equals(x, y)) {
            mAttachInfo.mLocationInParentDisplay.set(x, y);
        }
    }

    /**
     * Set the root-level system gesture exclusion rects. These are added to those provided by
     * the root's view hierarchy.
@@ -4486,6 +4493,7 @@ public final class ViewRootImpl implements ViewParent,
    private static final int MSG_INSETS_CHANGED = 30;
    private static final int MSG_INSETS_CONTROL_CHANGED = 31;
    private static final int MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED = 32;
    private static final int MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED = 33;

    final class ViewRootHandler extends Handler {
        @Override
@@ -4547,6 +4555,8 @@ public final class ViewRootImpl implements ViewParent,
                    return "MSG_INSETS_CONTROL_CHANGED";
                case MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED:
                    return "MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED";
                case MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED:
                    return "MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED";
            }
            return super.getMessageName(message);
        }
@@ -4780,6 +4790,9 @@ public final class ViewRootImpl implements ViewParent,
                case MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED: {
                    systemGestureExclusionChanged();
                } break;
                case MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED: {
                    updateLocationInParentDisplay(msg.arg1, msg.arg2);
                } break;
            }
        }
    }
@@ -7986,6 +7999,17 @@ public final class ViewRootImpl implements ViewParent,
        mHandler.sendMessage(msg);
    }

    /**
     * Dispatch the offset changed.
     *
     * @param offset the offset of this view in the parent window.
     */
    public void dispatchLocationInParentDisplayChanged(Point offset) {
        Message msg =
                mHandler.obtainMessage(MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED, offset.x, offset.y);
        mHandler.sendMessage(msg);
    }

    public void windowFocusChanged(boolean hasFocus, boolean inTouchMode) {
        synchronized (this) {
            mWindowFocusChanged = true;
@@ -8512,6 +8536,14 @@ public final class ViewRootImpl implements ViewParent,
            }
        }

        @Override
        public void locationInParentDisplayChanged(Point offset) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            if (viewAncestor != null) {
                viewAncestor.dispatchLocationInParentDisplayChanged(offset);
            }
        }

        @Override
        public void insetsChanged(InsetsState insetsState) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.view;

import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.input.InputManager;
import android.os.Bundle;
@@ -54,6 +55,10 @@ public class BaseIWindow extends IWindow.Stub {
        }
    }

    @Override
    public void locationInParentDisplayChanged(Point offset) {
    }

    @Override
    public void insetsChanged(InsetsState insetsState) {
    }
Loading