Search in sources :

Example 71 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by AOSPA.

the class ConnectivityService method reportInetCondition.

// 100 percent is full good, 0 is full bad.
@Override
public void reportInetCondition(int networkType, int percentage) {
    NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
    if (nai == null)
        return;
    reportNetworkConnectivity(nai.network, percentage > 50);
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 72 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by AOSPA.

the class ConnectivityService method handleSetAvoidUnvalidated.

private void handleSetAvoidUnvalidated(Network network) {
    NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
    if (nai == null || nai.lastValidated) {
        // Nothing to do. The network either disconnected or revalidated.
        return;
    }
    if (!nai.avoidUnvalidated) {
        int oldScore = nai.getCurrentScore();
        nai.avoidUnvalidated = true;
        rematchAllNetworksAndRequests(nai, oldScore);
        sendUpdatedScoreToFactories(nai);
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 73 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_opt_telephony by LineageOS.

the class ConnectivityServiceMock method handleAsyncChannelDisconnected.

private void handleAsyncChannelDisconnected(Message msg) {
    NetworkAgentInfo nai = mNetworkAgentInfos.get(msg.replyTo);
    if (nai != null) {
        if (DBG) {
            log(nai.name() + " got DISCONNECTED, was satisfying " + nai.numNetworkRequests());
        }
        // A network agent has disconnected.
        // TODO - if we move the logic to the network agent (have them disconnect
        // because they lost all their requests or because their score isn't good)
        // then they would disconnect organically, report their new state and then
        // disconnect the channel.
        // if (nai.networkInfo.isConnected()) {
        // nai.networkInfo.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED,
        // null, null);
        // }
        // final boolean wasDefault = isDefaultNetwork(nai);
        // if (wasDefault) {
        // mDefaultInetConditionPublished = 0;
        // }
        // notifyIfacesChanged();
        // TODO - we shouldn't send CALLBACK_LOST to requests that can be satisfied
        // by other networks that are already connected. Perhaps that can be done by
        // sending all CALLBACK_LOST messages (for requests, not listens) at the end
        // of rematchAllNetworksAndRequests
        // notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_LOST);
        // mKeepaliveTracker.handleStopAllKeepalives(nai,
        // ConnectivityManager.PacketKeepalive.ERROR_INVALID_NETWORK);
        nai.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_DISCONNECTED);
        mNetworkAgentInfos.remove(msg.replyTo);
    // updateClat(null, nai.linkProperties, nai);
    // synchronized (mNetworkForNetId) {
    // // Remove the NetworkAgent, but don't mark the netId as
    // // available until we've told netd to delete it below.
    // mNetworkForNetId.remove(nai.network.netId);
    // }
    // Remove all previously satisfied requests.
    // for (int i = 0; i < nai.networkRequests.size(); i++) {
    // NetworkRequest request = nai.networkRequests.valueAt(i);
    // NetworkAgentInfo currentNetwork = mNetworkForRequestId.get(request.requestId);
    // if (currentNetwork != null && currentNetwork.network.netId == nai.network.netId) {
    // mNetworkForRequestId.remove(request.requestId);
    // sendUpdatedScoreToFactories(request, 0);
    // }
    // }
    // if (nai.networkRequests.get(mDefaultRequest.requestId) != null) {
    // removeDataActivityTracking(nai);
    // notifyLockdownVpn(nai);
    // requestNetworkTransitionWakelock(nai.name());
    // }
    // mLegacyTypeTracker.remove(nai, wasDefault);
    // rematchAllNetworksAndRequests(null, 0);
    // if (nai.created) {
    // // Tell netd to clean up the configuration for this network
    // // (routing rules, DNS, etc).
    // // This may be slow as it requires a lot of netd shelling out to ip and
    // // ip[6]tables to flush routes and remove the incoming packet mark rule, so do it
    // // after we've rematched networks with requests which should make a potential
    // // fallback network the default or requested a new network from the
    // // NetworkFactories, so network traffic isn't interrupted for an unnecessarily
    // // long time.
    // try {
    // mNetd.removeNetwork(nai.network.netId);
    // } catch (Exception e) {
    // loge("Exception removing network: " + e);
    // }
    // }
    // synchronized (mNetworkForNetId) {
    // mNetIdInUse.delete(nai.network.netId);
    // }
    } else {
        NetworkFactoryInfo nfi = mNetworkFactoryInfos.remove(msg.replyTo);
        if (DBG && nfi != null)
            log("unregisterNetworkFactory for " + nfi.name);
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 74 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_opt_telephony by LineageOS.

the class ConnectivityServiceMock method handleAsyncChannelHalfConnect.

private void handleAsyncChannelHalfConnect(Message msg) {
    AsyncChannel ac = (AsyncChannel) msg.obj;
    if (mNetworkFactoryInfos.containsKey(msg.replyTo)) {
        if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
            if (VDBG)
                log("NetworkFactory connected");
            // A network factory has connected.  Send it all current NetworkRequests.
            for (NetworkRequestInfo nri : mNetworkRequests.values()) {
                if (nri.isRequest == false)
                    continue;
                // NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
                NetworkAgentInfo nai = null;
                ac.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, (nai != null ? nai.getCurrentScore() : 0), 0, nri.request);
            }
        } else {
            loge("Error connecting NetworkFactory");
            mNetworkFactoryInfos.remove(msg.obj);
        }
    } else if (mNetworkAgentInfos.containsKey(msg.replyTo)) {
        if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
            if (VDBG)
                log("NetworkAgent connected");
            // A network agent has requested a connection.  Establish the connection.
            mNetworkAgentInfos.get(msg.replyTo).asyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
        } else {
            loge("Error connecting NetworkAgent");
            NetworkAgentInfo nai = mNetworkAgentInfos.remove(msg.replyTo);
        // if (nai != null) {
        // final boolean wasDefault = isDefaultNetwork(nai);
        // synchronized (mNetworkForNetId) {
        // mNetworkForNetId.remove(nai.network.netId);
        // mNetIdInUse.delete(nai.network.netId);
        // }
        // // Just in case.
        // mLegacyTypeTracker.remove(nai, wasDefault);
        // }
        }
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) AsyncChannel(com.android.internal.util.AsyncChannel)

Example 75 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_opt_telephony by LineageOS.

the class ConnectivityServiceMock method handleRegisterNetworkRequest.

private void handleRegisterNetworkRequest(NetworkRequestInfo nri) {
    mNetworkRequests.put(nri.request, nri);
    if (!nri.isRequest) {
        for (NetworkAgentInfo network : mNetworkAgentInfos.values()) {
            if (nri.request.networkCapabilities.hasSignalStrength() && network.satisfiesImmutableCapabilitiesOf(nri.request)) {
            }
        }
    }
    rematchAllNetworksAndRequests(null, 0);
    if (nri.isRequest) {
        sendUpdatedScoreToFactories(nri.request, 0);
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Aggregations

NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)165 LinkProperties (android.net.LinkProperties)40 Network (android.net.Network)25 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)21 NetworkCapabilities (android.net.NetworkCapabilities)20 NetworkInfo (android.net.NetworkInfo)15 NetworkRequest (android.net.NetworkRequest)15 NetworkState (android.net.NetworkState)15 RemoteException (android.os.RemoteException)14 UnknownHostException (java.net.UnknownHostException)14 AsyncChannel (com.android.internal.util.AsyncChannel)11 Vpn (com.android.server.connectivity.Vpn)10 ArrayList (java.util.ArrayList)10 FileNotFoundException (java.io.FileNotFoundException)9 IOException (java.io.IOException)9 InetAddress (java.net.InetAddress)9 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)9 Nullable (android.annotation.Nullable)5 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5