Clear calling identity before calling getSubscriptionUserHandle
Bug: 320599071
Bug: 308033518
Test: Sending and receiving SMS/MMS,
atest FrameworkTelephonyTests,
atest CtsTelephonyTestCases
Change-Id: I84c74a81207d54f394721918e59eac2d89ef59e2
Merged-In: I84c74a81207d54f394721918e59eac2d89ef59e2
(cherry picked from commit 470051c41afa9846e58ebf230b2ce33236a74939)
diff --git a/src/java/com/android/internal/telephony/SMSDispatcher.java b/src/java/com/android/internal/telephony/SMSDispatcher.java
index a78242a..5df9f08 100644
--- a/src/java/com/android/internal/telephony/SMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/SMSDispatcher.java
@@ -2466,7 +2466,13 @@
/** Return if the SMS was originated from the default SMS application. */
public boolean isFromDefaultSmsApplication(Context context) {
if (mIsFromDefaultSmsApplication == null) {
- UserHandle userHandle = TelephonyUtils.getSubscriptionUserHandle(context, mSubId);
+ UserHandle userHandle;
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ userHandle = TelephonyUtils.getSubscriptionUserHandle(context, mSubId);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
// Perform a lazy initialization, due to the cost of the operation.
mIsFromDefaultSmsApplication = SmsApplication.isDefaultSmsApplicationAsUser(context,
getAppPackageName(), userHandle);