Search in sources :

Example 6 with ApnContext

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

the class GsmDataConnectionTracker method trySetupData.

private boolean trySetupData(String reason, String type) {
    if (DBG) {
        log("trySetupData: " + type + " due to " + (reason == null ? "(unspecified)" : reason) + " isPsRestricted=" + mIsPsRestricted);
    }
    if (type == null) {
        type = Phone.APN_TYPE_DEFAULT;
    }
    ApnContext apnContext = mApnContexts.get(type);
    if (apnContext == null) {
        if (DBG)
            log("trySetupData new apn context for type:" + type);
        apnContext = new ApnContext(type, LOG_TAG);
        mApnContexts.put(type, apnContext);
    }
    apnContext.setReason(reason);
    return trySetupData(apnContext);
}
Also used : ApnContext(com.android.internal.telephony.ApnContext)

Example 7 with ApnContext

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

the class GsmDataConnectionTracker method cleanUpAllConnections.

/**
     * If tearDown is true, this only tears down a CONNECTED session. Presently,
     * there is no mechanism for abandoning an INITING/CONNECTING session,
     * but would likely involve cancelling pending async requests or
     * setting a flag or new state to ignore them when they came in
     * @param tearDown true if the underlying GsmDataConnection should be
     * disconnected.
     * @param reason reason for the clean up.
     */
protected void cleanUpAllConnections(boolean tearDown, String reason) {
    if (DBG)
        log("cleanUpAllConnections: tearDown=" + tearDown + " reason=" + reason);
    for (ApnContext apnContext : mApnContexts.values()) {
        apnContext.setReason(reason);
        cleanUpConnection(tearDown, apnContext);
    }
    stopNetStatPoll();
    // TODO: Do we need mRequestedApnType?
    mRequestedApnType = Phone.APN_TYPE_DEFAULT;
}
Also used : ApnContext(com.android.internal.telephony.ApnContext)

Example 8 with ApnContext

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

the class GsmDataConnectionTracker method cleanUpConnection.

private void cleanUpConnection(boolean tearDown, ApnContext apnContext) {
    if (apnContext == null) {
        if (DBG)
            log("cleanUpConnection: apn context is null");
        return;
    }
    if (DBG) {
        log("cleanUpConnection: tearDown=" + tearDown + " reason=" + apnContext.getReason());
    }
    DataConnectionAc dcac = apnContext.getDataConnectionAc();
    if (tearDown) {
        if (apnContext.isDisconnected()) {
            // The request is tearDown and but ApnContext is not connected.
            // If apnContext is not enabled anymore, break the linkage to the DCAC/DC.
            apnContext.setState(State.IDLE);
            if (!apnContext.isReady()) {
                apnContext.setDataConnection(null);
                apnContext.setDataConnectionAc(null);
            }
        } else {
            // Connection is still there. Try to clean up.
            if (dcac != null) {
                if (apnContext.getState() != State.DISCONNECTING) {
                    if (DBG)
                        log("cleanUpConnection: tearing down");
                    Message msg = obtainMessage(EVENT_DISCONNECT_DONE, apnContext);
                    apnContext.getDataConnection().tearDown(apnContext.getReason(), msg);
                    apnContext.setState(State.DISCONNECTING);
                }
            } else {
                // apn is connected but no reference to dcac.
                // Should not be happen, but reset the state in case.
                apnContext.setState(State.IDLE);
                mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
            }
        }
    } else {
        // force clean up the data connection.
        if (dcac != null)
            dcac.resetSync();
        apnContext.setState(State.IDLE);
        mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
        apnContext.setDataConnection(null);
        apnContext.setDataConnectionAc(null);
    }
    // associated to the connection.
    if (dcac != null) {
        Collection<ApnContext> apnList = dcac.getApnListSync();
        if (apnList.isEmpty()) {
            cancelReconnectAlarm(dcac);
        }
    }
}
Also used : Message(android.os.Message) ApnContext(com.android.internal.telephony.ApnContext) DataConnectionAc(com.android.internal.telephony.DataConnectionAc)

Example 9 with ApnContext

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

the class GsmDataConnectionTracker method isDataPossible.

@Override
protected boolean isDataPossible(String apnType) {
    ApnContext apnContext = mApnContexts.get(apnType);
    if (apnContext == null) {
        return false;
    }
    boolean apnContextIsEnabled = apnContext.isEnabled();
    State apnContextState = apnContext.getState();
    boolean apnTypePossible = !(apnContextIsEnabled && (apnContextState == State.FAILED));
    boolean dataAllowed = isDataAllowed();
    boolean possible = dataAllowed && apnTypePossible;
    if (DBG) {
        log(String.format("isDataPossible(%s): possible=%b isDataAllowed=%b " + "apnTypePossible=%b apnContextisEnabled=%b apnContextState()=%s", apnType, possible, dataAllowed, apnTypePossible, apnContextIsEnabled, apnContextState));
    }
    return possible;
}
Also used : ServiceState(android.telephony.ServiceState) DataCallState(com.android.internal.telephony.DataCallState) ApnContext(com.android.internal.telephony.ApnContext)

Example 10 with ApnContext

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

the class GsmDataConnectionTracker method setupDataOnReadyApns.

private void setupDataOnReadyApns(String reason) {
    // retry. Reset ApnContext state to IDLE.
    for (DataConnectionAc dcac : mDataConnectionAsyncChannels.values()) {
        if (dcac.getReconnectIntentSync() != null) {
            cancelReconnectAlarm(dcac);
        }
        // ones for the new RAT.
        if (dcac.dataConnection != null) {
            Collection<ApnContext> apns = dcac.getApnListSync();
            boolean hasDefault = false;
            for (ApnContext apnContext : apns) {
                if (apnContext.getApnType().equals(Phone.APN_TYPE_DEFAULT)) {
                    hasDefault = true;
                    break;
                }
            }
            configureRetry(dcac.dataConnection, hasDefault);
        }
    }
    // Only check for default APN state
    for (ApnContext apnContext : mApnContexts.values()) {
        if (apnContext.getState() == State.FAILED) {
            // By this time, alarms for all failed Apns
            // should be stopped if any.
            // Make sure to set the state back to IDLE
            // so that setup data can happen.
            apnContext.setState(State.IDLE);
        }
        if (apnContext.isReady()) {
            if (apnContext.getState() == State.IDLE) {
                apnContext.setReason(reason);
                trySetupData(apnContext);
            }
        }
    }
}
Also used : ApnContext(com.android.internal.telephony.ApnContext) DataConnectionAc(com.android.internal.telephony.DataConnectionAc)

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