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

Commit cdcf059e authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Stop OUT_OF_SERVICE message during Emergency Call

Currently, the radio can report an OUT_OF_SERVICE (but Emergency calls
are available) status from the radio during an emergency call if that
call is made when there is no SIM card available or the SIM card is
locked. If the remote party disconnects, we mistakenly show a "Cellular
Network not Available" dialog when a call ends successfully because the
disconnect cause is mapped to OUT_OF_SERVICE. We now check to see if the
call was an emergency call before mapping to that disconnect cause.

Bug: 30657253
Change-Id: I7bf16c502c12125506ed31a56278f68ea39737ac
parent 508daf6f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -298,9 +298,10 @@ public class GsmCdmaCallTracker extends CallTracker {
            //we should have failed in !canDial() above before we get here
            throw new CallStateException("cannot dial in current state");
        }

        boolean isEmergencyCall = PhoneNumberUtils.isLocalEmergencyNumber(mPhone.getContext(),
                dialString);
        mPendingMO = new GsmCdmaConnection(mPhone, checkForTestEmergencyNumber(dialString),
                this, mForegroundCall);
                this, mForegroundCall, isEmergencyCall);
        mHangupPendingMO = false;

        if ( mPendingMO.getAddress() == null || mPendingMO.getAddress().length() == 0
@@ -411,7 +412,7 @@ public class GsmCdmaCallTracker extends CallTracker {
        }

        mPendingMO = new GsmCdmaConnection(mPhone, checkForTestEmergencyNumber(dialString),
                this, mForegroundCall);
                this, mForegroundCall, isEmergencyCall);
        mHangupPendingMO = false;

        if ( mPendingMO.getAddress() == null || mPendingMO.getAddress().length() == 0
@@ -454,12 +455,13 @@ public class GsmCdmaCallTracker extends CallTracker {
    //CDMA
    private Connection dialThreeWay(String dialString) {
        if (!mForegroundCall.isIdle()) {
            // Check data call
            // Check data call and possibly set mIsInEmergencyCall
            disableDataCallInEmergencyCall(dialString);

            // Attach the new connection to foregroundCall
            mPendingMO = new GsmCdmaConnection(mPhone,
                    checkForTestEmergencyNumber(dialString), this, mForegroundCall);
                    checkForTestEmergencyNumber(dialString), this, mForegroundCall,
                    mIsInEmergencyCall);
            // Some network need a empty flash before sending the normal one
            m3WayCallFlashDelay = mPhone.getContext().getResources()
                    .getInteger(com.android.internal.R.integer.config_cdma_3waycall_flash_delay);
+45 −36
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@ public class GsmCdmaConnection extends Connection {

    private PowerManager.WakeLock mPartialWakeLock;

    private boolean mIsEmergencyCall = false;

    // The cached delay to be used between DTMF tones fetched from carrier config.
    private int mDtmfToneDelay = 0;

@@ -116,7 +118,7 @@ public class GsmCdmaConnection extends Connection {

    //***** Constructors

    /** This is probably an MT call that we first saw in a CLCC response */
    /** This is probably an MT call that we first saw in a CLCC response or a hand over. */
    public GsmCdmaConnection (GsmCdmaPhone phone, DriverCall dc, GsmCdmaCallTracker ct, int index) {
        super(phone.getPhoneType());
        createWakeLock(phone.getContext());
@@ -126,7 +128,7 @@ public class GsmCdmaConnection extends Connection {
        mHandler = new MyHandler(mOwner.getLooper());

        mAddress = dc.number;

        mIsEmergencyCall = PhoneNumberUtils.isLocalEmergencyNumber(phone.getContext(), mAddress);
        mIsIncoming = dc.isMT;
        mCreateTime = System.currentTimeMillis();
        mCnapName = dc.name;
@@ -144,7 +146,7 @@ public class GsmCdmaConnection extends Connection {

    /** This is an MO call, created when dialing */
    public GsmCdmaConnection (GsmCdmaPhone phone, String dialString, GsmCdmaCallTracker ct,
                              GsmCdmaCall parent) {
                              GsmCdmaCall parent, boolean isEmergencyCall) {
        super(phone.getPhoneType());
        createWakeLock(phone.getContext());
        acquireWakeLock();
@@ -155,13 +157,16 @@ public class GsmCdmaConnection extends Connection {
        if (isPhoneTypeGsm()) {
            mDialString = dialString;
        } else {
            Rlog.d(LOG_TAG, "[GsmCdmaConn] GsmCdmaConnection: dialString=" + maskDialString(dialString));
            Rlog.d(LOG_TAG, "[GsmCdmaConn] GsmCdmaConnection: dialString=" +
                    maskDialString(dialString));
            dialString = formatDialString(dialString);
            Rlog.d(LOG_TAG,
                    "[GsmCdmaConn] GsmCdmaConnection:formated dialString=" + maskDialString(dialString));
                    "[GsmCdmaConn] GsmCdmaConnection:formated dialString=" +
                            maskDialString(dialString));
        }

        mAddress = PhoneNumberUtils.extractNetworkPortionAlt(dialString);
        mIsEmergencyCall = isEmergencyCall;
        mPostDialString = PhoneNumberUtils.extractPostDialPortion(dialString);

        mIndex = -1;
@@ -494,43 +499,47 @@ public class GsmCdmaConnection extends Connection {
                        AppState.APPSTATE_UNKNOWN;
                if (serviceState == ServiceState.STATE_POWER_OFF) {
                    return DisconnectCause.POWER_OFF;
                } else if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
                        || serviceState == ServiceState.STATE_EMERGENCY_ONLY ) {
                }
                if (!mIsEmergencyCall) {
                    // Only send OUT_OF_SERVICE if it is not an emergency call. We can still
                    // technically be in STATE_OUT_OF_SERVICE or STATE_EMERGENCY_ONLY during
                    // an emergency call and when it ends, we do not want to mistakenly generate
                    // an OUT_OF_SERVICE disconnect cause during normal call ending.
                    if ((serviceState == ServiceState.STATE_OUT_OF_SERVICE
                            || serviceState == ServiceState.STATE_EMERGENCY_ONLY)) {
                        return DisconnectCause.OUT_OF_SERVICE;
                } else {
                    if (isPhoneTypeGsm()) {
                    }
                    // If we are placing an emergency call and the SIM is currently PIN/PUK
                    // locked the AppState will always not be equal to APPSTATE_READY.
                    if (uiccAppState != AppState.APPSTATE_READY) {
                        if (isPhoneTypeGsm()) {
                            return DisconnectCause.ICC_ERROR;
                        } else if (causeCode == CallFailCause.ERROR_UNSPECIFIED) {
                        } else { // CDMA
                            if (phone.mCdmaSubscriptionSource ==
                                    CdmaSubscriptionSourceManager.SUBSCRIPTION_FROM_RUIM) {
                                return DisconnectCause.ICC_ERROR;
                            }
                        }
                    }
                }
                if (isPhoneTypeGsm()) {
                    if (causeCode == CallFailCause.ERROR_UNSPECIFIED) {
                        if (phone.mSST.mRestrictedState.isCsRestricted()) {
                            return DisconnectCause.CS_RESTRICTED;
                        } else if (phone.mSST.mRestrictedState.isCsEmergencyRestricted()) {
                            return DisconnectCause.CS_RESTRICTED_EMERGENCY;
                        } else if (phone.mSST.mRestrictedState.isCsNormalRestricted()) {
                            return DisconnectCause.CS_RESTRICTED_NORMAL;
                            } else {
                                return DisconnectCause.ERROR_UNSPECIFIED;
                        }
                        } else if (causeCode == CallFailCause.NORMAL_CLEARING) {
                    }
                }
                if (causeCode == CallFailCause.NORMAL_CLEARING) {
                    return DisconnectCause.NORMAL;
                        } else {
                }
                // If nothing else matches, report unknown call drop reason
                // to app, not NORMAL call end.
                return DisconnectCause.ERROR_UNSPECIFIED;
        }
                    } else {
                        if (phone.mCdmaSubscriptionSource ==
                                CdmaSubscriptionSourceManager.SUBSCRIPTION_FROM_RUIM
                                && uiccAppState != AppState.APPSTATE_READY) {
                            return DisconnectCause.ICC_ERROR;
                        } else if (causeCode==CallFailCause.NORMAL_CLEARING) {
                            return DisconnectCause.NORMAL;
                        } else {
                            return DisconnectCause.ERROR_UNSPECIFIED;
                        }
                    }
                }
        }
    }

    /*package*/ void
+16 −8
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    @Test @SmallTest
    public void testFormatDialString(){
        connection = new GsmCdmaConnection(mPhone, String.format(
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null);
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null,
                false /*isEmergencyCall*/);
       /* case 1: If PAUSE/WAIT sequence at the end, ignore them */
        String formattedDialStr = connection.formatDialString(
                String.format("+1 (700).555-41NN1234%c", PhoneNumberUtils.PAUSE));
@@ -72,7 +73,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    @Test @SmallTest
    public void testSanityGSM() {
        connection = new GsmCdmaConnection(mPhone, String.format(
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null);
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null,
                false /*isEmergencyCall*/);
        logd("Testing initial state of GsmCdmaConnection");
        assertEquals(GsmCdmaCall.State.IDLE, connection.getState());
        assertEquals(Connection.PostDialState.NOT_STARTED, connection.getPostDialState());
@@ -89,7 +91,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    public void testSanityCDMA() {
        doReturn(PhoneConstants.PHONE_TYPE_CDMA).when(mPhone).getPhoneType();
        connection = new GsmCdmaConnection(mPhone, String.format(
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null);
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null,
                false /*isEmergencyCall*/);
        logd("Testing initial state of GsmCdmaConnection");
        assertEquals(GsmCdmaCall.State.IDLE, connection.getState());
        assertEquals(Connection.PostDialState.NOT_STARTED, connection.getPostDialState());
@@ -106,7 +109,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    @Test @SmallTest
    public void testConnectionStateUpdate() {
        connection = new GsmCdmaConnection(mPhone, String.format(
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null);
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null,
                false /*isEmergencyCall*/);
        logd("Update the connection state from idle to active");
        mDC.state = DriverCall.State.ACTIVE;
        connection.update(mDC);
@@ -123,7 +127,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    public void testCDMAPostDialPause() {
        doReturn(PhoneConstants.PHONE_TYPE_CDMA).when(mPhone).getPhoneType();
        connection = new GsmCdmaConnection(mPhone, String.format(
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null);
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null,
                false /*isEmergencyCall*/);
        logd("Mock connection state from alerting to active ");
        mDC.state = DriverCall.State.ALERTING;
        connection.update(mDC);
@@ -139,7 +144,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    @Test @MediumTest
    public void testGSMPostDialPause() {
        connection = new GsmCdmaConnection(mPhone, String.format(
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null);
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null,
                false /*isEmergencyCall*/);
        logd("Mock connection state from alerting to active ");
        mDC.state = DriverCall.State.ALERTING;
        connection.update(mDC);
@@ -157,7 +163,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    public void testPostDialWait() {
        doReturn(PhoneConstants.PHONE_TYPE_CDMA).when(mPhone).getPhoneType();
        connection = new GsmCdmaConnection(mPhone,
                String.format("+1 (700).555-41NN%c1234", PhoneNumberUtils.WAIT),mCT,null);
                String.format("+1 (700).555-41NN%c1234", PhoneNumberUtils.WAIT),mCT,null,
                false /*isEmergencyCall*/);
        logd("Mock connection state transition from alerting to active ");
        mDC.state = DriverCall.State.ALERTING;
        connection.update(mDC);
@@ -173,7 +180,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    @Test @SmallTest
    public void testHangUpConnection() {
        connection = new GsmCdmaConnection(mPhone, String.format(
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null);
                "+1 (700).555-41NN%c1234", PhoneNumberUtils.PAUSE), mCT, null,
                false /*isEmergencyCall*/);
        mDC.state = DriverCall.State.ACTIVE;
        connection.update(mDC);
        logd("Hangup the connection locally");