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

Commit 30707bb7 authored by Svet Ganov's avatar Svet Ganov
Browse files

Use unique preference key.

The UI code was wrongly using UID as the key - it is not
unique - resulting in keeping only one app per UID in the
UI and not showing permission controls for the other apps
in this UID. This change uses the unique package plus UID
as the preference key.

bug:23937944

Change-Id: I859afcf3ec8efdcb62d0e9dacd19f771436da084
parent 3c44cc54
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ public class PermissionApps {
        }

        public String getKey() {
            return Integer.toString(getUid());
            return mPackageName + getUid();
        }

        public String getLabel() {
@@ -357,7 +357,7 @@ public class PermissionApps {
            final int result = mLabel.compareTo(another.mLabel);
            if (result == 0) {
                // Unbadged before badged.
                return getUid() - another.getUid();
                return getKey().compareTo(another.getKey());
            }
            return result;
        }
+6 −6
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@ import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.SparseArray;

import com.android.packageinstaller.permission.model.PermissionApps.PermissionApp;
import com.android.packageinstaller.permission.utils.Utils;
@@ -108,22 +108,22 @@ public class PermissionStatusReceiver extends BroadcastReceiver {
    public boolean getAppsWithPermissionsCount(Context context, int[] counts) {
        ArraySet<String> launcherPkgs = Utils.getLauncherPackages(context);
        // Indexed by uid.
        SparseArray<Boolean> grantedApps = new SparseArray<>();
        SparseArray<Boolean> allApps = new SparseArray<>();
        ArrayMap<String, Boolean> grantedApps = new ArrayMap<>();
        ArrayMap<String, Boolean> allApps = new ArrayMap<>();
        for (String group : Utils.MODERN_PERMISSION_GROUPS) {
            PermissionApps permissionApps = new PermissionApps(context,
                    group, null);
            permissionApps.loadNowWithoutUi();
            for (PermissionApp app : permissionApps.getApps()) {
                int uid = app.getUid();
                String key = app.getKey();
                if (Utils.isSystem(app, launcherPkgs)) {
                    // We default to not showing system apps, so hide them from count.
                    continue;
                }
                if (app.areRuntimePermissionsGranted()) {
                    grantedApps.put(uid, true);
                    grantedApps.put(key, true);
                }
                allApps.put(uid, true);
                allApps.put(key, true);
            }
        }
        counts[0] = grantedApps.size();