FileDocCategorySizeDatePackage
ApnContext.javaAPI DocAndroid 5.1 API9227Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.dataconnection

ApnContext

public class ApnContext extends Object
Maintain the Apn context

Fields Summary
public final String
LOG_TAG
protected static final boolean
DBG
private final android.content.Context
mContext
private final String
mApnType
private DctConstants.State
mState
private ArrayList
mWaitingApns
private ArrayList
mOriginalWaitingApns
Used to check if conditions (new RAT) are resulting in a new list which warrants a retry. Set in the last trySetupData call.
public final int
priority
private AtomicInteger
mWaitingApnsPermanentFailureCountDown
A zero indicates that all waiting APNs had a permanent error
private ApnSetting
mApnSetting
DcAsyncChannel
mDcAc
String
mReason
android.app.PendingIntent
mReconnectAlarmIntent
AtomicBoolean
mDataEnabled
user/app requested connection on this APN
private final Object
mRefCountLock
private int
mRefCount
AtomicBoolean
mDependencyMet
carrier requirements met
private final DcTrackerBase
mDcTracker
private boolean
mConcurrentVoiceAndDataAllowed
Remember this as a change in this value to a more permissive state should cause us to retry even permanent failures
Constructors Summary
public ApnContext(android.content.Context context, String apnType, String logTag, android.net.NetworkConfig config, DcTrackerBase tracker)


            
              
        mContext = context;
        mApnType = apnType;
        mState = DctConstants.State.IDLE;
        setReason(Phone.REASON_DATA_ENABLED);
        mDataEnabled = new AtomicBoolean(false);
        mDependencyMet = new AtomicBoolean(config.dependencyMet);
        mWaitingApnsPermanentFailureCountDown = new AtomicInteger(0);
        priority = config.priority;
        LOG_TAG = logTag;
        mDcTracker = tracker;
    
Methods Summary
public voiddecRefCount()

        synchronized (mRefCountLock) {
            if (mRefCount-- == 1) {
                mDcTracker.setEnabled(mDcTracker.apnTypeToId(mApnType), false);
            }
        }
    
public voiddecWaitingApnsPermFailCount()

        mWaitingApnsPermanentFailureCountDown.decrementAndGet();
    
public voiddump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)

        pw.println("ApnContext: " + this.toString());
    
public synchronized ApnSettinggetApnSetting()

        log("getApnSetting: apnSetting=" + mApnSetting);
        return mApnSetting;
    
public java.lang.StringgetApnType()

        return mApnType;
    
public synchronized DcAsyncChannelgetDcAc()

        return mDcAc;
    
public booleangetDependencyMet()

       return mDependencyMet.get();
    
public synchronized ApnSettinggetNextWaitingApn()

        ArrayList<ApnSetting> list = mWaitingApns;
        ApnSetting apn = null;

        if (list != null) {
            if (!list.isEmpty()) {
                apn = list.get(0);
            }
        }
        return apn;
    
public synchronized java.util.ArrayListgetOriginalWaitingApns()

        return mOriginalWaitingApns;
    
public synchronized java.lang.StringgetReason()

        return mReason;
    
public synchronized android.app.PendingIntentgetReconnectIntent()

        return mReconnectAlarmIntent;
    
public synchronized DctConstants.StategetState()

        return mState;
    
public synchronized java.util.ArrayListgetWaitingApns()

        return mWaitingApns;
    
public intgetWaitingApnsPermFailCount()

        return mWaitingApnsPermanentFailureCountDown.get();
    
public voidincRefCount()

        synchronized (mRefCountLock) {
            if (mRefCount++ == 0) {
                mDcTracker.setEnabled(mDcTracker.apnTypeToId(mApnType), true);
            }
        }
    
public synchronized booleanisConcurrentVoiceAndDataAllowed()

        return mConcurrentVoiceAndDataAllowed;
    
