From d9db861b6e4426d435e5f49bcb9384ec6f50c905 Mon Sep 17 00:00:00 2001 From: Aishwarya Mallampati Date: Fri, 9 Feb 2024 18:12:42 +0000 Subject: 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) --- src/java/com/android/internal/telephony/SMSDispatcher.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/java/com/android/internal/telephony/SMSDispatcher.java b/src/java/com/android/internal/telephony/SMSDispatcher.java index a78242ad5a..5df9f0890e 100644 --- a/src/java/com/android/internal/telephony/SMSDispatcher.java +++ b/src/java/com/android/internal/telephony/SMSDispatcher.java @@ -2466,7 +2466,13 @@ public abstract class SMSDispatcher extends Handler { /** 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); -- cgit v1.2.3