Search in sources :

Example 16 with ApnContext

use of com.android.internal.telephony.ApnContext in project XobotOS by xamarin.

the class GsmDataConnectionTracker method getOverallState.

// Return state of overall
public State getOverallState() {
    boolean isConnecting = false;
    // All enabled Apns should be FAILED.
    boolean isFailed = true;
    boolean isAnyEnabled = false;
    for (ApnContext apnContext : mApnContexts.values()) {
        if (apnContext.isEnabled()) {
            isAnyEnabled = true;
            switch(apnContext.getState()) {
                case CONNECTED:
                case DISCONNECTING:
                    if (DBG)
                        log("overall state is CONNECTED");
                    return State.CONNECTED;
                case CONNECTING:
                case INITING:
                    isConnecting = true;
                    isFailed = false;
                    break;
                case IDLE:
                case SCANNING:
                    isFailed = false;
                    break;
            }
        }
    }
    if (!isAnyEnabled) {
        // Nothing enabled. return IDLE.
        if (DBG)
            log("overall state is IDLE");
        return State.IDLE;
    }
    if (isConnecting) {
        if (DBG)
            log("overall state is CONNECTING");
        return State.CONNECTING;
    } else if (!isFailed) {
        if (DBG)
            log("overall state is IDLE");
        return State.IDLE;
    } else {
        if (DBG)
            log("overall state is FAILED");
        return State.FAILED;
    }
}
Also used : ApnContext(com.android.internal.telephony.ApnContext)

Example 17 with ApnContext

use of com.android.internal.telephony.ApnContext in project XobotOS by xamarin.

the class GsmDataConnectionTracker method onApnChanged.

/**
     * Handles changes to the APN database.
     */
private void onApnChanged() {
    // TODO: How to handle when multiple APNs are active?
    ApnContext defaultApnContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
    boolean defaultApnIsDisconnected = defaultApnContext.isDisconnected();
    if (mPhone instanceof GSMPhone) {
        // The "current" may no longer be valid.  MMS depends on this to send properly. TBD
        ((GSMPhone) mPhone).updateCurrentCarrierInProvider();
    }
    // match the current operator.
    if (DBG)
        log("onApnChanged: createAllApnList and cleanUpAllConnections");
    createAllApnList();
    cleanUpAllConnections(!defaultApnIsDisconnected, Phone.REASON_APN_CHANGED);
    if (defaultApnIsDisconnected) {
        setupDataOnReadyApns(Phone.REASON_APN_CHANGED);
    }
}
Also used : ApnContext(com.android.internal.telephony.ApnContext)

Aggregations

ApnContext (com.android.internal.telephony.ApnContext)17 DataConnectionAc (com.android.internal.telephony.DataConnectionAc)5 DataCallState (com.android.internal.telephony.DataCallState)2 LinkAddress (android.net.LinkAddress)1 NetworkConfig (android.net.NetworkConfig)1 ProxyProperties (android.net.ProxyProperties)1 Message (android.os.Message)1 ServiceState (android.telephony.ServiceState)1 ApnSetting (com.android.internal.telephony.ApnSetting)1 DataConnection (com.android.internal.telephony.DataConnection)1 FailCause (com.android.internal.telephony.DataConnection.FailCause)1 UpdateLinkPropertyResult (com.android.internal.telephony.DataConnection.UpdateLinkPropertyResult)1 ArrayList (java.util.ArrayList)1