use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by ResurrectionRemix.
the class ConnectivityService method registerNetworkAgent.
public int registerNetworkAgent(Messenger messenger, NetworkInfo networkInfo, LinkProperties linkProperties, NetworkCapabilities networkCapabilities, int currentScore, NetworkMisc networkMisc) {
enforceConnectivityInternalPermission();
// TODO: Instead of passing mDefaultRequest, provide an API to determine whether a Network
// satisfies mDefaultRequest.
final NetworkAgentInfo nai = new NetworkAgentInfo(messenger, new AsyncChannel(), new Network(reserveNetId()), new NetworkInfo(networkInfo), new LinkProperties(linkProperties), new NetworkCapabilities(networkCapabilities), currentScore, mContext, mTrackerHandler, new NetworkMisc(networkMisc), mDefaultRequest, this);
synchronized (this) {
nai.networkMonitor.systemReady = mSystemReady;
}
addValidationLogs(nai.networkMonitor.getValidationLogs(), nai.network, networkInfo.getExtraInfo());
if (DBG)
log("registerNetworkAgent " + nai);
mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai));
return nai.network.netId;
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by ResurrectionRemix.
the class ConnectivityService method dumpAvoidBadWifiSettings.
// TODO: Evaluate whether this is of interest to other consumers of
// AvoidBadWifiTracker and worth moving out of here.
private void dumpAvoidBadWifiSettings(IndentingPrintWriter pw) {
final boolean configRestrict = mAvoidBadWifiTracker.configRestrictsAvoidBadWifi();
if (!configRestrict) {
pw.println("Bad Wi-Fi avoidance: unrestricted");
return;
}
pw.println("Bad Wi-Fi avoidance: " + avoidBadWifi());
pw.increaseIndent();
pw.println("Config restrict: " + configRestrict);
final String value = mAvoidBadWifiTracker.getSettingsValue();
String description;
// Can't use a switch statement because strings are legal case labels, but null is not.
if ("0".equals(value)) {
description = "get stuck";
} else if (value == null) {
description = "prompt";
} else if ("1".equals(value)) {
description = "avoid";
} else {
description = value + " (?)";
}
pw.println("User setting: " + description);
pw.println("Network overrides:");
pw.increaseIndent();
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
if (nai.avoidUnvalidated) {
pw.println(nai.name());
}
}
pw.decreaseIndent();
pw.decreaseIndent();
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by ResurrectionRemix.
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 android_frameworks_base by ResurrectionRemix.
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);
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by ResurrectionRemix.
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);
}
}
Aggregations