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

Commit 8dffad68 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Bug fixes in the accessibility interrogation APIs

1. AccessibilityNodeInfo was not overriding equals.

2. ViewAncestor was not calling the callback for
   setting the result of an interrogation request
   thus making the system process wait upto the
   maximal timeout.

Change-Id: I040a3c12d97f48aee319ba6414879546e71e9b8e
parent 679dd99c
Loading
Loading
Loading
Loading
+60 −62
Original line number Diff line number Diff line
@@ -4364,17 +4364,16 @@ public final class ViewAncestor extends Handler implements ViewParent,
            final IAccessibilityInteractionConnectionCallback callback =
                (IAccessibilityInteractionConnectionCallback) message.obj;

            View root = ViewAncestor.this.mView;
            if (root == null) {
                return;
            }

            AccessibilityNodeInfo info = null;
            try {
                FindByAccessibilitytIdPredicate predicate = mFindByAccessibilityIdPredicate;
                predicate.init(accessibilityId);

                View root = ViewAncestor.this.mView;
                View target = root.findViewByPredicate(predicate);
                if (target != null) {
                AccessibilityNodeInfo info = target.createAccessibilityNodeInfo();
                    info = target.createAccessibilityNodeInfo();
                }
            } finally {
                try {
                    callback.setFindAccessibilityNodeInfoResult(info, interactionId);
                } catch (RemoteException re) {
@@ -4399,13 +4398,14 @@ public final class ViewAncestor extends Handler implements ViewParent,
            final IAccessibilityInteractionConnectionCallback callback =
                (IAccessibilityInteractionConnectionCallback) message.obj;

            AccessibilityNodeInfo info = null;
            try {
                View root = ViewAncestor.this.mView;
            if (root == null) {
                return;
            }
                View target = root.findViewById(viewId);
                if (target != null) {
                AccessibilityNodeInfo info = target.createAccessibilityNodeInfo();
                    info = target.createAccessibilityNodeInfo();
                }
            } finally {
                try {
                    callback.setFindAccessibilityNodeInfoResult(info, interactionId);
                } catch (RemoteException re) {
@@ -4434,10 +4434,9 @@ public final class ViewAncestor extends Handler implements ViewParent,
                (IAccessibilityInteractionConnectionCallback) args.arg2;
            mPool.release(args);

            List<AccessibilityNodeInfo> infos = null;
            try {
                View root = ViewAncestor.this.mView;
            if (root == null) {
                return;
            }

                ArrayList<View> foundViews = mAttachInfo.mFocusablesTempList;
                foundViews.clear();
@@ -4447,7 +4446,7 @@ public final class ViewAncestor extends Handler implements ViewParent,
                    return;
                }

            List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList;
                infos = mTempAccessibilityNodeInfoList;
                infos.clear();

                final int viewCount = foundViews.size();
@@ -4455,13 +4454,14 @@ public final class ViewAncestor extends Handler implements ViewParent,
                    View foundView = foundViews.get(i);
                    infos.add(foundView.createAccessibilityNodeInfo());
                 }

            } finally {
                try {
                    callback.setFindAccessibilityNodeInfosResult(infos, interactionId);
                } catch (RemoteException re) {
                    /* ignore - the other side will time out */
                }
            }
        }

        public void performAccessibilityActionClientThread(int accessibilityId, int action,
                int interactionId, IAccessibilityInteractionConnectionCallback callback) {
@@ -4485,11 +4485,8 @@ public final class ViewAncestor extends Handler implements ViewParent,
                (IAccessibilityInteractionConnectionCallback) args.arg1;
            mPool.release(args);

            if (ViewAncestor.this.mView == null) {
                return;
            }

            boolean succeeded = false;
            try {
                switch (action) {
                    case AccessibilityNodeInfo.ACTION_FOCUS: {
                        succeeded = performActionFocus(accessibilityId);
@@ -4504,13 +4501,14 @@ public final class ViewAncestor extends Handler implements ViewParent,
                        succeeded = performActionClearSelection(accessibilityId);
                    } break;
                }

            } finally {
                try {
                    callback.setPerformAccessibilityActionResult(succeeded, interactionId);
                } catch (RemoteException re) {
                    /* ignore - the other side will time out */
                }
            }
        }

        private boolean performActionFocus(int accessibilityId) {
            View target = findViewByAccessibilityId(accessibilityId);
+21 −0
Original line number Diff line number Diff line
@@ -869,6 +869,27 @@ public class AccessibilityNodeInfo implements Parcelable {
        return actionSymbolicNames.get(action);
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (object == null) {
            return false;
        }
        if (getClass() != object.getClass()) {
            return false;
        }
        AccessibilityNodeInfo other = (AccessibilityNodeInfo) object;
        if (mAccessibilityViewId != other.mAccessibilityViewId) {
            return false;
        }
        if (mAccessibilityWindowId != other.mAccessibilityWindowId) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;