summaryrefslogtreecommitdiff
path: root/telephony/common
diff options
context:
space:
mode:
authorSarah Chin <sarahchin@google.com>2020-03-18 18:04:18 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-18 18:04:18 +0000
commit2b004fa8e80199d4b0fc36f8158928d0e6b72d32 (patch)
tree2ed50af89e67253bdd535d944735f5a14b3c1671 /telephony/common
parent87962f9d0af171f40bea290013a03b508b5d0f78 (diff)
parent3dde71f506a35465bd8034794556df1ac300017e (diff)
Merge "Move getMsisdn and getLine1Number to READ_PHONE_NUMBERS" into rvc-dev
Diffstat (limited to 'telephony/common')
-rw-r--r--telephony/common/com/android/internal/telephony/TelephonyPermissions.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
index b89772538c6d..f0f9721744dd 100644
--- a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
+++ b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
@@ -437,8 +437,9 @@ public final class TelephonyPermissions {
/**
* Returns whether the caller can read phone numbers.
*
- * <p>Besides apps with the ability to read phone state per {@link #checkReadPhoneState}, the
- * default SMS app and apps with READ_SMS or READ_PHONE_NUMBERS can also read phone numbers.
+ * <p>Besides apps with the ability to read phone state per {@link #checkReadPhoneState}
+ * (only prior to R), the default SMS app and apps with READ_SMS or READ_PHONE_NUMBERS
+ * can also read phone numbers.
*/
public static boolean checkCallingOrSelfReadPhoneNumber(
Context context, int subId, String callingPackage, @Nullable String callingFeatureId,
@@ -451,8 +452,9 @@ public final class TelephonyPermissions {
/**
* Returns whether the caller can read phone numbers.
*
- * <p>Besides apps with the ability to read phone state per {@link #checkReadPhoneState}, the
- * default SMS app and apps with READ_SMS or READ_PHONE_NUMBERS can also read phone numbers.
+ * <p>Besides apps with the ability to read phone state per {@link #checkReadPhoneState}
+ * (only prior to R), the default SMS app and apps with READ_SMS or READ_PHONE_NUMBERS
+ * can also read phone numbers.
*/
@VisibleForTesting
public static boolean checkReadPhoneNumber(
@@ -468,12 +470,15 @@ public final class TelephonyPermissions {
// NOTE(b/73308711): If an app has one of the following AppOps bits explicitly revoked, they
// will be denied access, even if they have another permission and AppOps bit if needed.
- // First, check if we can read the phone state.
+ // First, check if we can read the phone state and the SDK version is below R.
try {
- return checkReadPhoneState(
- context, subId, pid, uid, callingPackage, callingFeatureId,
- message);
- } catch (SecurityException readPhoneStateSecurityException) {
+ ApplicationInfo info = context.getPackageManager().getApplicationInfoAsUser(
+ callingPackage, 0, UserHandle.getUserHandleForUid(Binder.getCallingUid()));
+ if (info.targetSdkVersion <= Build.VERSION_CODES.Q) {
+ return checkReadPhoneState(
+ context, subId, pid, uid, callingPackage, callingFeatureId, message);
+ }
+ } catch (SecurityException | PackageManager.NameNotFoundException e) {
}
// Can be read with READ_SMS too.
try {