Search in sources :

Example 11 with ApnContext

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

the class GsmDataConnectionTracker method onDataSetupComplete.

@Override
protected void onDataSetupComplete(AsyncResult ar) {
    ApnContext apnContext = null;
    if (ar.userObj instanceof ApnContext) {
        apnContext = (ApnContext) ar.userObj;
    } else {
        throw new RuntimeException("onDataSetupComplete: No apnContext");
    }
    if (isDataSetupCompleteOk(ar)) {
        DataConnectionAc dcac = apnContext.getDataConnectionAc();
        if (dcac == null) {
            throw new RuntimeException("onDataSetupCompete: No dcac");
        }
        DataConnection dc = apnContext.getDataConnection();
        if (DBG) {
            log(String.format("onDataSetupComplete: success apn=%s", apnContext.getWaitingApns().get(0).apn));
        }
        ApnSetting apn = apnContext.getApnSetting();
        if (apn.proxy != null && apn.proxy.length() != 0) {
            try {
                String port = apn.port;
                if (TextUtils.isEmpty(port))
                    port = "8080";
                ProxyProperties proxy = new ProxyProperties(apn.proxy, Integer.parseInt(port), null);
                dcac.setLinkPropertiesHttpProxySync(proxy);
            } catch (NumberFormatException e) {
                loge("onDataSetupComplete: NumberFormatException making ProxyProperties (" + apn.port + "): " + e);
            }
        }
        // everything is setup
        if (TextUtils.equals(apnContext.getApnType(), Phone.APN_TYPE_DEFAULT)) {
            SystemProperties.set("gsm.defaultpdpcontext.active", "true");
            if (canSetPreferApn && mPreferredApn == null) {
                if (DBG)
                    log("onDataSetupComplete: PREFERED APN is null");
                mPreferredApn = apnContext.getApnSetting();
                if (mPreferredApn != null) {
                    setPreferredApn(mPreferredApn.id);
                }
            }
        } else {
            SystemProperties.set("gsm.defaultpdpcontext.active", "false");
        }
        notifyDefaultData(apnContext);
    } else {
        String apnString;
        DataConnection.FailCause cause;
        cause = (DataConnection.FailCause) (ar.result);
        if (DBG) {
            try {
                apnString = apnContext.getWaitingApns().get(0).apn;
            } catch (Exception e) {
                apnString = "<unknown>";
            }
            log(String.format("onDataSetupComplete: error apn=%s cause=%s", apnString, cause));
        }
        if (cause.isEventLoggable()) {
            // Log this failure to the Event Logs.
            int cid = getCellLocationId();
            EventLog.writeEvent(EventLogTags.PDP_SETUP_FAIL, cause.ordinal(), cid, TelephonyManager.getDefault().getNetworkType());
        }
        // Count permanent failures and remove the APN we just tried
        if (cause.isPermanentFail())
            apnContext.decWaitingApnsPermFailCount();
        apnContext.removeNextWaitingApn();
        if (DBG) {
            log(String.format("onDataSetupComplete: WaitingApns.size=%d" + " WaitingApnsPermFailureCountDown=%d", apnContext.getWaitingApns().size(), apnContext.getWaitingApnsPermFailCount()));
        }
        // See if there are more APN's to try
        if (apnContext.getWaitingApns().isEmpty()) {
            if (apnContext.getWaitingApnsPermFailCount() == 0) {
                if (DBG) {
                    log("onDataSetupComplete: All APN's had permanent failures, stop retrying");
                }
                apnContext.setState(State.FAILED);
                mPhone.notifyDataConnection(Phone.REASON_APN_FAILED, apnContext.getApnType());
                apnContext.setDataConnection(null);
                apnContext.setDataConnectionAc(null);
                if (DBG) {
                    log("onDataSetupComplete: permanent error apn=%s" + apnString);
                }
            } else {
                if (DBG)
                    log("onDataSetupComplete: Not all permanent failures, retry");
                // check to see if retry should be overridden for this failure.
                int retryOverride = -1;
                if (ar.exception instanceof DataConnection.CallSetupException) {
                    retryOverride = ((DataConnection.CallSetupException) ar.exception).getRetryOverride();
                }
                if (retryOverride == RILConstants.MAX_INT) {
                    if (DBG)
                        log("No retry is suggested.");
                } else {
                    startDelayedRetry(cause, apnContext, retryOverride);
                }
            }
        } else {
            if (DBG)
                log("onDataSetupComplete: Try next APN");
            apnContext.setState(State.SCANNING);
            // Wait a bit before trying the next APN, so that
            // we're not tying up the RIL command channel
            startAlarmForReconnect(APN_DELAY_MILLIS, apnContext);
        }
    }
}
Also used : ProxyProperties(android.net.ProxyProperties) DataConnection(com.android.internal.telephony.DataConnection) ApnContext(com.android.internal.telephony.ApnContext) DataConnectionAc(com.android.internal.telephony.DataConnectionAc) FailCause(com.android.internal.telephony.DataConnection.FailCause) ApnSetting(com.android.internal.telephony.ApnSetting)

