Java Code Examples for android.util.ArraySet#equals()

The following examples show how to use android.util.ArraySet#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeySetManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Determine if a package is signed by the given KeySet.
 *
 * Returns false if the package was not signed by all the
 * keys in the KeySet, or if the package was signed by keys
 * not in the KeySet.
 *
 * Note that this can return only for one KeySet.
 */
public boolean packageIsSignedByExactlyLPr(String packageName, KeySetHandle ks) {
    PackageSetting pkg = mPackages.get(packageName);
    if (pkg == null) {
        throw new NullPointerException("Invalid package name");
    }
    if (pkg.keySetData == null
        || pkg.keySetData.getProperSigningKeySet()
        == PackageKeySetData.KEYSET_UNASSIGNED) {
        throw new NullPointerException("Package has no KeySet data");
     }
    long id = getIdByKeySetLPr(ks);
    if (id == KEYSET_NOT_FOUND) {
            return false;
    }
    ArraySet<Long> pkgKeys = mKeySetMapping.get(pkg.keySetData.getProperSigningKeySet());
    ArraySet<Long> testKeys = mKeySetMapping.get(id);
    return pkgKeys.equals(testKeys);
}
 
Example 2
Source File: KeySetManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Informs the system that the given package was signed by the provided KeySet.
 */
void addSigningKeySetToPackageLPw(PackageSetting pkg,
        ArraySet<PublicKey> signingKeys) {

    /* check existing keyset for reuse or removal */
    long signingKeySetId = pkg.keySetData.getProperSigningKeySet();

    if (signingKeySetId != PackageKeySetData.KEYSET_UNASSIGNED) {
        ArraySet<PublicKey> existingKeys = getPublicKeysFromKeySetLPr(signingKeySetId);
        if (existingKeys != null && existingKeys.equals(signingKeys)) {

            /* no change in signing keys, leave PackageSetting alone */
            return;
        } else {

            /* old keyset no longer valid, remove ref */
            decrementKeySetLPw(signingKeySetId);
        }
    }

    /* create and add a new keyset */
    KeySetHandle ks = addKeySetLPw(signingKeys);
    long id = ks.getId();
    pkg.keySetData.setProperSigningKeySet(id);
    return;
}
 
Example 3
Source File: KeySetManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the stable identifier for a KeySet based on a set of PublicKey stable IDs.
 *
 * Returns KEYSET_NOT_FOUND if there isn't one.
 */
private long getIdFromKeyIdsLPr(Set<Long> publicKeyIds) {
    for (int keyMapIndex = 0; keyMapIndex < mKeySetMapping.size(); keyMapIndex++) {
        ArraySet<Long> value = mKeySetMapping.valueAt(keyMapIndex);
        if (value.equals(publicKeyIds)) {
            return mKeySetMapping.keyAt(keyMapIndex);
        }
    }
    return KEYSET_NOT_FOUND;
}