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

Commit 37414e6f authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Fix emergency call failure over IMS after boot

With some recent changes to the ImsPhone, we now never go into
the STATE_POWER_OFF state. This was how the GsmCdmaPhone used
to verify that the ImsPhone was not ready to make calls, so
it was not falling back to CS in this small space of time
before the ImsService came up and instead failing to make the call.

This change fixes this issue in two ways:
1) Instead of looking for the STATE_POWER_OFF state, it will instead
check to see if the ImsService is up.
2) If the emergency call fails over IMS, then fallback to CS
automatically.

Bug: 62618800
Test: Place emergency call right after boot up
Change-Id: Ia290681983e995568d01e84fa81d38d4b986d9b0
parent 474e64b2
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1066,7 +1066,7 @@ public class GsmCdmaPhone extends Phone {
                && isEmergency
                && alwaysTryImsForEmergencyCarrierConfig
                && ImsManager.isNonTtyOrTtyOnVolteEnabled(mContext)
                && (imsPhone.getServiceState().getState() != ServiceState.STATE_POWER_OFF);
                && imsPhone.isImsAvailable();

        String dialPart = PhoneNumberUtils.extractNetworkPortionAlt(PhoneNumberUtils.
                stripSeparators(dialString));
@@ -1100,7 +1100,12 @@ public class GsmCdmaPhone extends Phone {
            } catch (CallStateException e) {
                if (DBG) logd("IMS PS call exception " + e +
                        "imsUseEnabled =" + imsUseEnabled + ", imsPhone =" + imsPhone);
                if (!Phone.CS_FALLBACK.equals(e.getMessage())) {
                // Do not throw a CallStateException and instead fall back to Circuit switch
                // for emergency calls and MMI codes.
                if (Phone.CS_FALLBACK.equals(e.getMessage()) || isEmergency) {
                    logi("IMS call failed with Exception: " + e.getMessage() + ". Falling back "
                            + "to CS.");
                } else {
                    CallStateException ce = new CallStateException(e.getMessage());
                    ce.setStackTrace(e.getStackTrace());
                    throw ce;
@@ -3425,6 +3430,10 @@ public class GsmCdmaPhone extends Phone {
        Rlog.d(LOG_TAG, "[GsmCdmaPhone] " + s);
    }

    private void logi(String s) {
        Rlog.i(LOG_TAG, "[GsmCdmaPhone] " + s);
    }

    private void loge(String s) {
        Rlog.e(LOG_TAG, "[GsmCdmaPhone] " + s);
    }
+12 −0
Original line number Diff line number Diff line
@@ -3308,6 +3308,18 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return imsUseEnabled;
    }

    /**
     * Determines if the connection to IMS services are available yet.
     * @return {@code true} if the connection to IMS services are available.
     */
    public boolean isImsAvailable() {
        if (mImsPhone == null) {
            return false;
        }

        return mImsPhone.isImsAvailable();
    }

    /**
     * Determines if video calling is enabled for the phone.
     *
+5 −0
Original line number Diff line number Diff line
@@ -343,6 +343,11 @@ public class ImsPhone extends ImsPhoneBase {
        return mCT.mRingingCall;
    }

    @Override
    public boolean isImsAvailable() {
        return mCT.isImsServiceReady();
    }

    private boolean handleCallDeflectionIncallSupplementaryService(
            String dialString) {
        if (dialString.length() > 1) {
+8 −0
Original line number Diff line number Diff line
@@ -902,6 +902,14 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        return mPendingMO;
    }

    boolean isImsServiceReady() {
        if (mImsManager == null) {
            return false;
        }

        return mImsManager.isServiceAvailable();
    }

    /**
     * Caches frequently used carrier configuration items locally.
     *