Example 12 with ApnContext

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

the class GsmDataConnectionTracker method onDisconnectDone.

/**
     * Called when EVENT_DISCONNECT_DONE is received.
     */
@Override
protected void onDisconnectDone(int connId, AsyncResult ar) {
    ApnContext apnContext = null;
    if (DBG)
        log("onDisconnectDone: EVENT_DISCONNECT_DONE connId=" + connId);
    if (ar.userObj instanceof ApnContext) {
        apnContext = (ApnContext) ar.userObj;
    } else {
        loge("Invalid ar in onDisconnectDone");
        return;
    }
    apnContext.setState(State.IDLE);
    mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
    // pending.
    if (isDisconnected()) {
        if (mPhone.getServiceStateTracker().processPendingRadioPowerOffAfterDataOff()) {
            // Radio will be turned off. No need to retry data setup
            apnContext.setApnSetting(null);
            apnContext.setDataConnection(null);
            apnContext.setDataConnectionAc(null);
            return;
        }
    }
    // If APN is still enabled, try to bring it back up automatically
    if (apnContext.isReady() && retryAfterDisconnected(apnContext.getReason())) {
        // TODO - what the heck?  This shoudld go
        SystemProperties.set("gsm.defaultpdpcontext.active", "false");
        // Wait a bit before trying the next APN, so that
        // we're not tying up the RIL command channel.
        // This also helps in any external dependency to turn off the context.
        startAlarmForReconnect(APN_DELAY_MILLIS, apnContext);
    } else {
        apnContext.setApnSetting(null);
        apnContext.setDataConnection(null);
        apnContext.setDataConnectionAc(null);
    }
}
Also used : ApnContext(com.android.internal.telephony.ApnContext)

Example 13 with ApnContext

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

the class GsmDataConnectionTracker method onSetDependencyMet.

@Override
protected void onSetDependencyMet(String apnType, boolean met) {
    // don't allow users to tweak hipri to work around default dependency not met
    if (Phone.APN_TYPE_HIPRI.equals(apnType))
        return;
    ApnContext apnContext = mApnContexts.get(apnType);
    if (apnContext == null) {
        loge("onSetDependencyMet: ApnContext not found in onSetDependencyMet(" + apnType + ", " + met + ")");
        return;
    }
    applyNewState(apnContext, apnContext.isEnabled(), met);
    if (Phone.APN_TYPE_DEFAULT.equals(apnType)) {
        // tie actions on default to similar actions on HIPRI regarding dependencyMet
        apnContext = mApnContexts.get(Phone.APN_TYPE_HIPRI);
        if (apnContext != null)
            applyNewState(apnContext, apnContext.isEnabled(), met);
    }
}
Also used : ApnContext(com.android.internal.telephony.ApnContext)

Example 14 with ApnContext

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

the class GsmDataConnectionTracker method onActionIntentReconnectAlarm.

@Override
protected void onActionIntentReconnectAlarm(Intent intent) {
    if (DBG)
        log("GPRS reconnect alarm. Previous state was " + mState);
    String reason = intent.getStringExtra(INTENT_RECONNECT_ALARM_EXTRA_REASON);
    int connectionId = intent.getIntExtra(INTENT_RECONNECT_ALARM_EXTRA_TYPE, -1);
    DataConnectionAc dcac = mDataConnectionAsyncChannels.get(connectionId);
    if (dcac != null) {
        for (ApnContext apnContext : dcac.getApnListSync()) {
            apnContext.setReason(reason);
            if (apnContext.getState() == State.FAILED) {
                apnContext.setState(State.IDLE);
            }
            sendMessage(obtainMessage(EVENT_TRY_SETUP_DATA, apnContext));
        }
        // Alram had expired. Clear pending intent recorded on the DataConnection.
        dcac.setReconnectIntentSync(null);
    }
}
Also used : ApnContext(com.android.internal.telephony.ApnContext) DataConnectionAc(com.android.internal.telephony.DataConnectionAc)

Example 15 with ApnContext

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

the class GsmDataConnectionTracker method addApnContext.

private ApnContext addApnContext(String type) {
    ApnContext apnContext = new ApnContext(type, LOG_TAG);
    apnContext.setDependencyMet(false);
    mApnContexts.put(type, apnContext);
    return apnContext;
}
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