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

Commit 35b71962 authored by Lee Shombert's avatar Lee Shombert
Browse files

Fix PackageManagerSettingsTest failures

Bug: 172654903

SparseArray.equals() does not compare array content.  Replace the call
to SparseArray.equals() in LegacyPermissionState.equals() with a loop
that verifies that the content is the same.

Test: FrameworksServicesTests:PackageManagerSettingsTests
Change-Id: I04e7d57ca877339d1594b7b41ea7acae2fc9bd88
parent 94590a89
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -89,8 +89,19 @@ public final class LegacyPermissionState {
            return false;
        }
        final LegacyPermissionState other = (LegacyPermissionState) object;
        return Objects.equals(mUserStates, other.mUserStates)
                && Objects.equals(mMissing, other.mMissing);
        // Hand-code equals() for mUserStates, since SparseArray only has the
        // default equals() method.
        final int userStatesSize = mUserStates.size();
        if (userStatesSize != other.mUserStates.size()) {
            return false;
        }
        for (int i = 0; i < userStatesSize; i++) {
            final int userId = mUserStates.keyAt(i);
            if (!Objects.equals(mUserStates.get(userId), other.mUserStates.get(userId))) {
                return false;
            }
        }
        return Objects.equals(mMissing, other.mMissing);
    }

    /**