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

Commit 4345e235 authored by Megha Patil's avatar Megha Patil
Browse files

Handle the result of sending RP-SMMA in framework

- Receive the callback Api onMemoryAvailbleResult in
framework
- Bug: b/240883268

Test: atest ImsSmsDispatcherTest, Tested Memory full and Not Full conditions in Pixel
Change-Id: Ib1cffd39cdd51a6c8dd1dea6cf62d13d26af999c
parent 2367fb16
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -44,7 +44,9 @@ import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.util.SMSDispatcherUtil;
import com.android.telephony.Rlog;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
@@ -74,6 +76,7 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                FeatureConnector.Listener<ImsManager> listener, Executor executor);
    }

    public List<Integer> mMemoryAvailableNotifierList = new ArrayList<Integer>();
    @VisibleForTesting
    public Map<Integer, SmsTracker> mTrackers = new ConcurrentHashMap<>();
    @VisibleForTesting
@@ -141,6 +144,37 @@ public class ImsSmsDispatcher extends SMSDispatcher {
    };

    private final IImsSmsListener mImsSmsListener = new IImsSmsListener.Stub() {
        @Override
        public void onMemoryAvailableResult(int token, @SendStatusResult int status,
                int networkReasonCode) {
            final long identity = Binder.clearCallingIdentity();
            try {
                logd("onMemoryAvailableResult token=" + token + " status=" + status
                        + " networkReasonCode=" + networkReasonCode);
                if (!mMemoryAvailableNotifierList.contains(token)) {
                    loge("onMemoryAvailableResult Invalid token");
                    return;
                }
                mMemoryAvailableNotifierList.remove(Integer.valueOf(token));

                /**
                 * The Retrans flag is set and reset As per section 6.3.3.1.2 in TS 124011
                 * Note: Assuming that SEND_STATUS_ERROR_RETRY is sent in case of temporary failure
                 */
                if (status ==  ImsSmsImplBase.SEND_STATUS_ERROR_RETRY) {
                    if (!mRPSmmaRetried) {
                        sendMessageDelayed(obtainMessage(EVENT_RETRY_SMMA), SEND_RETRY_DELAY);
                        mRPSmmaRetried = true;
                    } else {
                        mRPSmmaRetried = false;
                    }
                } else {
                    mRPSmmaRetried = false;
                }
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
        }
        @Override
        public void onSendSmsResult(int token, int messageRef, @SendStatusResult int status,
                @SmsManager.Result int reason, int networkReasonCode) {
@@ -293,6 +327,10 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                logd("SMS retry..");
                sendSms((SmsTracker) msg.obj);
                break;
            case EVENT_RETRY_SMMA:
                logd("SMMA Notification retry..");
                onMemoryAvailable();
                break;
            default:
                super.handleMessage(msg);
        }
@@ -540,9 +578,13 @@ public class ImsSmsDispatcher extends SMSDispatcher {
        int token = mNextToken.incrementAndGet();
        try {
            logd("onMemoryAvailable: token = " + token);
            mMemoryAvailableNotifierList.add(token);
            getImsManager().onMemoryAvailable(token);
        } catch (ImsException e) {
            loge("onMemoryAvailable failed: " + e.getMessage());
            if (mMemoryAvailableNotifierList.contains(token)) {
                mMemoryAvailableNotifierList.remove(Integer.valueOf(token));
            }
        }
    }

+10 −0
Original line number Diff line number Diff line
@@ -149,6 +149,8 @@ public abstract class SMSDispatcher extends Handler {
    /** New status report received. */
    protected static final int EVENT_NEW_SMS_STATUS_REPORT = 10;

    /** Retry Sending RP-SMMA Notification */
    protected static final int EVENT_RETRY_SMMA = 11;
    // other
    protected static final int EVENT_NEW_ICC_SMS = 14;
    protected static final int EVENT_ICC_CHANGED = 15;
@@ -186,6 +188,14 @@ public abstract class SMSDispatcher extends Handler {

    /** Maximum number of times to retry sending a failed SMS. */
    protected static final int MAX_SEND_RETRIES = 3;

    /** Retransmitted Flag as specified in section 6.3.1.2 in TS 124011
     * true:  RP-SMMA Retried once and no more transmissions are permitted
     * false: not retried at all and at least another transmission of the RP-SMMA message
     * is currently permitted
     */
    protected boolean mRPSmmaRetried = false;

    /** Delay before next send attempt on a failed SMS, in milliseconds. */
    @VisibleForTesting
    public static final int SEND_RETRY_DELAY = 2000;