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

Commit 75f9e244 authored by Steve Kondik's avatar Steve Kondik Committed by Adnan Begovic
Browse files

packagemanager: Use ArrayMap/ArraySet as per AOSP

 * To reduce memory consumption

Change-Id: I85bdf84d4a507532e41fe29668fef9b4eabfb04a
parent de43e207
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -100,8 +100,8 @@ public class SystemConfig {
    // URL-handling state upon factory reset.
    final ArraySet<String> mLinkedApps = new ArraySet<>();

    final HashMap<Signature, HashSet<String>> mSignatureAllowances
            = new HashMap<Signature, HashSet<String>>();
    final ArrayMap<Signature, ArraySet<String>> mSignatureAllowances
            = new ArrayMap<Signature, ArraySet<String>>();

    public static SystemConfig getInstance() {
        synchronized (SystemConfig.class) {
@@ -148,7 +148,7 @@ public class SystemConfig {
        return mLinkedApps;
    }

    public HashMap<Signature, HashSet<String>> getSignatureAllowances() {
    public ArrayMap<Signature, ArraySet<String>> getSignatureAllowances() {
        return mSignatureAllowances;
    }

@@ -322,9 +322,9 @@ public class SystemConfig {
                        // sig will be null so we will log it below
                    }
                    if (sig != null) {
                        HashSet<String> perms = mSignatureAllowances.get(sig);
                        ArraySet<String> perms = mSignatureAllowances.get(sig);
                        if (perms == null) {
                            perms = new HashSet<String>();
                            perms = new ArraySet<String>();
                            mSignatureAllowances.put(sig, perms);
                        }
                        perms.add(perm);
+3 −4
Original line number Diff line number Diff line
@@ -496,7 +496,6 @@ public class PackageManagerService extends IPackageManager.Stub {
     * Whether or not system app permissions should be promoted from install to runtime.
     */
    boolean mPromoteSystemApps;
    final Settings mSettings;
    boolean mRestoredSettings;
@@ -504,7 +503,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    final int[] mGlobalGids;
    final SparseArray<ArraySet<String>> mSystemPermissions;
    final ArrayMap<String, FeatureInfo> mAvailableFeatures;
    final ArrayMap<Signature, HashSet<String>> mSignatureAllowances;
    final ArrayMap<Signature, ArraySet<String>> mSignatureAllowances;
    // If mac_permissions.xml was found for seinfo labeling.
    boolean mFoundPolicyFile;
@@ -3454,7 +3453,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    private boolean isAllowedSignature(PackageParser.Package pkg, String permissionName) {
        for (Signature pkgSig : pkg.mSignatures) {
            HashSet<String> perms = mSignatureAllowances.get(pkgSig);
            ArraySet<String> perms = mSignatureAllowances.get(pkgSig);
            if (perms != null && perms.contains(permissionName)) {
                return true;
            }
@@ -3955,7 +3954,7 @@ public class PackageManagerService extends IPackageManager.Stub {
            return PackageManager.SIGNATURE_NO_MATCH;
        }
        // Since both signature sets are of size 1, we can compare without HashSets.
        // Since both signature sets are of size 1, we can compare without ArraySets.
        if (s1.length == 1) {
            return s1[0].equals(s2[0]) ?
                    PackageManager.SIGNATURE_MATCH :