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

Commit 09e4eea1 authored by Wink Saville's avatar Wink Saville
Browse files

Cleanup DataConnectionTracker

Promote apn members from GsmDCT to DCT.
Change getState to have a apnType parameter
Move abstract methods to they are together.


Change-Id: I19bc5d07859c9398076ae32647d8c211d19817d1
parent 9eac2c07
Loading
Loading
Loading
Loading
+33 −37
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.internal.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

/**
@@ -244,9 +245,26 @@ public abstract class DataConnectionTracker extends Handler {
    protected HashMap<Integer, DataConnection> mDataConnections =
        new HashMap<Integer, DataConnection>();

    /** Convert an ApnType string to Id (TODO: Use "enumeration" instead of String for ApnType) */
    protected HashMap<String, Integer> mApnToDataConnectionId =
                                    new HashMap<String, Integer>();

    /** Phone.APN_TYPE_* ===> ApnContext */
    protected ConcurrentHashMap<String, ApnContext> mApnContexts;

    /* Currently active APN */
    protected ApnSetting mActiveApn;

    /** allApns holds all apns */
    protected ArrayList<ApnSetting> mAllApns = null;

    /** preferred apn */
    protected ApnSetting mPreferredApn = null;

    /** Is packet service restricted by network */
    protected boolean mIsPsRestricted = false;


    protected BroadcastReceiver mIntentReceiver = new BroadcastReceiver ()
    {
        @Override
@@ -340,11 +358,6 @@ public abstract class DataConnectionTracker extends Handler {
        return mActivity;
    }

    public State getState() {
        // TODO: reimplement to use apnType better yet REMOVE.
        return mState;
    }

    /**
     * @return the data connections
     */
@@ -386,16 +399,7 @@ public abstract class DataConnectionTracker extends Handler {
        return result;
    }

    private String getActiveApnType() {
        String result;
        if (mActiveApn != null) {
            result = apnIdToType(mActiveApn.id);
        } else {
            result = null;
        }
        return result;
    }

    /** TODO: See if we can remove */
    public String getActiveApnString() {
        String result = null;
        if (mActiveApn != null) {
@@ -430,10 +434,19 @@ public abstract class DataConnectionTracker extends Handler {
        }
    }


    // abstract methods
    protected abstract String getActionIntentReconnectAlarm();
    protected abstract void startNetStatPoll();
    protected abstract void stopNetStatPoll();
    protected abstract void restartRadio();
    protected abstract void log(String s);
    protected abstract void loge(String s);
    protected abstract boolean isDataAllowed();
    protected abstract boolean isApnTypeAvailable(String type);
    public    abstract State getState(String apnType);
    protected abstract void setState(State s);
    protected abstract void gotoIdleAndNotifyDataConnection(String reason);

    // abstract handler methods
    protected abstract boolean onTrySetupData(String reason);
    protected abstract void onRoamingOff();
    protected abstract void onRoamingOn();
@@ -542,16 +555,6 @@ public abstract class DataConnectionTracker extends Handler {
        return result;
    }

    protected abstract void startNetStatPoll();

    protected abstract void stopNetStatPoll();

    protected abstract void restartRadio();

    protected abstract void log(String s);

    protected abstract void loge(String s);

    protected int apnTypeToId(String type) {
        if (TextUtils.equals(type, Phone.APN_TYPE_DEFAULT)) {
            return APN_DEFAULT_ID;
@@ -598,12 +601,6 @@ public abstract class DataConnectionTracker extends Handler {
        }
    }

    protected abstract boolean isApnTypeAvailable(String type);

    protected abstract void setState(State s);

    protected abstract void gotoIdleAndNotifyDataConnection(String reason);

    protected LinkProperties getLinkProperties(String apnType) {
        int id = apnTypeToId(apnType);
        if (isApnIdEnabled(id)) {
@@ -724,14 +721,13 @@ public abstract class DataConnectionTracker extends Handler {
        return possible;
    }

    protected abstract boolean isDataAllowed();

    public boolean isApnTypeEnabled(String apnType) {
        if (apnType == null) {
            apnType = getActiveApnType();
        }
            return false;
        } else {
            return isApnIdEnabled(apnTypeToId(apnType));
        }
    }

    protected synchronized boolean isApnIdEnabled(int id) {
        if (id != APN_INVALID_ID) {
+1 −7
Original line number Diff line number Diff line
@@ -122,13 +122,7 @@ public class CDMALTEPhone extends CDMAPhone {
        } else if (mDataConnection.isApnTypeEnabled(apnType) == false) {
            ret = DataState.DISCONNECTED;
        } else {
            DataConnectionTracker.State state;
            if (isCdmaDataConnectionTracker) {
                state = mDataConnection.getState();
            } else {
                state = ((GsmDataConnectionTracker)mDataConnection).getState(apnType);
            }
            switch (state) {
            switch (mDataConnection.getState(apnType)) {
                case FAILED:
                case IDLE:
                    ret = DataState.DISCONNECTED;
+1 −1
Original line number Diff line number Diff line
@@ -633,7 +633,7 @@ public class CDMAPhone extends PhoneBase {
                mDataConnection.isApnTypeActive(apnType) == false) {
            ret = DataState.DISCONNECTED;
        } else {
            switch (mDataConnection.getState()) {
            switch (mDataConnection.getState(apnType)) {
                case FAILED:
                case IDLE:
                    ret = DataState.DISCONNECTED;
+5 −0
Original line number Diff line number Diff line
@@ -157,6 +157,11 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
        }
    }

    @Override
    public synchronized State getState(String apnType) {
        return mState;
    }

    @Override
    protected boolean isApnTypeAvailable(String type) {
        for (String s : mSupportedApnTypes) {
+1 −1
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ public class GSMPhone extends PhoneBase {
                mDataConnection.isApnTypeActive(apnType) == false) {
            ret = DataState.DISCONNECTED;
        } else { /* mSST.gprsState == ServiceState.STATE_IN_SERVICE */
            switch (mDataConnection.getState()) {
            switch (mDataConnection.getState(apnType)) {
                case FAILED:
                case IDLE:
                    ret = DataState.DISCONNECTED;
Loading