use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by DirtyUnicorns.
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;
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by DirtyUnicorns.
the class ConnectivityService method getUnfilteredActiveNetworkState.
private NetworkState getUnfilteredActiveNetworkState(int uid) {
NetworkAgentInfo nai = getDefaultNetwork();
final Network[] networks = getVpnUnderlyingNetworks(uid);
if (networks != null) {
// first one.
if (networks.length > 0) {
nai = getNetworkAgentInfoForNetwork(networks[0]);
} else {
nai = null;
}
}
if (nai != null) {
return nai.getNetworkState();
} else {
return NetworkState.EMPTY;
}
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class ConnectivityService method updateDnses.
private void updateDnses(LinkProperties newLp, LinkProperties oldLp, int netId) {
if (oldLp != null && newLp.isIdenticalDnses(oldLp)) {
// no updating necessary
return;
}
Collection<InetAddress> dnses = newLp.getDnsServers();
if (DBG)
log("Setting DNS servers for network " + netId + " to " + dnses);
try {
mNetd.setDnsConfigurationForNetwork(netId, NetworkUtils.makeStrings(dnses), newLp.getDomains());
} catch (Exception e) {
loge("Exception in setDnsConfigurationForNetwork: " + e);
}
final NetworkAgentInfo defaultNai = getDefaultNetwork();
if (defaultNai != null && defaultNai.network.netId == netId) {
setDefaultDnsSystemProperties(dnses);
}
flushVmDnsCache();
}
use of com.android.server.connectivity.NetworkAgentInfo in project android_frameworks_base by DirtyUnicorns.
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);
}
Aggregations