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

Commit 834e3e15 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Send SMS over 1x when on eHRPD and active voice call"

parents a2392cfd a701561a
Loading
Loading
Loading
Loading
+60 −2
Original line number Diff line number Diff line
@@ -29,7 +29,9 @@ import android.os.AsyncResult;
import android.os.Message;
import android.provider.Telephony.Sms.Intents;
import android.telephony.Rlog;
import android.telephony.TelephonyManager;

import com.android.internal.R;
import com.android.internal.telephony.cdma.CdmaSMSDispatcher;
import com.android.internal.telephony.gsm.GsmSMSDispatcher;
import com.android.internal.telephony.InboundSmsHandler;
@@ -50,6 +52,13 @@ public class ImsSMSDispatcher extends SMSDispatcher {
    private boolean mIms = false;
    private String mImsSmsFormat = SmsConstants.FORMAT_UNKNOWN;

    /**
     * true if MO SMS over IMS is enabled. Default value is true. false for
     * carriers with config_send_sms1x_on_voice_call = true when attached to
     * eHRPD and during active 1x voice call
     */
    private boolean mImsSmsEnabled = true;

    public ImsSMSDispatcher(PhoneBase phone, SmsStorageMonitor storageMonitor,
            SmsUsageMonitor usageMonitor) {
        super(phone, usageMonitor, null);
@@ -349,8 +358,9 @@ public class ImsSMSDispatcher extends SMSDispatcher {
     * @return true if Cdma format should be used for MO SMS, false otherwise.
     */
    private boolean isCdmaMo() {
        if (!isIms()) {
            // IMS is not registered, use Voice technology to determine SMS format.
        if (!isIms() || !shouldSendSmsOverIms()) {
            // Either IMS is not registered or there is an active 1x voice call
            // while on eHRPD, use Voice technology to determine SMS format.
            return (PhoneConstants.PHONE_TYPE_CDMA == mPhone.getPhoneType());
        }
        // IMS is registered with SMS support
@@ -366,4 +376,52 @@ public class ImsSMSDispatcher extends SMSDispatcher {
    private boolean isCdmaFormat(String format) {
        return (mCdmaDispatcher.getFormat().equals(format));
    }

    /**
     * Enables MO SMS over IMS
     *
     * @param enable
     */
    public void enableSendSmsOverIms(boolean enable) {
        mImsSmsEnabled = enable;
    }

    /**
     * Determines whether MO SMS over IMS is currently enabled.
     *
     * @return true if MO SMS over IMS is enabled, false otherwise.
     */
    public boolean isImsSmsEnabled() {
        return mImsSmsEnabled;
    }

    /**
     * Determines whether SMS should be sent over IMS if UE is attached to eHRPD
     * and there is an active voice call
     *
     * @return true if SMS should be sent over IMS based on value in config.xml
     *         or system property false otherwise
     */
    public boolean shouldSendSmsOverIms() {
        boolean sendSmsOn1x = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_send_sms1x_on_voice_call);
        int currentCallState = mTelephonyManager.getCallState();
        int currentVoiceNetwork = mTelephonyManager.getVoiceNetworkType();
        int currentDataNetwork = mTelephonyManager.getDataNetworkType();

        Rlog.d(TAG, "data = " + currentDataNetwork + " voice = " + currentVoiceNetwork
                + " call state = " + currentCallState);

        if (sendSmsOn1x) {
            // The UE shall use 1xRTT for SMS if the UE is attached to an eHRPD
            // network and there is an active 1xRTT voice call.
            if (currentDataNetwork == TelephonyManager.NETWORK_TYPE_EHRPD
                    && currentVoiceNetwork == TelephonyManager.NETWORK_TYPE_1xRTT
                    && currentCallState != mTelephonyManager.CALL_STATE_IDLE) {
                enableSendSmsOverIms(false);
                return false;
            }
        }
        return true;
    }
}
+14 −4
Original line number Diff line number Diff line
@@ -209,7 +209,17 @@ public class CdmaSMSDispatcher extends SMSDispatcher {
        // indicated by mImsRetry > 0
        if (0 == tracker.mImsRetry && !isIms()) {
            mCi.sendCdmaSms(pdu, reply);
        } else {
        }
        // If sending SMS over IMS is not enabled, send SMS over cdma. Simply
        // calling shouldSendSmsOverIms() to check for that here might yield a
        // different result if the conditions of UE being attached to eHRPD and
        // active 1x voice call have changed since we last called it in
        // ImsSMSDispatcher.isCdmaMo()
        else if (!mImsSMSDispatcher.isImsSmsEnabled()) {
            mCi.sendCdmaSms(pdu, reply);
            mImsSMSDispatcher.enableSendSmsOverIms(true);
        }
        else {
            mCi.sendImsCdmaSms(pdu, tracker.mImsRetry, tracker.mMessageRef, reply);
            // increment it here, so in case of SMS_FAIL_RETRY over IMS
            // next retry will be sent using IMS request again.