Merge "Completely fill in permission info" into pi-dev

am: fdc891e2af

Change-Id: Iff6c239001686f523bbb89aeeeae572fab32bce0
This commit is contained in:
Todd Kennedy
2018-04-04 16:52:40 -07:00
committed by android-build-merger

View File

@@ -411,17 +411,23 @@ public final class BasePermission {
} }
public @NonNull PermissionInfo generatePermissionInfo(int adjustedProtectionLevel, int flags) { public @NonNull PermissionInfo generatePermissionInfo(int adjustedProtectionLevel, int flags) {
final boolean protectionLevelChanged = protectionLevel != adjustedProtectionLevel; PermissionInfo permissionInfo;
// if we return different protection level, don't use the cached info if (perm != null) {
if (perm != null && !protectionLevelChanged) { final boolean protectionLevelChanged = protectionLevel != adjustedProtectionLevel;
return PackageParser.generatePermissionInfo(perm, flags); permissionInfo = PackageParser.generatePermissionInfo(perm, flags);
if (protectionLevelChanged && permissionInfo == perm.info) {
// if we return different protection level, don't use the cached info
permissionInfo = new PermissionInfo(permissionInfo);
permissionInfo.protectionLevel = adjustedProtectionLevel;
}
return permissionInfo;
} }
final PermissionInfo pi = new PermissionInfo(); permissionInfo = new PermissionInfo();
pi.name = name; permissionInfo.name = name;
pi.packageName = sourcePackageName; permissionInfo.packageName = sourcePackageName;
pi.nonLocalizedLabel = name; permissionInfo.nonLocalizedLabel = name;
pi.protectionLevel = protectionLevelChanged ? adjustedProtectionLevel : protectionLevel; permissionInfo.protectionLevel = protectionLevel;
return pi; return permissionInfo;
} }
public static boolean readLPw(@NonNull Map<String, BasePermission> out, public static boolean readLPw(@NonNull Map<String, BasePermission> out,