diff options
author | Sooraj Sasindran <sasindran@google.com> | 2021-09-28 02:54:35 +0000 |
---|---|---|
committer | Sooraj Sasindran <sasindran@google.com> | 2021-09-29 20:40:44 +0000 |
commit | 66ec345aa2164789e823801d2543a9b0eede6b84 (patch) | |
tree | 02c82b453453536680d18ffe78be80e0f08cef92 | |
parent | c22056bba2ccb0e8ea989a3dee6b2ba11f5d1a51 (diff) |
Send same exception in case of installed package
Send same exception in case of installed packages and
non installed packages
Bug: 194743207
Test: build
Change-Id: I2dc350721162be8d9150fbe7ce0eee8f6fdd7486
-rw-r--r-- | telephony/common/com/android/internal/telephony/TelephonyPermissions.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java index 4d81b5e54470..7a424c87d1d6 100644 --- a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java +++ b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java @@ -308,6 +308,12 @@ public final class TelephonyPermissions { return checkPrivilegedReadPermissionOrCarrierPrivilegePermission( 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. * @@ -343,9 +349,14 @@ public final class TelephonyPermissions { LegacyPermissionManager permissionManager = (LegacyPermissionManager) context.getSystemService(Context.LEGACY_PERMISSION_SERVICE); - if (permissionManager.checkDeviceIdentifierAccess(callingPackage, message, callingFeatureId, - pid, uid) == PackageManager.PERMISSION_GRANTED) { - return true; + try { + if (permissionManager.checkDeviceIdentifierAccess(callingPackage, message, + callingFeatureId, + pid, uid) == PackageManager.PERMISSION_GRANTED) { + return true; + } + } catch (SecurityException se) { + throwSecurityExceptionAsUidDoesNotHaveAccess(message, uid); } if (reportFailure) { @@ -410,8 +421,8 @@ public final class TelephonyPermissions { return false; } } - throw new SecurityException(message + ": The user " + uid - + " does not meet the requirements to access device identifiers."); + throwSecurityExceptionAsUidDoesNotHaveAccess(message, uid); + return true; } /** |