Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 320b6207 authored by Thomas Nguyen's avatar Thomas Nguyen
Browse files

Clear calling identity before calling getSubscriptionUserHandle

Bug: 261200119
Test: atest CtsTelephonyTestCases:android.telephony.cts.SmsManagerTest

Change-Id: Iab22f9a8b37da4cdd512fa68b2a4018a98e02ff9
parent 171c02b1
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -134,7 +134,15 @@ public class SmsPermissions {
     */
    public boolean checkCallingOrSelfCanGetSmscAddress(String callingPackage, String message) {
        // Allow it to the default SMS app always.
        if (!isCallerDefaultSmsPackage(callingPackage)) {
        boolean isDefaultSmsPackage;
        final long identity = Binder.clearCallingIdentity();
        try {
            isDefaultSmsPackage = isCallerDefaultSmsPackage(callingPackage);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }

        if (!isDefaultSmsPackage) {
            TelephonyPermissions
                        .enforceCallingOrSelfReadPrivilegedPhoneStatePermissionOrCarrierPrivilege(
                                mContext, mPhone.getSubId(), message);
@@ -153,7 +161,15 @@ public class SmsPermissions {
     */
    public boolean checkCallingOrSelfCanSetSmscAddress(String callingPackage, String message) {
        // Allow it to the default SMS app always.
        if (!isCallerDefaultSmsPackage(callingPackage)) {
        boolean isDefaultSmsPackage;
        final long identity = Binder.clearCallingIdentity();
        try {
            isDefaultSmsPackage = isCallerDefaultSmsPackage(callingPackage);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }

        if (!isDefaultSmsPackage) {
            // Allow it with MODIFY_PHONE_STATE or Carrier Privileges
            TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
                    mContext, mPhone.getSubId(), message);