public booleanisConnectable()

        return isReady() && ((mState == DctConstants.State.IDLE)
                                || (mState == DctConstants.State.SCANNING)
                                || (mState == DctConstants.State.RETRYING)
                                || (mState == DctConstants.State.FAILED));
    
public booleanisConnectedOrConnecting()

        return isReady() && ((mState == DctConstants.State.CONNECTED)
                                || (mState == DctConstants.State.CONNECTING)
                                || (mState == DctConstants.State.SCANNING)
                                || (mState == DctConstants.State.RETRYING));
    
public booleanisDisconnected()

        DctConstants.State currentState = getState();
        return ((currentState == DctConstants.State.IDLE) ||
                    currentState == DctConstants.State.FAILED);
    
public booleanisEnabled()

        return mDataEnabled.get();
    
public booleanisProvisioningApn()

        String provisioningApn = mContext.getResources()
                .getString(R.string.mobile_provisioning_apn);
        if ((mApnSetting != null) && (mApnSetting.apn != null)) {
            return (mApnSetting.apn.equals(provisioningApn));
        } else {
            return false;
        }
    
public booleanisReady()

        return mDataEnabled.get() && mDependencyMet.get();
    
protected voidlog(java.lang.String s)

        Rlog.d(LOG_TAG, "[ApnContext:" + mApnType + "] " + s);
    
public synchronized voidremoveWaitingApn(ApnSetting apn)

        if (mWaitingApns != null) {
            mWaitingApns.remove(apn);
        }
    
public synchronized voidsetApnSetting(ApnSetting apnSetting)

        log("setApnSetting: apnSetting=" + apnSetting);
        mApnSetting = apnSetting;
    
public synchronized voidsetConcurrentVoiceAndDataAllowed(boolean allowed)

        mConcurrentVoiceAndDataAllowed = allowed;
    
public synchronized voidsetDataConnectionAc(DcAsyncChannel dcac)

        if (DBG) {
            log("setDataConnectionAc: old dcac=" + mDcAc + " new dcac=" + dcac
                    + " this=" + this);
        }
        mDcAc = dcac;
    
public voidsetDependencyMet(boolean met)

        if (DBG) {
            log("set mDependencyMet as " + met + " current state is " + mDependencyMet.get());
        }
        mDependencyMet.set(met);
    
public voidsetEnabled(boolean enabled)

        if (DBG) {
            log("set enabled as " + enabled + ", current state is " + mDataEnabled.get());
        }
        mDataEnabled.set(enabled);
    
public synchronized voidsetReason(java.lang.String reason)

        if (DBG) {
            log("set reason as " + reason + ",current state " + mState);
        }
        mReason = reason;
    
public synchronized voidsetReconnectIntent(android.app.PendingIntent intent)

        mReconnectAlarmIntent = intent;
    
public synchronized voidsetState(DctConstants.State s)

        if (DBG) {
            log("setState: " + s + ", previous state:" + mState);
        }

        mState = s;

        if (mState == DctConstants.State.FAILED) {
            if (mWaitingApns != null) {
                mWaitingApns.clear(); // when teardown the connection and set to IDLE
            }
        }
    
public synchronized voidsetWaitingApns(java.util.ArrayList waitingApns)

        mWaitingApns = waitingApns;
        mOriginalWaitingApns = new ArrayList<ApnSetting>(waitingApns);
        mWaitingApnsPermanentFailureCountDown.set(mWaitingApns.size());
    
public synchronized java.lang.StringtoString()

        // We don't print mDataConnection because its recursive.
        return "{mApnType=" + mApnType + " mState=" + getState() + " mWaitingApns={" + mWaitingApns +
                "} mWaitingApnsPermanentFailureCountDown=" + mWaitingApnsPermanentFailureCountDown +
                " mApnSetting={" + mApnSetting + "} mReason=" + mReason +
                " mDataEnabled=" + mDataEnabled + " mDependencyMet=" + mDependencyMet + "}";