use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by AOSPA.
the class ConnectivityService method getProxyForNetwork.
@Override
public ProxyInfo getProxyForNetwork(Network network) {
if (network == null)
return getDefaultProxy();
final ProxyInfo globalProxy = getGlobalProxy();
if (globalProxy != null)
return globalProxy;
if (!NetworkUtils.queryUserAccess(Binder.getCallingUid(), network.netId))
return null;
// Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which
// caller may not have.
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
if (nai == null)
return null;
synchronized (nai) {
final ProxyInfo proxyInfo = nai.linkProperties.getHttpProxy();
if (proxyInfo == null)
return null;
return new ProxyInfo(proxyInfo);
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by AOSPA.
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);
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by AOSPA.
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 android_frameworks_base by AOSPA.
the class ConnectivityService method getLinkPropertiesForType.
@Override
public LinkProperties getLinkPropertiesForType(int networkType) {
enforceAccessPermission();
NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
if (nai != null) {
synchronized (nai) {
return new LinkProperties(nai.linkProperties);
}
}
return null;
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by AOSPA.
the class ConnectivityService method rematchAllNetworksAndRequests.
/**
* Attempt to rematch all Networks with NetworkRequests. This may result in Networks
* being disconnected.
* @param changed If only one Network's score or capabilities have been modified since the last
* time this function was called, pass this Network in this argument, otherwise pass
* null.
* @param oldScore If only one Network has been changed but its NetworkCapabilities have not
* changed, pass in the Network's score (from getCurrentScore()) prior to the change via
* this argument, otherwise pass {@code changed.getCurrentScore()} or 0 if
* {@code changed} is {@code null}. This is because NetworkCapabilities influence a
* network's score.
*/
private void rematchAllNetworksAndRequests(NetworkAgentInfo changed, int oldScore) {
// TODO: This may get slow. The "changed" parameter is provided for future optimization
// to avoid the slowness. It is not simply enough to process just "changed", for
// example in the case where "changed"'s score decreases and another network should begin
// satifying a NetworkRequest that "changed" currently satisfies.
// Optimization: Only reprocess "changed" if its score improved. This is safe because it
// can only add more NetworkRequests satisfied by "changed", and this is exactly what
// rematchNetworkAndRequests() handles.
final long now = SystemClock.elapsedRealtime();
if (changed != null && oldScore < changed.getCurrentScore()) {
rematchNetworkAndRequests(changed, ReapUnvalidatedNetworks.REAP, now);
} else {
final NetworkAgentInfo[] nais = mNetworkAgentInfos.values().toArray(new NetworkAgentInfo[mNetworkAgentInfos.size()]);
// Rematch higher scoring networks first to prevent requests first matching a lower
// scoring network and then a higher scoring network, which could produce multiple
// callbacks and inadvertently unlinger networks.
Arrays.sort(nais);
for (NetworkAgentInfo nai : nais) {
rematchNetworkAndRequests(nai, // rematched.
(nai != nais[nais.length - 1]) ? ReapUnvalidatedNetworks.DONT_REAP : ReapUnvalidatedNetworks.REAP, now);
}
}
}
Aggregations