Search in sources :

Example 1 with NetworkAgentInfo

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

the class ConnectivityService method registerNetworkAgent.

public int registerNetworkAgent(Messenger messenger, NetworkInfo networkInfo, LinkProperties linkProperties, NetworkCapabilities networkCapabilities, int currentScore, NetworkMisc networkMisc) {
    enforceConnectivityInternalPermission();
    // TODO: Instead of passing mDefaultRequest, provide an API to determine whether a Network
    // satisfies mDefaultRequest.
    final NetworkAgentInfo nai = new NetworkAgentInfo(messenger, new AsyncChannel(), new Network(reserveNetId()), new NetworkInfo(networkInfo), new LinkProperties(linkProperties), new NetworkCapabilities(networkCapabilities), currentScore, mContext, mTrackerHandler, new NetworkMisc(networkMisc), mDefaultRequest, this);
    synchronized (this) {
        nai.networkMonitor.systemReady = mSystemReady;
    }
    addValidationLogs(nai.networkMonitor.getValidationLogs(), nai.network, networkInfo.getExtraInfo());
    if (DBG)
        log("registerNetworkAgent " + nai);
    mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai));
    return nai.network.netId;
}
Also used : NetworkMisc(android.net.NetworkMisc) NetworkInfo(android.net.NetworkInfo) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) Network(android.net.Network) AsyncChannel(com.android.internal.util.AsyncChannel) LinkProperties(android.net.LinkProperties) NetworkCapabilities(android.net.NetworkCapabilities)

Example 2 with NetworkAgentInfo

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

the class ConnectivityService method dumpAvoidBadWifiSettings.

// TODO: Evaluate whether this is of interest to other consumers of
// AvoidBadWifiTracker and worth moving out of here.
private void dumpAvoidBadWifiSettings(IndentingPrintWriter pw) {
    final boolean configRestrict = mAvoidBadWifiTracker.configRestrictsAvoidBadWifi();
    if (!configRestrict) {
        pw.println("Bad Wi-Fi avoidance: unrestricted");
        return;
    }
    pw.println("Bad Wi-Fi avoidance: " + avoidBadWifi());
    pw.increaseIndent();
    pw.println("Config restrict:   " + configRestrict);
    final String value = mAvoidBadWifiTracker.getSettingsValue();
    String description;
    // Can't use a switch statement because strings are legal case labels, but null is not.
    if ("0".equals(value)) {
        description = "get stuck";
    } else if (value == null) {
        description = "prompt";
    } else if ("1".equals(value)) {
        description = "avoid";
    } else {
        description = value + " (?)";
    }
    pw.println("User setting:      " + description);
    pw.println("Network overrides:");
    pw.increaseIndent();
    for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
        if (nai.avoidUnvalidated) {
            pw.println(nai.name());
        }
    }
    pw.decreaseIndent();
    pw.decreaseIndent();
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Example 3 with NetworkAgentInfo

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

the class ConnectivityService method reportNetworkConnectivity.

@Override
public void reportNetworkConnectivity(Network network, boolean hasConnectivity) {
    enforceAccessPermission();
    enforceInternetPermission();
    NetworkAgentInfo nai;
    if (network == null) {
        nai = getDefaultNetwork();
    } else {
        nai = getNetworkAgentInfoForNetwork(network);
    }
    if (nai == null || nai.networkInfo.getState() == NetworkInfo.State.DISCONNECTING || nai.networkInfo.getState() == NetworkInfo.State.DISCONNECTED) {
        return;
    }
    // Revalidate if the app report does not match our current validated state.
    if (hasConnectivity == nai.lastValidated)
        return;
    final int uid = Binder.getCallingUid();
    if (DBG) {
        log("reportNetworkConnectivity(" + nai.network.netId + ", " + hasConnectivity + ") by " + uid);
    }
    synchronized (nai) {
        // rematchNetworkAndRequests() which is not meant to work on such networks.
        if (!nai.everConnected)
            return;
        if (isNetworkWithLinkPropertiesBlocked(nai.linkProperties, uid, false))
            return;
        nai.networkMonitor.sendMessage(NetworkMonitor.CMD_FORCE_REEVALUATION, uid);
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 4 with NetworkAgentInfo

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

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 5 with NetworkAgentInfo

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

the class ConnectivityService method dumpNetworkDiagnostics.

private void dumpNetworkDiagnostics(IndentingPrintWriter pw) {
    final List<NetworkDiagnostics> netDiags = new ArrayList<NetworkDiagnostics>();
    final long DIAG_TIME_MS = 5000;
    for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
        // Start gathering diagnostic information.
        netDiags.add(new NetworkDiagnostics(nai.network, // Must be a copy.
        new LinkProperties(nai.linkProperties), DIAG_TIME_MS));
    }
    for (NetworkDiagnostics netDiag : netDiags) {
        pw.println();
        netDiag.waitForMeasurements();
        netDiag.dump(pw);
    }
}
Also used : NetworkDiagnostics(com.android.server.connectivity.NetworkDiagnostics) NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) ArrayList(java.util.ArrayList) LinkProperties(android.net.LinkProperties)

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