Revert "Report permission flags for all protections based on SDK"
This reverts commit 852cf98cb8.
Change-Id: I62763bf85ec95a02a245c6b503aa34bb0e9d997a
This commit is contained in:
@@ -281,8 +281,7 @@ public class ApplicationPackageManager extends PackageManager {
|
|||||||
public PermissionInfo getPermissionInfo(String name, int flags)
|
public PermissionInfo getPermissionInfo(String name, int flags)
|
||||||
throws NameNotFoundException {
|
throws NameNotFoundException {
|
||||||
try {
|
try {
|
||||||
PermissionInfo pi = mPM.getPermissionInfo(name,
|
PermissionInfo pi = mPM.getPermissionInfo(name, flags);
|
||||||
mContext.getOpPackageName(), flags);
|
|
||||||
if (pi != null) {
|
if (pi != null) {
|
||||||
return pi;
|
return pi;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ interface IPackageManager {
|
|||||||
String[] currentToCanonicalPackageNames(in String[] names);
|
String[] currentToCanonicalPackageNames(in String[] names);
|
||||||
String[] canonicalToCurrentPackageNames(in String[] names);
|
String[] canonicalToCurrentPackageNames(in String[] names);
|
||||||
|
|
||||||
PermissionInfo getPermissionInfo(String name, String packageName, int flags);
|
PermissionInfo getPermissionInfo(String name, int flags);
|
||||||
|
|
||||||
ParceledListSlice queryPermissionsByGroup(String group, int flags);
|
ParceledListSlice queryPermissionsByGroup(String group, int flags);
|
||||||
|
|
||||||
|
|||||||
@@ -802,7 +802,7 @@ public final class BroadcastQueue {
|
|||||||
IPackageManager pm = AppGlobals.getPackageManager();
|
IPackageManager pm = AppGlobals.getPackageManager();
|
||||||
for (int i = perms.length-1; i >= 0; i--) {
|
for (int i = perms.length-1; i >= 0; i--) {
|
||||||
try {
|
try {
|
||||||
PermissionInfo pi = pm.getPermissionInfo(perms[i], "android", 0);
|
PermissionInfo pi = pm.getPermissionInfo(perms[i], 0);
|
||||||
if ((pi.protectionLevel & (PermissionInfo.PROTECTION_MASK_BASE
|
if ((pi.protectionLevel & (PermissionInfo.PROTECTION_MASK_BASE
|
||||||
| PermissionInfo.PROTECTION_FLAG_PRIVILEGED))
|
| PermissionInfo.PROTECTION_FLAG_PRIVILEGED))
|
||||||
!= PermissionInfo.PROTECTION_SIGNATURE) {
|
!= PermissionInfo.PROTECTION_SIGNATURE) {
|
||||||
|
|||||||
@@ -3996,64 +3996,20 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermissionInfo getPermissionInfo(String name, String packageName, int flags) {
|
public PermissionInfo getPermissionInfo(String name, int flags) {
|
||||||
final int callingUid = Binder.getCallingUid();
|
if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
|
||||||
if (getInstantAppPackageName(callingUid) != null) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// reader
|
// reader
|
||||||
synchronized (mPackages) {
|
synchronized (mPackages) {
|
||||||
final BasePermission p = mSettings.mPermissions.get(name);
|
final BasePermission p = mSettings.mPermissions.get(name);
|
||||||
// If the caller is an app that targets pre 26 SDK drop protection flags.
|
if (p != null) {
|
||||||
final PermissionInfo permissionInfo = generatePermissionInfo(p, flags);
|
return generatePermissionInfo(p, flags);
|
||||||
permissionInfo.protectionLevel = adjustPermissionProtectionFlagsLPr(
|
}
|
||||||
permissionInfo.protectionLevel, packageName, callingUid);
|
return null;
|
||||||
return permissionInfo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int adjustPermissionProtectionFlagsLPr(int protectionLevel,
|
|
||||||
String packageName, int uid) {
|
|
||||||
// Signature permission flags area always reported
|
|
||||||
final int protectionLevelMasked = protectionLevel
|
|
||||||
& (PermissionInfo.PROTECTION_NORMAL
|
|
||||||
| PermissionInfo.PROTECTION_DANGEROUS
|
|
||||||
| PermissionInfo.PROTECTION_SIGNATURE);
|
|
||||||
if (protectionLevelMasked == PermissionInfo.PROTECTION_SIGNATURE) {
|
|
||||||
return protectionLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// System sees all flags.
|
|
||||||
final int appId = UserHandle.getAppId(uid);
|
|
||||||
if (appId == Process.SYSTEM_UID || appId == Process.ROOT_UID
|
|
||||||
|| appId == Process.SHELL_UID) {
|
|
||||||
return protectionLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize package name to handle renamed packages and static libs
|
|
||||||
packageName = resolveInternalPackageNameLPr(packageName,
|
|
||||||
PackageManager.VERSION_CODE_HIGHEST);
|
|
||||||
|
|
||||||
// Apps that target O see flags for all protection levels.
|
|
||||||
final PackageSetting ps = mSettings.mPackages.get(packageName);
|
|
||||||
if (ps == null) {
|
|
||||||
return protectionLevel;
|
|
||||||
}
|
|
||||||
if (ps.appId != appId) {
|
|
||||||
return protectionLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
final PackageParser.Package pkg = mPackages.get(packageName);
|
|
||||||
if (pkg == null) {
|
|
||||||
return protectionLevel;
|
|
||||||
}
|
|
||||||
if (pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.O) {
|
|
||||||
return protectionLevelMasked;
|
|
||||||
}
|
|
||||||
|
|
||||||
return protectionLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable ParceledListSlice<PermissionInfo> queryPermissionsByGroup(String group,
|
public @Nullable ParceledListSlice<PermissionInfo> queryPermissionsByGroup(String group,
|
||||||
int flags) {
|
int flags) {
|
||||||
|
|||||||
Reference in New Issue
Block a user