NetworkAgentInfo.java revision 7b81602f3c18df8a4ca0342c514af8f7e394c0d7
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.server.connectivity; 18 19import android.net.LinkProperties; 20import android.net.Network; 21import android.net.NetworkCapabilities; 22import android.net.NetworkInfo; 23import android.net.NetworkRequest; 24import android.os.Messenger; 25import android.util.SparseArray; 26 27import com.android.internal.util.AsyncChannel; 28 29import java.util.ArrayList; 30 31/** 32 * A bag class used by ConnectivityService for holding a collection of most recent 33 * information published by a particular NetworkAgent as well as the 34 * AsyncChannel/messenger for reaching that NetworkAgent and lists of NetworkRequests 35 * interested in using it. 36 */ 37public class NetworkAgentInfo { 38 public NetworkInfo networkInfo; 39 public final Network network; 40 public LinkProperties linkProperties; 41 public NetworkCapabilities networkCapabilities; 42 public int currentScore; 43 44 // The list of NetworkRequests being satisfied by this Network. 45 public final SparseArray<NetworkRequest> networkRequests = new SparseArray<NetworkRequest>(); 46 47 // The list of NetworkListens listening for changes on this Network. 48 public final ArrayList<NetworkRequest> networkListens = new ArrayList<NetworkRequest>(); 49 public final Messenger messenger; 50 public final AsyncChannel asyncChannel; 51 52 public NetworkAgentInfo(Messenger messenger, AsyncChannel ac, int netId, NetworkInfo info, 53 LinkProperties lp, NetworkCapabilities nc, int score) { 54 this.messenger = messenger; 55 asyncChannel = ac; 56 network = new Network(netId); 57 networkInfo = info; 58 linkProperties = lp; 59 networkCapabilities = nc; 60 currentScore = score; 61 62 } 63 64 public String toString() { 65 return "NetworkAgentInfo{ ni{" + networkInfo + "} network{" + 66 network + "} lp{" + 67 linkProperties + "} nc{" + 68 networkCapabilities + "} Score{" + currentScore + "} }"; 69 } 70 71 public String name() { 72 return "NetworkAgentInfo [" + networkInfo.getTypeName() + " (" + 73 networkInfo.getSubtypeName() + ")]"; 74 } 75} 76