use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by AOSPA.
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 android_frameworks_base by AOSPA.
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_opt_telephony by LineageOS.
the class ConnectivityServiceMock method handleAsyncChannelDisconnected.
private void handleAsyncChannelDisconnected(Message msg) {
NetworkAgentInfo nai = mNetworkAgentInfos.get(msg.replyTo);
if (nai != null) {
if (DBG) {
log(nai.name() + " got DISCONNECTED, was satisfying " + nai.numNetworkRequests());
}
// A network agent has disconnected.
// TODO - if we move the logic to the network agent (have them disconnect
// because they lost all their requests or because their score isn't good)
// then they would disconnect organically, report their new state and then
// disconnect the channel.
// if (nai.networkInfo.isConnected()) {
// nai.networkInfo.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED,
// null, null);
// }
// final boolean wasDefault = isDefaultNetwork(nai);
// if (wasDefault) {
// mDefaultInetConditionPublished = 0;
// }
// notifyIfacesChanged();
// TODO - we shouldn't send CALLBACK_LOST to requests that can be satisfied
// by other networks that are already connected. Perhaps that can be done by
// sending all CALLBACK_LOST messages (for requests, not listens) at the end
// of rematchAllNetworksAndRequests
// notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_LOST);
// mKeepaliveTracker.handleStopAllKeepalives(nai,
// ConnectivityManager.PacketKeepalive.ERROR_INVALID_NETWORK);
nai.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_DISCONNECTED);
mNetworkAgentInfos.remove(msg.replyTo);
// updateClat(null, nai.linkProperties, nai);
// synchronized (mNetworkForNetId) {
// // Remove the NetworkAgent, but don't mark the netId as
// // available until we've told netd to delete it below.
// mNetworkForNetId.remove(nai.network.netId);
// }
// Remove all previously satisfied requests.
// for (int i = 0; i < nai.networkRequests.size(); i++) {
// NetworkRequest request = nai.networkRequests.valueAt(i);
// NetworkAgentInfo currentNetwork = mNetworkForRequestId.get(request.requestId);
// if (currentNetwork != null && currentNetwork.network.netId == nai.network.netId) {
// mNetworkForRequestId.remove(request.requestId);
// sendUpdatedScoreToFactories(request, 0);
// }
// }
// if (nai.networkRequests.get(mDefaultRequest.requestId) != null) {
// removeDataActivityTracking(nai);
// notifyLockdownVpn(nai);
// requestNetworkTransitionWakelock(nai.name());
// }
// mLegacyTypeTracker.remove(nai, wasDefault);
// rematchAllNetworksAndRequests(null, 0);
// if (nai.created) {
// // Tell netd to clean up the configuration for this network
// // (routing rules, DNS, etc).
// // This may be slow as it requires a lot of netd shelling out to ip and
// // ip[6]tables to flush routes and remove the incoming packet mark rule, so do it
// // after we've rematched networks with requests which should make a potential
// // fallback network the default or requested a new network from the
// // NetworkFactories, so network traffic isn't interrupted for an unnecessarily
// // long time.
// try {
// mNetd.removeNetwork(nai.network.netId);
// } catch (Exception e) {
// loge("Exception removing network: " + e);
// }
// }
// synchronized (mNetworkForNetId) {
// mNetIdInUse.delete(nai.network.netId);
// }
} else {
NetworkFactoryInfo nfi = mNetworkFactoryInfos.remove(msg.replyTo);
if (DBG && nfi != null)
log("unregisterNetworkFactory for " + nfi.name);
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_opt_telephony by LineageOS.
the class ConnectivityServiceMock method handleAsyncChannelHalfConnect.
private void handleAsyncChannelHalfConnect(Message msg) {
AsyncChannel ac = (AsyncChannel) msg.obj;
if (mNetworkFactoryInfos.containsKey(msg.replyTo)) {
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
if (VDBG)
log("NetworkFactory connected");
// A network factory has connected. Send it all current NetworkRequests.
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
if (nri.isRequest == false)
continue;
// NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
NetworkAgentInfo nai = null;
ac.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, (nai != null ? nai.getCurrentScore() : 0), 0, nri.request);
}
} else {
loge("Error connecting NetworkFactory");
mNetworkFactoryInfos.remove(msg.obj);
}
} else if (mNetworkAgentInfos.containsKey(msg.replyTo)) {
if (msg.arg1 == AsyncChannel.STATUS_SUCCESSFUL) {
if (VDBG)
log("NetworkAgent connected");
// A network agent has requested a connection. Establish the connection.
mNetworkAgentInfos.get(msg.replyTo).asyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
} else {
loge("Error connecting NetworkAgent");
NetworkAgentInfo nai = mNetworkAgentInfos.remove(msg.replyTo);
// if (nai != null) {
// final boolean wasDefault = isDefaultNetwork(nai);
// synchronized (mNetworkForNetId) {
// mNetworkForNetId.remove(nai.network.netId);
// mNetIdInUse.delete(nai.network.netId);
// }
// // Just in case.
// mLegacyTypeTracker.remove(nai, wasDefault);
// }
}
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_opt_telephony by LineageOS.
the class ConnectivityServiceMock method handleRegisterNetworkRequest.
private void handleRegisterNetworkRequest(NetworkRequestInfo nri) {
mNetworkRequests.put(nri.request, nri);
if (!nri.isRequest) {
for (NetworkAgentInfo network : mNetworkAgentInfos.values()) {
if (nri.request.networkCapabilities.hasSignalStrength() && network.satisfiesImmutableCapabilitiesOf(nri.request)) {
}
}
}
rematchAllNetworksAndRequests(null, 0);
if (nri.isRequest) {
sendUpdatedScoreToFactories(nri.request, 0);
}
}
Aggregations