Search in sources :

Example 1 with ApnContext

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

the class GsmDataConnectionTracker method onEnableApn.

@Override
protected void onEnableApn(int apnId, int enabled) {
    ApnContext apnContext = mApnContexts.get(apnIdToType(apnId));
    if (apnContext == null) {
        loge("onEnableApn(" + apnId + ", " + enabled + "): NO ApnContext");
        return;
    }
    // TODO change our retry manager to use the appropriate numbers for the new APN
    if (DBG)
        log("onEnableApn: apnContext=" + apnContext + " call applyNewState");
    applyNewState(apnContext, enabled == ENABLED, apnContext.getDependencyMet());
}
Also used : ApnContext(com.android.internal.telephony.ApnContext)

Example 2 with ApnContext

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

the class GsmDataConnectionTracker method onCleanUpConnection.

@Override
protected void onCleanUpConnection(boolean tearDown, int apnId, String reason) {
    if (DBG)
        log("onCleanUpConnection");
    ApnContext apnContext = mApnContexts.get(apnIdToType(apnId));
    if (apnContext != null) {
        apnContext.setReason(reason);
        cleanUpConnection(tearDown, apnContext);
    }
}
Also used : ApnContext(com.android.internal.telephony.ApnContext)

Example 3 with ApnContext

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

the class GsmDataConnectionTracker method onDataStateChanged.

/**
     * @param ar is the result of RIL_REQUEST_DATA_CALL_LIST
     * or RIL_UNSOL_DATA_CALL_LIST_CHANGED
     */
private void onDataStateChanged(AsyncResult ar) {
    ArrayList<DataCallState> dataCallStates;
    if (DBG)
        log("onDataStateChanged(ar): E");
    dataCallStates = (ArrayList<DataCallState>) (ar.result);
    if (ar.exception != null) {
        // to come down soon anyway
        if (DBG)
            log("onDataStateChanged(ar): exception; likely radio not available, ignore");
        return;
    }
    if (DBG)
        log("onDataStateChanged(ar): DataCallState size=" + dataCallStates.size());
    // Create a hash map to store the dataCallState of each DataConnectionAc
    HashMap<DataCallState, DataConnectionAc> dataCallStateToDcac;
    dataCallStateToDcac = new HashMap<DataCallState, DataConnectionAc>();
    for (DataCallState dataCallState : dataCallStates) {
        DataConnectionAc dcac = findDataConnectionAcByCid(dataCallState.cid);
        if (dcac != null)
            dataCallStateToDcac.put(dataCallState, dcac);
    }
    // A list of apns to cleanup, those that aren't in the list we know we have to cleanup
    List<ApnContext> apnsToCleanup = findApnContextToClean(dataCallStateToDcac.values());
    // Find which connections have changed state and send a notification or cleanup
    for (DataCallState newState : dataCallStates) {
        DataConnectionAc dcac = dataCallStateToDcac.get(newState);
        if (dcac == null) {
            loge("onDataStateChanged(ar): No associated DataConnection ignore");
            continue;
        }
        // The list of apn's associated with this DataConnection
        Collection<ApnContext> apns = dcac.getApnListSync();
        // Find which ApnContexts of this DC are in the "Connected/Connecting" state.
        ArrayList<ApnContext> connectedApns = new ArrayList<ApnContext>();
        for (ApnContext apnContext : apns) {
            if (apnContext.getState() == State.CONNECTED || apnContext.getState() == State.CONNECTING || apnContext.getState() == State.INITING) {
                connectedApns.add(apnContext);
            }
        }
        if (connectedApns.size() == 0) {
            if (DBG)
                log("onDataStateChanged(ar): no connected apns");
        } else {
            // or just a notification should be sent out.
            if (DBG)
                log("onDataStateChanged(ar): Found ConnId=" + newState.cid + " newState=" + newState.toString());
            if (newState.active == 0) {
                if (DBG) {
                    log("onDataStateChanged(ar): inactive, cleanup apns=" + connectedApns);
                }
                apnsToCleanup.addAll(connectedApns);
            } else {
                // Its active so update the DataConnections link properties
                UpdateLinkPropertyResult result = dcac.updateLinkPropertiesDataCallStateSync(newState);
                if (result.oldLp.equals(result.newLp)) {
                    if (DBG)
                        log("onDataStateChanged(ar): no change");
                } else {
                    if (result.oldLp.isIdenticalInterfaceName(result.newLp)) {
                        if (!result.oldLp.isIdenticalDnses(result.newLp) || !result.oldLp.isIdenticalRoutes(result.newLp) || !result.oldLp.isIdenticalHttpProxy(result.newLp) || !result.oldLp.isIdenticalAddresses(result.newLp)) {
                            // If the same address type was removed and added we need to cleanup
                            CompareResult<LinkAddress> car = result.oldLp.compareAddresses(result.newLp);
                            boolean needToClean = false;
                            for (LinkAddress added : car.added) {
                                for (LinkAddress removed : car.removed) {
                                    if (NetworkUtils.addressTypeMatches(removed.getAddress(), added.getAddress())) {
                                        needToClean = true;
                                        break;
                                    }
                                }
                            }
                            if (needToClean) {
                                if (DBG) {
                                    log("onDataStateChanged(ar): addr change, cleanup apns=" + connectedApns);
                                }
                                apnsToCleanup.addAll(connectedApns);
                            } else {
                                if (DBG)
                                    log("onDataStateChanged(ar): simple change");
                                for (ApnContext apnContext : connectedApns) {
                                    mPhone.notifyDataConnection(Phone.REASON_LINK_PROPERTIES_CHANGED, apnContext.getApnType());
                                }
                            }
                        } else {
                            if (DBG) {
                                log("onDataStateChanged(ar): no changes");
                            }
                        }
                    } else {
                        if (DBG) {
                            log("onDataStateChanged(ar): interface change, cleanup apns=" + connectedApns);
                        }
                        apnsToCleanup.addAll(connectedApns);
                    }
                }
            }
        }
    }
    if (apnsToCleanup.size() != 0) {
        // Add an event log when the network drops PDP
        int cid = getCellLocationId();
        EventLog.writeEvent(EventLogTags.PDP_NETWORK_DROP, cid, TelephonyManager.getDefault().getNetworkType());
    }
    // Cleanup those dropped connections
    for (ApnContext apnContext : apnsToCleanup) {
        cleanUpConnection(true, apnContext);
    }
    if (DBG)
        log("onDataStateChanged(ar): X");
}
Also used : LinkAddress(android.net.LinkAddress) UpdateLinkPropertyResult(com.android.internal.telephony.DataConnection.UpdateLinkPropertyResult) DataCallState(com.android.internal.telephony.DataCallState) ArrayList(java.util.ArrayList) ApnContext(com.android.internal.telephony.ApnContext) DataConnectionAc(com.android.internal.telephony.DataConnectionAc)

