Search in sources :

Example 91 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.

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

use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.

the class ConnectivityService method handleSetAcceptUnvalidated.

private void handleSetAcceptUnvalidated(Network network, boolean accept, boolean always) {
    if (DBG)
        log("handleSetAcceptUnvalidated network=" + network + " accept=" + accept + " always=" + always);
    NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
    if (nai == null) {
        // Nothing to do.
        return;
    }
    if (nai.everValidated) {
        // The network validated while the dialog box was up. Take no action.
        return;
    }
    if (!nai.networkMisc.explicitlySelected) {
        Slog.wtf(TAG, "BUG: setAcceptUnvalidated non non-explicitly selected network");
    }
    if (accept != nai.networkMisc.acceptUnvalidated) {
        int oldScore = nai.getCurrentScore();
        nai.networkMisc.acceptUnvalidated = accept;
        rematchAllNetworksAndRequests(nai, oldScore);
        sendUpdatedScoreToFactories(nai);
    }
    if (always) {
        nai.asyncChannel.sendMessage(NetworkAgent.CMD_SAVE_ACCEPT_UNVALIDATED, accept ? 1 : 0);
    }
    if (!accept) {
        // Tell the NetworkAgent to not automatically reconnect to the network.
        nai.asyncChannel.sendMessage(NetworkAgent.CMD_PREVENT_AUTOMATIC_RECONNECT);
        // Teardown the nework.
        teardownUnneededNetwork(nai);
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 93 with NetworkAgentInfo

use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.

the class ConnectivityService method handlePromptUnvalidated.

private void handlePromptUnvalidated(Network network) {
    if (VDBG)
        log("handlePromptUnvalidated " + network);
    NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
    // Also don't prompt on captive portals because we're already prompting the user to sign in.
    if (nai == null || nai.everValidated || nai.everCaptivePortalDetected || !nai.networkMisc.explicitlySelected || nai.networkMisc.acceptUnvalidated) {
        return;
    }
    showValidationNotification(nai, NotificationType.NO_INTERNET);
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo)

Example 94 with NetworkAgentInfo

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

the class ConnectivityService method getAllNetworkState.

@Override
public NetworkState[] getAllNetworkState() {
    // Require internal since we're handing out IMSI details
    enforceConnectivityInternalPermission();
    final ArrayList<NetworkState> result = Lists.newArrayList();
    for (Network network : getAllNetworks()) {
        final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
        if (nai != null) {
            result.add(nai.getNetworkState());
        }
    }
    return result.toArray(new NetworkState[result.size()]);
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) Network(android.net.Network) NetworkState(android.net.NetworkState)

Example 95 with NetworkAgentInfo

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

the class ConnectivityService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        pw.println("Permission Denial: can't dump ConnectivityService " + "from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
        return;
    }
    if (argsContain(args, "--diag")) {
        dumpNetworkDiagnostics(pw);
        return;
    }
    pw.print("NetworkFactories for:");
    for (NetworkFactoryInfo nfi : mNetworkFactoryInfos.values()) {
        pw.print(" " + nfi.name);
    }
    pw.println();
    pw.println();
    final NetworkAgentInfo defaultNai = getDefaultNetwork();
    pw.print("Active default network: ");
    if (defaultNai == null) {
        pw.println("none");
    } else {
        pw.println(defaultNai.network.netId);
    }
    pw.println();
    pw.println("Current Networks:");
    pw.increaseIndent();
    for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
        pw.println(nai.toString());
        pw.increaseIndent();
        pw.println(String.format("Requests: REQUEST:%d LISTEN:%d BACKGROUND_REQUEST:%d total:%d", nai.numForegroundNetworkRequests(), nai.numNetworkRequests() - nai.numRequestNetworkRequests(), nai.numBackgroundNetworkRequests(), nai.numNetworkRequests()));
        pw.increaseIndent();
        for (int i = 0; i < nai.numNetworkRequests(); i++) {
            pw.println(nai.requestAt(i).toString());
        }
        pw.decreaseIndent();
        pw.println("Lingered:");
        pw.increaseIndent();
        nai.dumpLingerTimers(pw);
        pw.decreaseIndent();
        pw.decreaseIndent();
    }
    pw.decreaseIndent();
    pw.println();
    pw.println("Metered Interfaces:");
    pw.increaseIndent();
    for (String value : mMeteredIfaces) {
        pw.println(value);
    }
    pw.decreaseIndent();
    pw.println();
    pw.print("Restrict background: ");
    pw.println(mRestrictBackground);
    pw.println();
    pw.println("Status for known UIDs:");
    pw.increaseIndent();
    final int size = mUidRules.size();
    for (int i = 0; i < size; i++) {
        final int uid = mUidRules.keyAt(i);
        pw.print("UID=");
        pw.print(uid);
        final int uidRules = mUidRules.get(uid, RULE_NONE);
        pw.print(" rules=");
        pw.print(uidRulesToString(uidRules));
        pw.println();
    }
    pw.println();
    pw.decreaseIndent();
    pw.println("Network Requests:");
    pw.increaseIndent();
    for (NetworkRequestInfo nri : mNetworkRequests.values()) {
        pw.println(nri.toString());
    }
    pw.println();
    pw.decreaseIndent();
    mLegacyTypeTracker.dump(pw);
    synchronized (this) {
        pw.print("mNetTransitionWakeLock: currently " + (mNetTransitionWakeLock.isHeld() ? "" : "not ") + "held");
        if (!TextUtils.isEmpty(mNetTransitionWakeLockCausedBy)) {
            pw.println(", last requested for " + mNetTransitionWakeLockCausedBy);
        } else {
            pw.println(", last requested never");
        }
    }
    pw.println();
    mTethering.dump(fd, pw, args);
    pw.println();
    mKeepaliveTracker.dump(pw);
    pw.println();
    dumpAvoidBadWifiSettings(pw);
    pw.println();
    if (mInetLog != null && mInetLog.size() > 0) {
        pw.println();
        pw.println("Inet condition reports:");
        pw.increaseIndent();
        for (int i = 0; i < mInetLog.size(); i++) {
            pw.println(mInetLog.get(i));
        }
        pw.decreaseIndent();
    }
    if (argsContain(args, "--short") == false) {
        pw.println();
        synchronized (mValidationLogs) {
            pw.println("mValidationLogs (most recent first):");
            for (ValidationLog p : mValidationLogs) {
                pw.println(p.mNetwork + " - " + p.mNetworkExtraInfo);
                pw.increaseIndent();
                p.mLog.dump(fd, pw, args);
                pw.decreaseIndent();
            }
        }
        pw.println();
        pw.println("mNetworkRequestInfoLogs (most recent first):");
        pw.increaseIndent();
        mNetworkRequestInfoLogs.reverseDump(fd, pw, args);
        pw.decreaseIndent();
        pw.println();
        pw.println("mNetworkInfoBlockingLogs (most recent first):");
        pw.increaseIndent();
        mNetworkInfoBlockingLogs.reverseDump(fd, pw, args);
        pw.decreaseIndent();
    }
}
Also used : NetworkAgentInfo(com.android.server.connectivity.NetworkAgentInfo) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

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