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

Commit 234076ca authored by qinyige's avatar qinyige Committed by android-build-merger
Browse files

Merge "Avoid adding node itself as child node."

am: e0a34bf1

Change-Id: I5b86189d3ad1e3ead4b24f0c15c44d6beb2a0a4b
parents 474ed578 e0a34bf1
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ import android.text.style.AccessibilityURLSpan;
import android.text.style.ClickableSpan;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.text.style.URLSpan;
import android.util.ArraySet;
import android.util.ArraySet;
import android.util.Log;
import android.util.LongArray;
import android.util.LongArray;
import android.util.Pools.SynchronizedPool;
import android.util.Pools.SynchronizedPool;
import android.view.View;
import android.view.View;
@@ -85,6 +86,8 @@ public class AccessibilityNodeInfo implements Parcelable {


    private static final boolean DEBUG = false;
    private static final boolean DEBUG = false;


    private static final String TAG = "AccessibilityNodeInfo";

    /** @hide */
    /** @hide */
    public static final int UNDEFINED_CONNECTION_ID = -1;
    public static final int UNDEFINED_CONNECTION_ID = -1;


@@ -990,6 +993,7 @@ public class AccessibilityNodeInfo implements Parcelable {
     * <strong>Note:</strong> Cannot be called from an
     * <strong>Note:</strong> Cannot be called from an
     * {@link android.accessibilityservice.AccessibilityService}.
     * {@link android.accessibilityservice.AccessibilityService}.
     * This class is made immutable before being delivered to an AccessibilityService.
     * This class is made immutable before being delivered to an AccessibilityService.
     * Note that a view cannot be made its own child.
     * </p>
     * </p>
     *
     *
     * @param child The child.
     * @param child The child.
@@ -1037,6 +1041,7 @@ public class AccessibilityNodeInfo implements Parcelable {
     * hierarchy for accessibility purposes. This enables custom views that draw complex
     * hierarchy for accessibility purposes. This enables custom views that draw complex
     * content to report them selves as a tree of virtual views, thus conveying their
     * content to report them selves as a tree of virtual views, thus conveying their
     * logical structure.
     * logical structure.
     * Note that a view cannot be made its own child.
     * </p>
     * </p>
     *
     *
     * @param root The root of the virtual subtree.
     * @param root The root of the virtual subtree.
@@ -1054,6 +1059,11 @@ public class AccessibilityNodeInfo implements Parcelable {
        final int rootAccessibilityViewId =
        final int rootAccessibilityViewId =
            (root != null) ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
            (root != null) ? root.getAccessibilityViewId() : UNDEFINED_ITEM_ID;
        final long childNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
        final long childNodeId = makeNodeId(rootAccessibilityViewId, virtualDescendantId);
        if (childNodeId == mSourceNodeId) {
            Log.e(TAG, "Rejecting attempt to make a View its own child");
            return;
        }

        // If we're checking uniqueness and the ID already exists, abort.
        // If we're checking uniqueness and the ID already exists, abort.
        if (checked && mChildNodeIds.indexOf(childNodeId) >= 0) {
        if (checked && mChildNodeIds.indexOf(childNodeId) >= 0) {
            return;
            return;