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

Commit 0ce79ca6 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Don't clear the calling identity until needed for SmsManager

We were clearing the calling identity in IccSmsInterfaceManager
in order to access CarrierConfigManager. This was causing
us to also clear the calling identity in SMSDispatcher, which
needs the UID of the caller.

Bug: 129909610
Test: manual
Change-Id: I9cc0c04a876c30aa7032b0b84acb580ed95ea8a7
parent 0fee01f6
Loading
Loading
Loading
Loading
+73 −81
Original line number Diff line number Diff line
@@ -690,8 +690,6 @@ public class IccSmsInterfaceManager {
            }
        }

        final long ident = Binder.clearCallingIdentity();
        try {
        destAddr = filterDestAddress(destAddr);

        if (parts.size() > 1 && parts.size() < 10 && !SmsMessage.hasEmsSupport()) {
@@ -702,7 +700,8 @@ public class IccSmsInterfaceManager {
                if (SmsMessage.shouldAppendPageNumberAsPrefix()) {
                    singlePart = String.valueOf(i + 1) + '/' + parts.size() + ' ' + singlePart;
                } else {
                        singlePart = singlePart.concat(' ' + String.valueOf(i + 1) + '/' + parts.size());
                    singlePart = singlePart.concat(' ' + String.valueOf(i + 1) + '/'
                            + parts.size());
                }

                PendingIntent singleSentIntent = null;
@@ -731,9 +730,7 @@ public class IccSmsInterfaceManager {
                                      (ArrayList<PendingIntent>) deliveryIntents,
                                      null, callingPackage, persistMessageForNonDefaultSmsApp,
                                          priority, expectMore, validityPeriod);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }

    }

    @UnsupportedAppUsage
@@ -1183,9 +1180,6 @@ public class IccSmsInterfaceManager {
            returnUnspecifiedFailure(sentIntents);
            return;
        }

        final long ident = Binder.clearCallingIdentity();
        try {
        textAndAddress[1] = filterDestAddress(textAndAddress[1]);

        if (parts.size() > 1 && parts.size() < 10 && !SmsMessage.hasEmsSupport()) {
@@ -1196,7 +1190,8 @@ public class IccSmsInterfaceManager {
                if (SmsMessage.shouldAppendPageNumberAsPrefix()) {
                    singlePart = String.valueOf(i + 1) + '/' + parts.size() + ' ' + singlePart;
                } else {
                        singlePart = singlePart.concat(' ' + String.valueOf(i + 1) + '/' + parts.size());
                    singlePart = singlePart.concat(' ' + String.valueOf(i + 1) + '/'
                            + parts.size());
                }

                PendingIntent singleSentIntent = null;
@@ -1230,9 +1225,6 @@ public class IccSmsInterfaceManager {
                SMS_MESSAGE_PRIORITY_NOT_SPECIFIED,
                false /* expectMore */,
                SMS_MESSAGE_PERIOD_NOT_SPECIFIED);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }

    private boolean isFailedOrDraft(ContentResolver resolver, Uri messageUri) {
+14 −8
Original line number Diff line number Diff line
@@ -2008,6 +2008,9 @@ public abstract class SMSDispatcher extends Handler {
    }

    private boolean isAscii7bitSupportedForLongMessage() {
        //TODO: Do not rely on calling identity here, we should store UID & clear identity earlier.
        long token = Binder.clearCallingIdentity();
        try {
            CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(
                    Context.CARRIER_CONFIG_SERVICE);
            PersistableBundle pb = null;
@@ -2017,5 +2020,8 @@ public abstract class SMSDispatcher extends Handler {
                        .KEY_ASCII_7_BIT_SUPPORT_FOR_LONG_MESSAGE_BOOL);
            }
            return false;
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }
}