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

Commit 6c9aa656 authored by arcwang's avatar arcwang Committed by Arc Wang
Browse files

Send sentIntent back to APP when a MO SMS can't be sent to network.

Some MO SMS abnormal stop sending cases do not send sentIntent back to APP,
users may be confused about the MO SMS status.

This change send sentIntent back to APP for abnormal stop sending cases of:

    1. permision problem
    2. subscription problem
    3. multipart text SMS encoding problem

Bug: 112975296
Test: make
Change-Id: I96fc5129d03072c04f45f43b3b5514d562e13c54
parent e3556760
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -338,6 +338,7 @@ public class IccSmsInterfaceManager {
    public void sendDataWithSelfPermissions(String callingPackage, String destAddr, String scAddr,
            int destPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) {
        if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            return;
        }
        sendDataInternal(destAddr, scAddr, destPort, data, sentIntent, deliveryIntent);
@@ -350,6 +351,7 @@ public class IccSmsInterfaceManager {
    public void sendData(String callingPackage, String destAddr, String scAddr, int destPort,
            byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) {
        if (!checkCallingSendSmsPermission(callingPackage, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            return;
        }
        sendDataInternal(destAddr, scAddr, destPort, data, sentIntent, deliveryIntent);
@@ -402,6 +404,7 @@ public class IccSmsInterfaceManager {
            boolean persistMessageForNonDefaultSmsApp) {
        if (!checkCallingSendTextPermissions(
                persistMessageForNonDefaultSmsApp, callingPackage, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            return;
        }
        sendTextInternal(callingPackage, destAddr, scAddr, text, sentIntent, deliveryIntent,
@@ -417,6 +420,7 @@ public class IccSmsInterfaceManager {
            String text, PendingIntent sentIntent, PendingIntent deliveryIntent,
            boolean persistMessage) {
        if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            return;
        }
        sendTextInternal(callingPackage, destAddr, scAddr, text, sentIntent, deliveryIntent,
@@ -538,6 +542,7 @@ public class IccSmsInterfaceManager {
            boolean persistMessageForNonDefaultSmsApp, int priority, boolean expectMore,
            int validityPeriod) {
        if (!checkCallingOrSelfSendSmsPermission(callingPackage, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            return;
        }
        sendTextInternal(callingPackage, destAddr, scAddr, text, sentIntent, deliveryIntent,
@@ -666,6 +671,7 @@ public class IccSmsInterfaceManager {
            int priority, boolean expectMore, int validityPeriod) {
        if (!checkCallingSendTextPermissions(
                persistMessageForNonDefaultSmsApp, callingPackage, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntents);
            return;
        }
        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
@@ -1100,6 +1106,7 @@ public class IccSmsInterfaceManager {
    public void sendStoredText(String callingPkg, Uri messageUri, String scAddress,
            PendingIntent sentIntent, PendingIntent deliveryIntent) {
        if (!checkCallingSendSmsPermission(callingPkg, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntent);
            return;
        }
        if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
@@ -1128,6 +1135,7 @@ public class IccSmsInterfaceManager {
    public void sendStoredMultipartText(String callingPkg, Uri messageUri, String scAddress,
            List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) {
        if (!checkCallingSendSmsPermission(callingPkg, "Sending SMS message")) {
            returnUnspecifiedFailure(sentIntents);
            return;
        }
        final ContentResolver resolver = mContext.getContentResolver();
+11 −0
Original line number Diff line number Diff line
@@ -877,6 +877,16 @@ public abstract class SMSDispatcher extends Handler {
        }
    }

    private void triggerSentIntentForFailure(List<PendingIntent> sentIntents) {
        if (sentIntents == null) {
            return;
        }

        for (PendingIntent sentIntent : sentIntents) {
            triggerSentIntentForFailure(sentIntent);
        }
    }

    private boolean sendSmsByCarrierApp(boolean isDataSms, SmsTracker tracker ) {
        String carrierPackage = getCarrierAppPackageName();
        if (carrierPackage != null) {
@@ -1025,6 +1035,7 @@ public abstract class SMSDispatcher extends Handler {
        if (parts == null || trackers == null || trackers.length == 0
                || trackers[0] == null) {
            Rlog.e(TAG, "Cannot send multipart text. parts=" + parts + " trackers=" + trackers);
            triggerSentIntentForFailure(sentIntents);
            return;
        }

+12 −4
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ public class UiccSmsController extends ISmsImplBase {
        } else {
            Rlog.e(LOG_TAG,"sendText iccSmsIntMgr is null for" +
                          " Subscription: " + subId);
            sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE);
        }
    }

@@ -152,21 +153,23 @@ public class UiccSmsController extends ISmsImplBase {
        } else {
            Rlog.e(LOG_TAG,"sendText iccSmsIntMgr is null for" +
                          " Subscription: " + subId);
            sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE);
        }
    }

    @Override
    public void sendTextForSubscriberWithOptions(int subId, String callingPackage,
            String destAddr, String scAddr, String parts, PendingIntent sentIntents,
            PendingIntent deliveryIntents, boolean persistMessage, int priority,
            String destAddr, String scAddr, String parts, PendingIntent sentIntent,
            PendingIntent deliveryIntent, boolean persistMessage, int priority,
            boolean expectMore, int validityPeriod) {
        IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
        if (iccSmsIntMgr != null ) {
            iccSmsIntMgr.sendTextWithOptions(callingPackage, destAddr, scAddr, parts, sentIntents,
                    deliveryIntents, persistMessage,  priority, expectMore, validityPeriod);
            iccSmsIntMgr.sendTextWithOptions(callingPackage, destAddr, scAddr, parts, sentIntent,
                    deliveryIntent, persistMessage,  priority, expectMore, validityPeriod);
        } else {
            Rlog.e(LOG_TAG,"sendTextWithOptions iccSmsIntMgr is null for" +
                          " Subscription: " + subId);
            sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE);
        }
    }

@@ -198,6 +201,7 @@ public class UiccSmsController extends ISmsImplBase {
        } else {
            Rlog.e(LOG_TAG,"sendMultipartTextWithOptions iccSmsIntMgr is null for" +
                          " Subscription: " + subId);
            sendErrorInPendingIntents(sentIntents, SmsManager.RESULT_ERROR_GENERIC_FAILURE);
        }
    }

@@ -431,6 +435,10 @@ public class UiccSmsController extends ISmsImplBase {
    }

    private void sendErrorInPendingIntents(List<PendingIntent> intents, int errorCode) {
        if (intents == null) {
            return;
        }

        for (PendingIntent intent : intents) {
            sendErrorInPendingIntent(intent, errorCode);
        }