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

Commit a0ec24cb authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Completely fill in permission info

During the refactor, an optimization was made to generatePermissionInfo()
to avoid creating duplicate PermissionInfo objects. However, the logic was
flawed and if a permission's protection level was ever adjusted, we
wouldn't return a properly filled out PermissionInfo object.

Change-Id: I70b3eda199008807182f75a413651d7cb4f4b7fd
Fixes: 74556457
Test: Manual; run app com.kakao.taxi and it doesn't crash
parent 3275d9a0
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -411,17 +411,23 @@ public final class BasePermission {
    }

    public @NonNull PermissionInfo generatePermissionInfo(int adjustedProtectionLevel, int flags) {
        PermissionInfo permissionInfo;
        if (perm != null) {
            final boolean protectionLevelChanged = protectionLevel != adjustedProtectionLevel;
            permissionInfo = PackageParser.generatePermissionInfo(perm, flags);
            if (protectionLevelChanged && permissionInfo == perm.info) {
                // if we return different protection level, don't use the cached info
        if (perm != null && !protectionLevelChanged) {
            return PackageParser.generatePermissionInfo(perm, flags);
                permissionInfo = new PermissionInfo(permissionInfo);
                permissionInfo.protectionLevel = adjustedProtectionLevel;
            }
        final PermissionInfo pi = new PermissionInfo();
        pi.name = name;
        pi.packageName = sourcePackageName;
        pi.nonLocalizedLabel = name;
        pi.protectionLevel = protectionLevelChanged ? adjustedProtectionLevel : protectionLevel;
        return pi;
            return permissionInfo;
        }
        permissionInfo = new PermissionInfo();
        permissionInfo.name = name;
        permissionInfo.packageName = sourcePackageName;
        permissionInfo.nonLocalizedLabel = name;
        permissionInfo.protectionLevel = protectionLevel;
        return permissionInfo;
    }

    public static boolean readLPw(@NonNull Map<String, BasePermission> out,