Merge "Send same exception in case of installed package" into sc-v2-dev am: 7efbb60d22

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15941403

Change-Id: I00c3849696d578df90ab1f81fd1a3f43597b5a9b
This commit is contained in:
Sooraj Sasindran
2021-09-30 20:26:36 +00:00
committed by Automerger Merge Worker

View File

@@ -308,6 +308,12 @@ public final class TelephonyPermissions {
return checkPrivilegedReadPermissionOrCarrierPrivilegePermission( return checkPrivilegedReadPermissionOrCarrierPrivilegePermission(
context, subId, callingPackage, callingFeatureId, message, false, reportFailure); context, subId, callingPackage, callingFeatureId, message, false, reportFailure);
} }
private static void throwSecurityExceptionAsUidDoesNotHaveAccess(String message, int uid) {
throw new SecurityException(message + ": The uid " + uid
+ " does not meet the requirements to access device identifiers.");
}
/** /**
* Checks whether the app with the given pid/uid can read device identifiers. * Checks whether the app with the given pid/uid can read device identifiers.
* *
@@ -343,9 +349,14 @@ public final class TelephonyPermissions {
LegacyPermissionManager permissionManager = (LegacyPermissionManager) LegacyPermissionManager permissionManager = (LegacyPermissionManager)
context.getSystemService(Context.LEGACY_PERMISSION_SERVICE); context.getSystemService(Context.LEGACY_PERMISSION_SERVICE);
if (permissionManager.checkDeviceIdentifierAccess(callingPackage, message, callingFeatureId, try {
pid, uid) == PackageManager.PERMISSION_GRANTED) { if (permissionManager.checkDeviceIdentifierAccess(callingPackage, message,
return true; callingFeatureId,
pid, uid) == PackageManager.PERMISSION_GRANTED) {
return true;
}
} catch (SecurityException se) {
throwSecurityExceptionAsUidDoesNotHaveAccess(message, uid);
} }
if (reportFailure) { if (reportFailure) {
@@ -410,8 +421,8 @@ public final class TelephonyPermissions {
return false; return false;
} }
} }
throw new SecurityException(message + ": The user " + uid throwSecurityExceptionAsUidDoesNotHaveAccess(message, uid);
+ " does not meet the requirements to access device identifiers."); return true;
} }
/** /**