use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
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();
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
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);
}
use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
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);
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
the class ConnectivityService method getNetworkInfoForUid.
@Override
public NetworkInfo getNetworkInfoForUid(Network network, int uid, boolean ignoreBlocked) {
enforceAccessPermission();
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
if (nai != null) {
final NetworkState state = nai.getNetworkState();
filterNetworkStateForUid(state, uid, ignoreBlocked);
return state.networkInfo;
} else {
return null;
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project platform_frameworks_base by android.
the class ConnectivityService method getDefaultNetworkCapabilitiesForUser.
@Override
public NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId) {
// The basic principle is: if an app's traffic could possibly go over a
// network, without the app doing anything multinetwork-specific,
// (hence, by "default"), then include that network's capabilities in
// the array.
//
// In the normal case, app traffic only goes over the system's default
// network connection, so that's the only network returned.
//
// With a VPN in force, some app traffic may go into the VPN, and thus
// over whatever underlying networks the VPN specifies, while other app
// traffic may go over the system default network (e.g.: a split-tunnel
// VPN, or an app disallowed by the VPN), so the set of networks
// returned includes the VPN's underlying networks and the system
// default.
enforceAccessPermission();
HashMap<Network, NetworkCapabilities> result = new HashMap<Network, NetworkCapabilities>();
NetworkAgentInfo nai = getDefaultNetwork();
NetworkCapabilities nc = getNetworkCapabilitiesInternal(nai);
if (nc != null) {
result.put(nai.network, nc);
}
if (!mLockdownEnabled) {
synchronized (mVpns) {
Vpn vpn = mVpns.get(userId);
if (vpn != null) {
Network[] networks = vpn.getUnderlyingNetworks();
if (networks != null) {
for (Network network : networks) {
nai = getNetworkAgentInfoForNetwork(network);
nc = getNetworkCapabilitiesInternal(nai);
if (nc != null) {
result.put(network, nc);
}
}
}
}
}
}
NetworkCapabilities[] out = new NetworkCapabilities[result.size()];
out = result.values().toArray(out);
return out;
}
Aggregations