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

Commit 0c93776e authored by ashastry's avatar ashastry Committed by Gerrit Code Review
Browse files

Merge "Permit IMS app to send single part SMS messages."

parents 3fe31f7f 532c5ffb
Loading
Loading
Loading
Loading
+17 −12
Original line number Original line Diff line number Diff line
@@ -449,8 +449,7 @@ public class IccSmsInterfaceManager {
            return;
            return;
        }
        }
        if (!persistMessageForNonDefaultSmsApp) {
        if (!persistMessageForNonDefaultSmsApp) {
            // Only allow carrier app or phone process to skip auto message persistence.
            enforcePrivilegedAppPermissions();
            enforceCarrierOrPhonePrivilege();
        }
        }
        destAddr = filterDestAddress(destAddr);
        destAddr = filterDestAddress(destAddr);
        mDispatcher.sendText(destAddr, scAddr, text, sentIntent, deliveryIntent,
        mDispatcher.sendText(destAddr, scAddr, text, sentIntent, deliveryIntent,
@@ -468,7 +467,7 @@ public class IccSmsInterfaceManager {
     *  the same time an SMS received from radio is acknowledged back.
     *  the same time an SMS received from radio is acknowledged back.
     */
     */
    public void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent) {
    public void injectSmsPdu(byte[] pdu, String format, PendingIntent receivedIntent) {
        enforceCarrierOrCarrierImsPrivilege();
        enforcePrivilegedAppPermissions();
        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
            log("pdu: " + pdu +
            log("pdu: " + pdu +
                "\n format=" + format +
                "\n format=" + format +
@@ -511,7 +510,7 @@ public class IccSmsInterfaceManager {
                "Sending SMS message");
                "Sending SMS message");
        if (!persistMessageForNonDefaultSmsApp) {
        if (!persistMessageForNonDefaultSmsApp) {
            // Only allow carrier app or carrier ims to skip auto message persistence.
            // Only allow carrier app or carrier ims to skip auto message persistence.
            enforceCarrierOrCarrierImsPrivilege();
            enforcePrivilegedAppPermissions();
        }
        }
        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
            int i = 0;
            int i = 0;
@@ -1118,8 +1117,21 @@ public class IccSmsInterfaceManager {
        }
        }
    }
    }


    private void enforceCarrierOrCarrierImsPrivilege() {
    /**
     * Enforces that the caller is one of the following:
     * <ul>
     *     <li> Phone process
     *     <li> IMS App
     *     <li> Carrier App
     * </ul>
     */
    private void enforcePrivilegedAppPermissions() {
        int callingUid = Binder.getCallingUid();
        int callingUid = Binder.getCallingUid();
        // Allow the phone process itself to send, inject messages.
        if (callingUid == Process.PHONE_UID) {
            return;
        }

        String carrierImsPackage = CarrierSmsUtils.getCarrierImsPackageForIntent(mContext, mPhone,
        String carrierImsPackage = CarrierSmsUtils.getCarrierImsPackageForIntent(mContext, mPhone,
                new Intent(CarrierMessagingService.SERVICE_INTERFACE));
                new Intent(CarrierMessagingService.SERVICE_INTERFACE));
        try {
        try {
@@ -1136,13 +1148,6 @@ public class IccSmsInterfaceManager {
        enforceCarrierPrivilege();
        enforceCarrierPrivilege();
    }
    }


    private void enforceCarrierOrPhonePrivilege() {
        int callingUid = Binder.getCallingUid();
        if (callingUid != Process.PHONE_UID) {
            enforceCarrierPrivilege();
        }
    }

    private String filterDestAddress(String destAddr) {
    private String filterDestAddress(String destAddr) {
        String result  = null;
        String result  = null;
        result = SmsNumberUtils.filterDestAddr(mPhone, destAddr);
        result = SmsNumberUtils.filterDestAddr(mPhone, destAddr);