Change to update SecurityException message.
Change the message from something like "Neither user 10023 nor
current process has android.permission.READ_SMS." to
"Neither user 10023 nor current process has
android.permission.READ_PHONE_STATE or android.permission.READ_PHONE_SMS."
Bug: 23869003
Change-Id: Ie86e31000b8ee5958286ee00073ce21b9a113442
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 7e06fdf..013ee7e 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2730,7 +2730,7 @@
}
/**
- * Besides READ_PHONE_STATE, WRITE_SMS also allows apps to get phone numbers.
+ * Besides READ_PHONE_STATE, WRITE_SMS and READ_SMS also allow apps to get phone numbers.
*/
private boolean canReadPhoneNumber(String callingPackage, String message) {
// Default SMS app can always read it.
@@ -2740,11 +2740,19 @@
}
try {
return canReadPhoneState(callingPackage, message);
- } catch (SecurityException e) {
- // Can be read with READ_SMS too.
- mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_SMS, message);
- return mAppOps.noteOp(AppOpsManager.OP_READ_SMS,
- Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED;
+ } catch (SecurityException readPhoneStateSecurityException) {
+ try {
+ // Can be read with READ_SMS too.
+ mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_SMS, message);
+ return mAppOps.noteOp(AppOpsManager.OP_READ_SMS,
+ Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED;
+ } catch (SecurityException readSmsSecurityException) {
+ // Throw exception with message including both READ_PHONE_STATE and READ_SMS
+ // permissions
+ throw new SecurityException(message + ": Neither user " + Binder.getCallingUid() +
+ " nor current process has " + android.Manifest.permission.READ_PHONE_STATE +
+ " or " + android.Manifest.permission.READ_SMS + ".");
+ }
}
}