FileDocCategorySizeDatePackage
NetworkAgentInfo.javaAPI DocAndroid 5.1 API6908Thu Mar 12 22:22:42 GMT 2015com.android.server.connectivity

NetworkAgentInfo

public class NetworkAgentInfo extends Object
A bag class used by ConnectivityService for holding a collection of most recent information published by a particular NetworkAgent as well as the AsyncChannel/messenger for reaching that NetworkAgent and lists of NetworkRequests interested in using it.

Fields Summary
public android.net.NetworkInfo
networkInfo
public android.net.Network
network
public android.net.LinkProperties
linkProperties
public android.net.NetworkCapabilities
networkCapabilities
public final com.android.server.connectivity.NetworkMonitor
networkMonitor
public final android.net.NetworkMisc
networkMisc
public boolean
created
public boolean
everValidated
public boolean
lastValidated
private int
currentScore
private static final int
UNVALIDATED_SCORE_PENALTY
private static final int
EXPLICITLY_SELECTED_NETWORK_SCORE
public final android.util.SparseArray
networkRequests
public final ArrayList
networkLingered
public final android.os.Messenger
messenger
public final com.android.internal.util.AsyncChannel
asyncChannel
public Nat464Xlat
clatd
Constructors Summary
public NetworkAgentInfo(android.os.Messenger messenger, com.android.internal.util.AsyncChannel ac, android.net.NetworkInfo info, android.net.LinkProperties lp, android.net.NetworkCapabilities nc, int score, android.content.Context context, android.os.Handler handler, android.net.NetworkMisc misc, android.net.NetworkRequest defaultRequest)


          
                     
                
        this.messenger = messenger;
        asyncChannel = ac;
        network = null;
        networkInfo = info;
        linkProperties = lp;
        networkCapabilities = nc;
        currentScore = score;
        networkMonitor = new NetworkMonitor(context, handler, this, defaultRequest);
        networkMisc = misc;
        created = false;
        everValidated = false;
        lastValidated = false;
    
Methods Summary
public voidaddRequest(android.net.NetworkRequest networkRequest)

        networkRequests.put(networkRequest.requestId, networkRequest);
    
private intgetCurrentScore(boolean pretendValidated)

        // TODO: We may want to refactor this into a NetworkScore class that takes a base score from
        // the NetworkAgent and signals from the NetworkAgent and uses those signals to modify the
        // score.  The NetworkScore class would provide a nice place to centralize score constants
        // so they are not scattered about the transports.

        int score = currentScore;

        if (!everValidated && !pretendValidated) score -= UNVALIDATED_SCORE_PENALTY;
        if (score < 0) score = 0;

        if (networkMisc.explicitlySelected) score = EXPLICITLY_SELECTED_NETWORK_SCORE;

        return score;
    
public intgetCurrentScore()

        return getCurrentScore(false);
    
public intgetCurrentScoreAsValidated()

        return getCurrentScore(true);
    
public booleanisVPN()

        return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN);
    
public java.lang.Stringname()

        return "NetworkAgentInfo [" + networkInfo.getTypeName() + " (" +
                networkInfo.getSubtypeName() + ") - " +
                (network == null ? "null" : network.toString()) + "]";
    
public booleansatisfies(android.net.NetworkRequest request)

        return created &&
                request.networkCapabilities.satisfiedByNetworkCapabilities(networkCapabilities);
    
public voidsetCurrentScore(int newScore)

        currentScore = newScore;
    
public java.lang.StringtoString()

        return "NetworkAgentInfo{ ni{" + networkInfo + "}  network{" +
                network + "}  lp{" +
                linkProperties + "}  nc{" +
                networkCapabilities + "}  Score{" + getCurrentScore() + "}  " +
                "everValidated{" + everValidated + "}  lastValidated{" + lastValidated + "}  " +
                "created{" + created + "}  " +
                "explicitlySelected{" + networkMisc.explicitlySelected + "} }";