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

Commit 86f275d9 authored by Jayachandran C's avatar Jayachandran C
Browse files

Check for service state before dialing normal voice call in the CS pipe

1) Rename CallStateException ERROR_DISCONNECTED to ERROR_OUT_OF_SERVICE

2) Do not dial in the CS pipe if CS is out of service and PS is not in LTE.
TelephonyConnectionService#getTelephonyConnection() doesn't filter in
some cases (ex. CS is out of service and IMS registered for SMS only) so
added this check to filter dialing the normal voice call to modem.

3) If dial is not allowed then throw CallStateException ERROR_OUT_OF_SERVICE
which will trigger notifying user to enable VoWiFi if WFC is disabled,
WFC provisioned and connected to WiFi.

4) Optimized imports

Test: Dial voice and video calls for all the combinations of the following
 - CS  : No service, 1x, GSM, UMTS, LTE
 - PS  : No service, 1x, eHRPD, GSM, UMTS, LTE
 - IMS : No service, SMS only, SMS&VT only, VoLTE
 - WiFi: Connected, Disconnected
 - WFC : Enabled, Disabled

Bug: 37405103
Change-Id: I0fb91e06aac99b1c4cf163c7b5858a694b40c91c
parent 9ac5b784
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -26,7 +26,7 @@ public class CallStateException extends Exception
    /** The error code is not valid (Not received a disconnect cause) */
    /** The error code is not valid (Not received a disconnect cause) */
    public static final int ERROR_INVALID = -1;
    public static final int ERROR_INVALID = -1;


    public static final int ERROR_DISCONNECTED = 1;
    public static final int ERROR_OUT_OF_SERVICE = 1;
    public static final int ERROR_POWER_OFF = 2;
    public static final int ERROR_POWER_OFF = 2;


    public
    public
+12 −1
Original line number Original line Diff line number Diff line
@@ -62,7 +62,6 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.telephony.UssdResponse;
import android.telephony.UssdResponse;

import android.telephony.cdma.CdmaCellLocation;
import android.telephony.cdma.CdmaCellLocation;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;
@@ -1129,6 +1128,18 @@ public class GsmCdmaPhone extends Phone {
                CallStateException.ERROR_POWER_OFF,
                CallStateException.ERROR_POWER_OFF,
                "cannot dial voice call in airplane mode");
                "cannot dial voice call in airplane mode");
        }
        }
        // Check for service before placing non emergency CS voice call.
        // Allow dial only if either CS is camped on any RAT (or) PS is in LTE service.
        if (mSST != null
                && mSST.mSS.getState() == ServiceState.STATE_OUT_OF_SERVICE /* CS out of service */
                && !(mSST.mSS.getDataRegState() == ServiceState.STATE_IN_SERVICE
                    && ServiceState.isLte(mSST.mSS.getRilDataRadioTechnology())) /* PS not in LTE */
                && !VideoProfile.isVideo(videoState) /* voice call */
                && !isEmergency /* non-emergency call */) {
            throw new CallStateException(
                CallStateException.ERROR_OUT_OF_SERVICE,
                "cannot dial voice call in out of service");
        }
        if (DBG) logd("Trying (non-IMS) CS call");
        if (DBG) logd("Trying (non-IMS) CS call");


        if (isPhoneTypeGsm()) {
        if (isPhoneTypeGsm()) {
+1 −2
Original line number Original line Diff line number Diff line
@@ -59,7 +59,6 @@ import com.android.ims.ImsManager;
import com.android.internal.R;
import com.android.internal.R;
import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.dataconnection.DcTracker;
import com.android.internal.telephony.imsphone.ImsPhoneCall;
import com.android.internal.telephony.imsphone.ImsPhoneCall;
import com.android.internal.telephony.ims.ImsResolver;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccFileHandler;
import com.android.internal.telephony.uicc.IccFileHandler;
@@ -3384,7 +3383,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
                            ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY));
                            ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY));
            if (wfcWiFiOnly) {
            if (wfcWiFiOnly) {
                throw new CallStateException(
                throw new CallStateException(
                        CallStateException.ERROR_DISCONNECTED,
                        CallStateException.ERROR_OUT_OF_SERVICE,
                        "WFC Wi-Fi Only Mode: IMS not registered");
                        "WFC Wi-Fi Only Mode: IMS not registered");
            }
            }
        }
        }
+5 −3
Original line number Original line Diff line number Diff line
@@ -15,10 +15,12 @@
 */
 */
package com.android.internal.telephony;
package com.android.internal.telephony;


import static org.junit.Assert.assertEquals;

import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.SmallTest;

import org.junit.After;
import org.junit.After;
import org.junit.Test;
import org.junit.Test;
import static org.junit.Assert.assertEquals;


public class CallStateExceptionTest {
public class CallStateExceptionTest {
    private CallStateException mCallStateException;
    private CallStateException mCallStateException;
@@ -39,9 +41,9 @@ public class CallStateExceptionTest {
    @Test
    @Test
    @SmallTest
    @SmallTest
    public void testCallStateExceptionWithErrCode() {
    public void testCallStateExceptionWithErrCode() {
        mCallStateException = new CallStateException(mCallStateException.ERROR_DISCONNECTED,
        mCallStateException = new CallStateException(mCallStateException.ERROR_OUT_OF_SERVICE,
                                                     "sanity test with err code");
                                                     "sanity test with err code");
        assertEquals("sanity test with err code", mCallStateException.getMessage());
        assertEquals("sanity test with err code", mCallStateException.getMessage());
        assertEquals(mCallStateException.ERROR_DISCONNECTED, mCallStateException.getError());
        assertEquals(mCallStateException.ERROR_OUT_OF_SERVICE, mCallStateException.getError());
    }
    }
}
}