summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--telephony/common/com/android/internal/telephony/TelephonyPermissions.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
index 86623599d984..905a90c11957 100644
--- a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
+++ b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
@@ -842,6 +842,34 @@ public final class TelephonyPermissions {
/**
* Check if calling user is associated with the given subscription.
+ * Subscription-user association check is skipped if destination address is an emergency number.
+ *
+ * @param context Context
+ * @param subId subscription ID
+ * @param callerUserHandle caller user handle
+ * @param destAddr destination address of the message
+ * @return true if destAddr is an emergency number
+ * and return false if user is not associated with the subscription.
+ */
+ public static boolean checkSubscriptionAssociatedWithUser(@NonNull Context context, int subId,
+ @NonNull UserHandle callerUserHandle, @NonNull String destAddr) {
+ // Skip subscription-user association check for emergency numbers
+ TelephonyManager tm = context.getSystemService(TelephonyManager.class);
+ final long token = Binder.clearCallingIdentity();
+ try {
+ if (tm != null && tm.isEmergencyNumber(destAddr)) {
+ Log.d(LOG_TAG, "checkSubscriptionAssociatedWithUser:"
+ + " destAddr is emergency number");
+ return true;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ return checkSubscriptionAssociatedWithUser(context, subId, callerUserHandle);
+ }
+
+ /**
+ * Check if calling user is associated with the given subscription.
* @param context Context
* @param subId subscription ID
* @param callerUserHandle caller user handle