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

Commit 57ef3b4e authored by Taesu Lee's avatar Taesu Lee Committed by android-build-merger
Browse files

Merge "Retry over IMS when CS SMS is failed" am: 06e21b56

am: c519c0fd

Change-Id: I0a2536cfc73baf64fa67ed7e53f98b2c824ce46b
parents 6d2735e5 c519c0fd
Loading
Loading
Loading
Loading
+62 −63
Original line number Diff line number Diff line
@@ -432,31 +432,30 @@ public class SmsDispatchersController extends Handler {
     */
    public void sendRetrySms(SMSDispatcher.SmsTracker tracker) {
        String oldFormat = tracker.mFormat;
        boolean retryUsingImsService = false;

        // newFormat will be based on voice technology
        String newFormat =
                (PhoneConstants.PHONE_TYPE_CDMA == mPhone.getPhoneType())
                        ? mCdmaDispatcher.getFormat() : mGsmDispatcher.getFormat();

        // was previously sent sms format match with voice tech?
        if (oldFormat.equals(newFormat)) {
            if (isCdmaFormat(newFormat)) {
                Rlog.d(TAG, "old format matched new format (cdma)");
                mCdmaDispatcher.sendSms(tracker);
                return;
            } else {
                Rlog.d(TAG, "old format matched new format (gsm)");
                mGsmDispatcher.sendSms(tracker);
                return;
            }
        if (!tracker.mUsesImsServiceForIms && mImsSmsDispatcher.isAvailable()) {
            // If this tracker has not been handled by ImsSmsDispatcher yet and IMS Service is
            // available now, retry this failed tracker using IMS Service.
            retryUsingImsService = true;
        }

        // If retryUsingImsService is true, newFormat will be IMS SMS format. Otherwise, newFormat
        // will be based on voice technology.
        String newFormat =
                retryUsingImsService
                        ? mImsSmsDispatcher.getFormat()
                        : (PhoneConstants.PHONE_TYPE_CDMA == mPhone.getPhoneType())
                                ? mCdmaDispatcher.getFormat()
                                : mGsmDispatcher.getFormat();

        Rlog.d(TAG, "old format(" + oldFormat + ") ==> new format (" + newFormat + ")");
        if (!oldFormat.equals(newFormat)) {
            // format didn't match, need to re-encode.
            HashMap map = tracker.getData();

        // to re-encode, fields needed are:  scAddr, destAddr, and
        //   text if originally sent as sendText or
        //   data and destPort if originally sent as sendData.
            // to re-encode, fields needed are: scAddr, destAddr and text if originally sent as
            // sendText or data and destPort if originally sent as sendData.
            if (!(map.containsKey("scAddr") && map.containsKey("destAddr")
                    && (map.containsKey("text")
                    || (map.containsKey("data") && map.containsKey("destPort"))))) {
@@ -475,11 +474,9 @@ public class SmsDispatchersController extends Handler {
                String text = (String) map.get("text");

                if (isCdmaFormat(newFormat)) {
                Rlog.d(TAG, "old format (gsm) ==> new format (cdma)");
                    pdu = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(
                            scAddr, destAddr, text, (tracker.mDeliveryIntent != null), null);
                } else {
                Rlog.d(TAG, "old format (cdma) ==> new format (gsm)");
                    pdu = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(
                            scAddr, destAddr, text, (tracker.mDeliveryIntent != null), null);
                }
@@ -489,12 +486,10 @@ public class SmsDispatchersController extends Handler {
                Integer destPort = (Integer) map.get("destPort");

                if (isCdmaFormat(newFormat)) {
                Rlog.d(TAG, "old format (gsm) ==> new format (cdma)");
                    pdu = com.android.internal.telephony.cdma.SmsMessage.getSubmitPdu(
                            scAddr, destAddr, destPort.intValue(), data,
                            (tracker.mDeliveryIntent != null));
                } else {
                Rlog.d(TAG, "old format (cdma) ==> new format (gsm)");
                    pdu = com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(
                            scAddr, destAddr, destPort.intValue(), data,
                            (tracker.mDeliveryIntent != null));
@@ -504,10 +499,14 @@ public class SmsDispatchersController extends Handler {
            // replace old smsc and pdu with newly encoded ones
            map.put("smsc", pdu.encodedScAddress);
            map.put("pdu", pdu.encodedMessage);
            tracker.mFormat = newFormat;
        }

        SMSDispatcher dispatcher = (isCdmaFormat(newFormat)) ? mCdmaDispatcher : mGsmDispatcher;
        SMSDispatcher dispatcher =
                retryUsingImsService
                        ? mImsSmsDispatcher
                        : (isCdmaFormat(newFormat)) ? mCdmaDispatcher : mGsmDispatcher;

        tracker.mFormat = dispatcher.getFormat();
        dispatcher.sendSms(tracker);
    }