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

Commit 71f0a1f4 authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Android (Google) Code Review
Browse files

Merge "Clear calling identity before calling getSubscriptionUserHandle"

parents 2041b76d 320b6207
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);