Example 4 with ApnContext

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

the class GsmDataConnectionTracker method initApnContextsAndDataConnection.

protected void initApnContextsAndDataConnection() {
    boolean defaultEnabled = SystemProperties.getBoolean(DEFALUT_DATA_ON_BOOT_PROP, true);
    // Load device network attributes from resources
    String[] networkConfigStrings = mPhone.getContext().getResources().getStringArray(com.android.internal.R.array.networkAttributes);
    for (String networkConfigString : networkConfigStrings) {
        NetworkConfig networkConfig = new NetworkConfig(networkConfigString);
        ApnContext apnContext = null;
        switch(networkConfig.type) {
            case ConnectivityManager.TYPE_MOBILE:
                apnContext = addApnContext(Phone.APN_TYPE_DEFAULT);
                apnContext.setEnabled(defaultEnabled);
                break;
            case ConnectivityManager.TYPE_MOBILE_MMS:
                apnContext = addApnContext(Phone.APN_TYPE_MMS);
                break;
            case ConnectivityManager.TYPE_MOBILE_SUPL:
                apnContext = addApnContext(Phone.APN_TYPE_SUPL);
                break;
            case ConnectivityManager.TYPE_MOBILE_DUN:
                apnContext = addApnContext(Phone.APN_TYPE_DUN);
                break;
            case ConnectivityManager.TYPE_MOBILE_HIPRI:
                apnContext = addApnContext(Phone.APN_TYPE_HIPRI);
                ApnContext defaultContext = mApnContexts.get(Phone.APN_TYPE_DEFAULT);
                if (defaultContext != null) {
                    applyNewState(apnContext, apnContext.isEnabled(), defaultContext.getDependencyMet());
                } else {
                // the default will set the hipri dep-met when it is created
                }
                continue;
            case ConnectivityManager.TYPE_MOBILE_FOTA:
                apnContext = addApnContext(Phone.APN_TYPE_FOTA);
                break;
            case ConnectivityManager.TYPE_MOBILE_IMS:
                apnContext = addApnContext(Phone.APN_TYPE_IMS);
                break;
            case ConnectivityManager.TYPE_MOBILE_CBS:
                apnContext = addApnContext(Phone.APN_TYPE_CBS);
                break;
            default:
                // skip unknown types
                continue;
        }
        if (apnContext != null) {
            // set the prop, but also apply the newly set enabled and dependency values
            onSetDependencyMet(apnContext.getApnType(), networkConfig.dependencyMet);
        }
    }
}
Also used : ApnContext(com.android.internal.telephony.ApnContext) NetworkConfig(android.net.NetworkConfig)

Example 5 with ApnContext

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

the class GsmDataConnectionTracker method enableApnType.

/**
     * Ensure that we are connected to an APN of the specified type.
     *
     * @param type the APN type
     * @return Success is indicated by {@code Phone.APN_ALREADY_ACTIVE} or
     *         {@code Phone.APN_REQUEST_STARTED}. In the latter case, a
     *         broadcast will be sent by the ConnectivityManager when a
     *         connection to the APN has been established.
     */
@Override
public synchronized int enableApnType(String apnType) {
    ApnContext apnContext = mApnContexts.get(apnType);
    if (apnContext == null || !isApnTypeAvailable(apnType)) {
        if (DBG)
            log("enableApnType: " + apnType + " is type not available");
        return Phone.APN_TYPE_NOT_AVAILABLE;
    }
    // If already active, return
    if (DBG)
        log("enableApnType: " + apnType + " mState(" + apnContext.getState() + ")");
    if (apnContext.getState() == State.CONNECTED) {
        if (DBG)
            log("enableApnType: return APN_ALREADY_ACTIVE");
        return Phone.APN_ALREADY_ACTIVE;
    }
    setEnabled(apnTypeToId(apnType), true);
    if (DBG) {
        log("enableApnType: new apn request for type " + apnType + " return APN_REQUEST_STARTED");
    }
    return Phone.APN_REQUEST_STARTED;
}
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