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

Commit b5929bd4 authored by Megha Patil's avatar Megha Patil
Browse files

Implementation for SMS retry based on config

- Reads the Maximum retry count and retry timer
from Carrier config
- Applies the retry count and timer values to SMS
retry on Error
Bug: b/230707485

Test: manual(received temp error for and attempt retry)

Change-Id: Ie950df4e7cef10f7ee13c93cda1fc6cc8c4ae5a9
parent b933769b
Loading
Loading
Loading
Loading
+49 −2
Original line number Diff line number Diff line
@@ -171,10 +171,11 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                        mTrackers.remove(token);
                        break;
                    case ImsSmsImplBase.SEND_STATUS_ERROR_RETRY:
                        if (tracker.mRetryCount < MAX_SEND_RETRIES) {
                        if (tracker.mRetryCount < getMaxSmsRetryCount()) {
                            tracker.mRetryCount += 1;
                            sendMessageDelayed(
                                    obtainMessage(EVENT_SEND_RETRY, tracker), SEND_RETRY_DELAY);
                                    obtainMessage(EVENT_SEND_RETRY, tracker),
                                    getSmsRetryDelayValue());
                        } else {
                            tracker.onFailed(mContext, reason, networkReasonCode);
                            mTrackers.remove(token);
@@ -405,6 +406,52 @@ public class ImsSmsDispatcher extends SMSDispatcher {
        }
    }

    @Override
    protected int getMaxSmsRetryCount() {
        int retryCount = MAX_SEND_RETRIES;
        CarrierConfigManager mConfigManager;

        mConfigManager = (CarrierConfigManager)  mContext.getSystemService(
                Context.CARRIER_CONFIG_SERVICE);

        if (mConfigManager != null) {
            PersistableBundle carrierConfig = mConfigManager.getConfigForSubId(
                    getSubId());

            if (carrierConfig != null) {
                retryCount = carrierConfig.getInt(
                        CarrierConfigManager.ImsSms.KEY_SMS_MAX_RETRY_COUNT_INT);
            }
        }

        Rlog.d(TAG, "Retry Count: " + retryCount);

        return retryCount;
    }

    @Override
    protected int getSmsRetryDelayValue() {
        int retryDelay = SEND_RETRY_DELAY;
        CarrierConfigManager mConfigManager;

        mConfigManager = (CarrierConfigManager)  mContext.getSystemService(
                Context.CARRIER_CONFIG_SERVICE);

        if (mConfigManager != null) {
            PersistableBundle carrierConfig = mConfigManager.getConfigForSubId(
                    getSubId());

            if (carrierConfig != null) {
                retryDelay = carrierConfig.getInt(
                        CarrierConfigManager.ImsSms.KEY_SMS_OVER_IMS_SEND_RETRY_DELAY_MILLIS_INT);
            }
        }

        Rlog.d(TAG, "Retry delay: " + retryDelay);

        return retryDelay;
    }

    @Override
    protected boolean shouldBlockSmsForEcbm() {
        // We should not block outgoing SMS during ECM on IMS. It only applies to outgoing CDMA
+23 −3
Original line number Diff line number Diff line
@@ -315,6 +315,26 @@ public abstract class SMSDispatcher extends Handler {
     */
    protected abstract String getFormat();

    /**
     * Gets the maximum number of times the SMS can be retried upon Failure,
     * from the {@link android.telephony.CarrierConfigManager}
     *
     * @return the default maximum number of times SMS can be sent
     */
    protected int getMaxSmsRetryCount() {
        return MAX_SEND_RETRIES;
    }

    /**
     * Gets the Time delay before next send attempt on a failed SMS,
     * from the {@link android.telephony.CarrierConfigManager}
     *
     * @return the Time in miiliseconds for delay before next send attempt on a failed SMS
     */
    protected int getSmsRetryDelayValue() {
        return SEND_RETRY_DELAY;
    }

    /**
     * Called when a status report is received. This should correspond to a previously successful
     * SEND.
@@ -1014,7 +1034,7 @@ public abstract class SMSDispatcher extends Handler {
                // This is retry after failure over IMS but voice is not available.
                // Set retry to max allowed, so no retry is sent and cause
                // SmsManager.RESULT_ERROR_GENERIC_FAILURE to be returned to app.
                tracker.mRetryCount = MAX_SEND_RETRIES;
                tracker.mRetryCount = getMaxSmsRetryCount();

                Rlog.d(TAG, "handleSendComplete: Skipping retry: "
                        + " isIms()=" + isIms()
@@ -1037,7 +1057,7 @@ public abstract class SMSDispatcher extends Handler {
                        tracker.isFromDefaultSmsApplication(mContext),
                        tracker.getInterval());
            } else if (error == SmsManager.RESULT_RIL_SMS_SEND_FAIL_RETRY
                    && tracker.mRetryCount < MAX_SEND_RETRIES) {
                    && tracker.mRetryCount < getMaxSmsRetryCount()) {
                // Retry after a delay if needed.
                // TODO: According to TS 23.040, 9.2.3.6, we should resend
                //       with the same TP-MR as the failed message, and
@@ -1049,7 +1069,7 @@ public abstract class SMSDispatcher extends Handler {
                tracker.mRetryCount++;
                int errorCode = (smsResponse != null) ? smsResponse.mErrorCode : NO_ERROR_CODE;
                Message retryMsg = obtainMessage(EVENT_SEND_RETRY, tracker);
                sendMessageDelayed(retryMsg, SEND_RETRY_DELAY);
                sendMessageDelayed(retryMsg, getSmsRetryDelayValue());
                mPhone.getSmsStats().onOutgoingSms(
                        tracker.mImsRetry > 0 /* isOverIms */,
                        SmsConstants.FORMAT_3GPP2.equals(getFormat()),