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

Commit df99184a authored by Eugene Susla's avatar Eugene Susla
Browse files

Use structural equality for A11yNodeInfo#mChildNodeIds

A11yNodeInfo#writeToParcel relied on LongArray#equals to avoid
storing it if it's the default value, but because the equality
is be by reference, it would store it every time.
This fixes that.

Test: a11y cts
Fixes: 72460870
Change-Id: I508df9e4346e304b8ae56cc38b17e9a940d941f1
parent aa2c46cc
Loading
Loading
Loading
Loading
+16 −1
Original line number Original line Diff line number Diff line
@@ -18,9 +18,11 @@ package android.util;


import com.android.internal.util.ArrayUtils;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.Preconditions;
import com.android.internal.util.Preconditions;
import java.util.Arrays;

import libcore.util.EmptyArray;
import libcore.util.EmptyArray;


import java.util.Arrays;

/**
/**
 * Implements a growing array of long primitives.
 * Implements a growing array of long primitives.
 *
 *
@@ -216,4 +218,17 @@ public class LongArray implements Cloneable {
            throw new ArrayIndexOutOfBoundsException(mSize, index);
            throw new ArrayIndexOutOfBoundsException(mSize, index);
        }
        }
    }
    }

    /**
     * Test if each element of {@code a} equals corresponding element from {@code b}
     */
    public static boolean elementsEqual(LongArray a, LongArray b) {
        if (a.mSize != b.mSize) return false;
        for (int i = 0; i < a.mSize; i++) {
            if (a.get(i) != b.get(i)) {
                return false;
            }
        }
        return true;
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -3194,7 +3194,7 @@ public class AccessibilityNodeInfo implements Parcelable {
        fieldIndex++;
        fieldIndex++;
        if (mConnectionId != DEFAULT.mConnectionId) nonDefaultFields |= bitAt(fieldIndex);
        if (mConnectionId != DEFAULT.mConnectionId) nonDefaultFields |= bitAt(fieldIndex);
        fieldIndex++;
        fieldIndex++;
        if (!Objects.equals(mChildNodeIds, DEFAULT.mChildNodeIds)) {
        if (!LongArray.elementsEqual(mChildNodeIds, DEFAULT.mChildNodeIds)) {
            nonDefaultFields |= bitAt(fieldIndex);
            nonDefaultFields |= bitAt(fieldIndex);
        }
        }
        fieldIndex++;
        fieldIndex++;