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

Commit d5764837 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Make the internal data-disable mechanism internal

Break links to the outside world and limit its use.
A new public, persisted and separate mechanism will be coming soon.

Change-Id: Ia51a663125f7fe583e6d5d93bc2253f4e318847b
parent b6d1832f
Loading
Loading
Loading
Loading
+14 −23
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public abstract class DataConnectionTracker extends Handler {
    public static final int EVENT_CLEAN_UP_CONNECTION = 34;
    protected static final int EVENT_CDMA_OTA_PROVISION = 35;
    protected static final int EVENT_RESTART_RADIO = 36;
    protected static final int EVENT_SET_MASTER_DATA_ENABLE = 37;
    protected static final int EVENT_SET_INTERNAL_DATA_ENABLE = 37;
    protected static final int EVENT_RESET_DONE = 38;

    /***** Constants *****/
@@ -126,8 +126,9 @@ public abstract class DataConnectionTracker extends Handler {
    protected static final int DISABLED = 0;
    protected static final int ENABLED = 1;

    // responds to the setDataEnabled call - used independently from the APN requests
    protected boolean mMasterDataEnabled = true;
    // responds to the setInternalDataEnabled call - used internally to turn off data
    // for example during emergency calls
    protected boolean mInternalDataEnabled = true;

    protected boolean[] dataEnabled = new boolean[APN_NUM_TYPES];

@@ -489,9 +490,9 @@ public abstract class DataConnectionTracker extends Handler {
                onCleanUpConnection(tearDown, (String) msg.obj);
                break;

            case EVENT_SET_MASTER_DATA_ENABLE:
            case EVENT_SET_INTERNAL_DATA_ENABLE:
                boolean enabled = (msg.arg1 == ENABLED) ? true : false;
                onSetDataEnabled(enabled);
                onSetInternalDataEnabled(enabled);
                break;

            case EVENT_RESET_DONE:
@@ -504,16 +505,6 @@ public abstract class DataConnectionTracker extends Handler {
        }
    }

    /**
     * Report the current state of data connectivity (enabled or disabled)
     *
     * @return {@code false} if data connectivity has been explicitly disabled,
     *         {@code true} otherwise.
     */
    public synchronized boolean getDataEnabled() {
        return (mMasterDataEnabled && dataEnabled[APN_DEFAULT_ID]);
    }

    /**
     * Report on whether data connectivity is enabled
     *
@@ -521,7 +512,7 @@ public abstract class DataConnectionTracker extends Handler {
     *         {@code true} otherwise.
     */
    public synchronized boolean getAnyDataEnabled() {
        return (mMasterDataEnabled && (enabledCount != 0));
        return (mInternalDataEnabled && (enabledCount != 0));
    }

    protected abstract void startNetStatPoll();
@@ -676,7 +667,7 @@ public abstract class DataConnectionTracker extends Handler {
     */
    protected boolean isDataPossible() {
        boolean possible = (isDataAllowed()
                && !(getDataEnabled() && (mState == State.FAILED || mState == State.IDLE)));
                && !(getAnyDataEnabled() && (mState == State.FAILED || mState == State.IDLE)));
        if (!possible && DBG && isDataAllowed()) {
            log("Data not possible.  No coverage: dataState = " + mState);
        }
@@ -847,20 +838,20 @@ public abstract class DataConnectionTracker extends Handler {
     *            {@code false}) data
     * @return {@code true} if the operation succeeded
     */
    public boolean setDataEnabled(boolean enable) {
    public boolean setInternalDataEnabled(boolean enable) {
        if (DBG)
            log("setDataEnabled(" + enable + ")");
            log("setInternalDataEnabled(" + enable + ")");

        Message msg = obtainMessage(EVENT_SET_MASTER_DATA_ENABLE);
        Message msg = obtainMessage(EVENT_SET_INTERNAL_DATA_ENABLE);
        msg.arg1 = (enable ? ENABLED : DISABLED);
        sendMessage(msg);
        return true;
    }

    protected void onSetDataEnabled(boolean enable) {
        if (mMasterDataEnabled != enable) {
    protected void onSetInternalDataEnabled(boolean enable) {
        if (mInternalDataEnabled != enable) {
            synchronized (this) {
                mMasterDataEnabled = enable;
                mInternalDataEnabled = enable;
            }
            if (enable) {
                mRetryMgr.resetRetryCount();
+0 −30
Original line number Diff line number Diff line
@@ -1324,36 +1324,6 @@ public interface Phone {
     */
    SimulatedRadioControl getSimulatedRadioControl();

    /**
     * Allow mobile data connections.
     * @return {@code true} if the operation started successfully
     * <br/>{@code false} if it
     * failed immediately.<br/>
     * Even in the {@code true} case, it may still fail later
     * during setup, in which case an asynchronous indication will
     * be supplied.
     */
    boolean enableDataConnectivity();

    /**
     * Disallow mobile data connections, and terminate any that
     * are in progress.
     * @return {@code true} if the operation started successfully
     * <br/>{@code false} if it
     * failed immediately.<br/>
     * Even in the {@code true} case, it may still fail later
     * during setup, in which case an asynchronous indication will
     * be supplied.
     */
    boolean disableDataConnectivity();

    /**
     * Report the current state of data connectivity (enabled or disabled)
     * @return {@code false} if data connectivity has been explicitly disabled,
     * {@code true} otherwise.
     */
    boolean isDataConnectivityEnabled();

    /**
     * Enables the specified APN type. Only works for "special" APN types,
     * i.e., not the default APN.
+0 −4
Original line number Diff line number Diff line
@@ -941,10 +941,6 @@ public abstract class PhoneBase extends Handler implements Phone {
         logUnexpectedCdmaMethodCall("unsetOnEcbModeExitResponse");
     }

    public boolean isDataConnectivityEnabled() {
        return mDataConnection.getDataEnabled();
    }

    public String[] getActiveApnTypes() {
        return mDataConnection.getActiveApnTypes();
    }
+0 −12
Original line number Diff line number Diff line
@@ -650,14 +650,6 @@ public class PhoneProxy extends Handler implements Phone {
        return mActivePhone.getSimulatedRadioControl();
    }

    public boolean enableDataConnectivity() {
        return mActivePhone.enableDataConnectivity();
    }

    public boolean disableDataConnectivity() {
        return mActivePhone.disableDataConnectivity();
    }

    public int enableApnType(String type) {
        return mActivePhone.enableApnType(type);
    }
@@ -666,10 +658,6 @@ public class PhoneProxy extends Handler implements Phone {
        return mActivePhone.disableApnType(type);
    }

    public boolean isDataConnectivityEnabled() {
        return mActivePhone.isDataConnectivityEnabled();
    }

    public boolean isDataConnectivityPossible() {
        return mActivePhone.isDataConnectivityPossible();
    }
+1 −20
Original line number Diff line number Diff line
@@ -478,10 +478,6 @@ public class CDMAPhone extends PhoneBase {
        return mSST.cellLoc;
    }

    public boolean disableDataConnectivity() {
        return mDataConnection.setDataEnabled(false);
    }

    public CdmaCall getForegroundCall() {
        return mCT.foregroundCall;
    }
@@ -761,21 +757,6 @@ public class CDMAPhone extends PhoneBase {
        return ret;
    }

    public boolean enableDataConnectivity() {

        // block data activities when phone is in emergency callback mode
        if (mIsPhoneInEcmState) {
            Intent intent = new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS);
            ActivityManagerNative.broadcastStickyIntent(intent, null);
            return false;
        } else if ((mCT.state == Phone.State.OFFHOOK) && mCT.isInEmergencyCall()) {
            // Do not allow data call to be enabled when emergency call is going on
            return false;
        } else {
            return mDataConnection.setDataEnabled(true);
        }
    }

    public boolean getIccRecordsLoaded() {
        return mRuimRecords.getRecordsLoaded();
    }
@@ -921,7 +902,7 @@ public class CDMAPhone extends PhoneBase {
            // send an Intent
            sendEmergencyCallbackModeChange();
            // Re-initiate data connection
            mDataConnection.setDataEnabled(true);
            mDataConnection.setInternalDataEnabled(true);
        }
    }

Loading