summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aishwarya Mallampati <amallampati@google.com> 2023-03-06 18:43:08 +0000
committer Aishwarya Mallampati <amallampati@google.com> 2023-03-23 19:42:45 +0000
commit2f904345dfa798299d84a4df4a74ae987dfef0d0 (patch)
tree8526982d0528a07b2ab6cfae5bae3729d2243e63
parent98295d52fccb444cbd8da41a91b8a875b2091b04 (diff)
Skip subscription-user association check for emergency sms.
Bug: 270340388 Test: Manually sending/receiving SMS/MMS, atest com.android.providers.telephony.SmsProviderTest, atest com.android.providers.telephony.MmsProviderTest, atest com.android.providers.telephony.ProviderUtilTest, atest CtsTelephonyProviderTestCases, atest CtsTelephonyTestCases Change-Id: Iecf9a0e3187b2c74faf29bc7b3ac419f04009e6b
-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