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

Commit e025391b authored by Wink Saville's avatar Wink Saville
Browse files

Add DataConnection#isEmergency and use in trySetupData.

If an emergency is occurring we may not want to allow data calls.

An emergency is defined as in an Emergency call or in the
emergency call back mode. I've added isInEcm and isEmergencyCall
to PhoneBase and CDMAPhone. And in DataConnectionTracker added
isEmergency which is the or of isInEcm, isEmergencyCall.

Also, removed some optimization code in DataConnectionTracker
onSetInternalDataEnabled because mInternalDataEnabled defaults to true
when a DCT is constructed and without this change trySetupData will
not be called leaving ECM if the DCT was just created. Which is what
is currently happening on the ICS lead device.

Also see b/5471660 as there is similar optimizations in
onSetUserDataEnabled and onSetPolicyDataEnabled.


Bug: 5437885
Change-Id: Iba81366300fe46eaa9aa6e457d6659b42d6fe927
parent d814d4fa
Loading
Loading
Loading
Loading
+17 −11
Original line number Original line Diff line number Diff line
@@ -679,6 +679,15 @@ public abstract class DataConnectionTracker extends Handler {
        return result;
        return result;
    }
    }


    protected boolean isEmergency() {
        final boolean result;
        synchronized (mDataEnabledLock) {
            result = mPhone.isInEcm() || mPhone.isInEmergencyCall();
        }
        log("isEmergency: result=" + result);
        return result;
    }

    protected int apnTypeToId(String type) {
    protected int apnTypeToId(String type) {
        if (TextUtils.equals(type, Phone.APN_TYPE_DEFAULT)) {
        if (TextUtils.equals(type, Phone.APN_TYPE_DEFAULT)) {
            return APN_DEFAULT_ID;
            return APN_DEFAULT_ID;
@@ -998,20 +1007,17 @@ public abstract class DataConnectionTracker extends Handler {


    protected void onSetInternalDataEnabled(boolean enabled) {
    protected void onSetInternalDataEnabled(boolean enabled) {
        synchronized (mDataEnabledLock) {
        synchronized (mDataEnabledLock) {
            final boolean prevEnabled = getAnyDataEnabled();
            if (mInternalDataEnabled != enabled) {
            mInternalDataEnabled = enabled;
            mInternalDataEnabled = enabled;
                if (prevEnabled != getAnyDataEnabled()) {
            if (enabled) {
                    if (!prevEnabled) {
                log("onSetInternalDataEnabled: changed to enabled, try to setup data call");
                resetAllRetryCounts();
                resetAllRetryCounts();
                onTrySetupData(Phone.REASON_DATA_ENABLED);
                onTrySetupData(Phone.REASON_DATA_ENABLED);
            } else {
            } else {
                log("onSetInternalDataEnabled: changed to disabled, cleanUpAllConnections");
                cleanUpAllConnections(null);
                cleanUpAllConnections(null);
            }
            }
        }
        }
    }
    }
        }
    }


    public void cleanUpAllConnections(String cause) {
    public void cleanUpAllConnections(String cause) {
        Message msg = obtainMessage(EVENT_CLEAN_UP_ALL_CONNECTIONS);
        Message msg = obtainMessage(EVENT_CLEAN_UP_ALL_CONNECTIONS);
+16 −0
Original line number Original line Diff line number Diff line
@@ -832,6 +832,22 @@ public abstract class PhoneBase extends Handler implements Phone {
        mNotifier.notifyOtaspChanged(this, otaspMode);
        mNotifier.notifyOtaspChanged(this, otaspMode);
    }
    }


    /**
     * @return true if a mobile originating emergency call is active
     */
    public boolean isInEmergencyCall() {
        return false;
    }

    /**
     * @return true if we are in the emergency call back mode. This is a period where
     * the phone should be using as little power as possible and be ready to receive an
     * incoming call from the emergency operator.
     */
    public boolean isInEcm() {
        return false;
    }

    public abstract String getPhoneName();
    public abstract String getPhoneName();


    public abstract int getPhoneType();
    public abstract int getPhoneType();
+8 −0
Original line number Original line Diff line number Diff line
@@ -848,6 +848,14 @@ public class CDMAPhone extends PhoneBase {
        mUnknownConnectionRegistrants.notifyResult(this);
        mUnknownConnectionRegistrants.notifyResult(this);
    }
    }


    public boolean isInEmergencyCall() {
        return mCT.isInEmergencyCall();
    }

    public boolean isInEcm() {
        return mIsPhoneInEcmState;
    }

    void sendEmergencyCallbackModeChange(){
    void sendEmergencyCallbackModeChange(){
        //Send an Intent
        //Send an Intent
        Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
        Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
+1 −1
Original line number Original line Diff line number Diff line
@@ -248,7 +248,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
        boolean desiredPowerState = mCdmaPhone.mSST.getDesiredPowerState();
        boolean desiredPowerState = mCdmaPhone.mSST.getDesiredPowerState();


        if ((mState == State.IDLE || mState == State.SCANNING) &&
        if ((mState == State.IDLE || mState == State.SCANNING) &&
                isDataAllowed() && getAnyDataEnabled()) {
                isDataAllowed() && getAnyDataEnabled() && !isEmergency()) {
            boolean retValue = setupData(reason);
            boolean retValue = setupData(reason);
            notifyOffApnsOfAvailability(reason, retValue);
            notifyOffApnsOfAvailability(reason, retValue);
            return retValue;
            return retValue;
+1 −1
Original line number Original line Diff line number Diff line
@@ -686,7 +686,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();
        boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();


        if ((apnContext.getState() == State.IDLE || apnContext.getState() == State.SCANNING) &&
        if ((apnContext.getState() == State.IDLE || apnContext.getState() == State.SCANNING) &&
                isDataAllowed(apnContext) && getAnyDataEnabled()) {
                isDataAllowed(apnContext) && getAnyDataEnabled() && !isEmergency()) {


            if (apnContext.getState() == State.IDLE) {
            if (apnContext.getState() == State.IDLE) {
                ArrayList<ApnSetting> waitingApns = buildWaitingApns(apnContext.getApnType());
                ArrayList<ApnSetting> waitingApns = buildWaitingApns(apnContext.getApnType());