use of android.net.Network in project android_frameworks_base by crdroidandroid.
the class OSUManager method wnmRemediate.
// !!! Consistently check passpoint match.
// !!! Convert to a one-thread thread-pool
public void wnmRemediate(long bssid, String url, PasspointMatch match) throws IOException, SAXException {
WifiConfiguration config = mWifiNetworkAdapter.getActiveWifiConfig();
HomeSP homeSP = MOManager.buildSP(config.getMoTree());
if (homeSP == null) {
throw new IOException("Remediation request for unidentified Passpoint network " + config.networkId);
}
Network network = mWifiNetworkAdapter.getCurrentNetwork();
if (network == null) {
throw new IOException("Failed to determine current network");
}
WifiInfo wifiInfo = mWifiNetworkAdapter.getConnectionInfo();
if (wifiInfo == null || Utils.parseMac(wifiInfo.getBSSID()) != bssid) {
throw new IOException("Mismatching BSSID");
}
Log.d(TAG, "WNM Remediation on " + network.netId + " FQDN " + homeSP.getFQDN());
doRemediate(url, network, homeSP, false);
}
use of android.net.Network in project android_frameworks_base by AOSPA.
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 android.net.Network in project android_frameworks_base by AOSPA.
the class NetworkTest method testZeroIsObviousForDebugging.
@SmallTest
public void testZeroIsObviousForDebugging() {
Network zero = new Network(0);
assertEquals(0, zero.hashCode());
assertEquals(0, zero.getNetworkHandle());
assertEquals("0", zero.toString());
}
use of android.net.Network in project android_frameworks_base by AOSPA.
the class ConnectivityService method getAllNetworkState.
@Override
public NetworkState[] getAllNetworkState() {
// Require internal since we're handing out IMSI details
enforceConnectivityInternalPermission();
final ArrayList<NetworkState> result = Lists.newArrayList();
for (Network network : getAllNetworks()) {
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
if (nai != null) {
result.add(nai.getNetworkState());
}
}
return result.toArray(new NetworkState[result.size()]);
}
use of android.net.Network in project NetGuard by M66B.
the class Util method getDefaultDNS.
public static List<String> getDefaultDNS(Context context) {
String dns1 = null;
String dns2 = null;
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.N) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Network an = cm.getActiveNetwork();
if (an != null) {
LinkProperties lp = cm.getLinkProperties(an);
if (lp != null) {
List<InetAddress> dns = lp.getDnsServers();
if (dns != null) {
if (dns.size() > 0)
dns1 = dns.get(0).getHostAddress();
if (dns.size() > 1)
dns2 = dns.get(1).getHostAddress();
for (InetAddress d : dns) Log.i(TAG, "DNS from LP: " + d.getHostAddress());
}
}
}
} else {
dns1 = jni_getprop("net.dns1");
dns2 = jni_getprop("net.dns2");
}
List<String> listDns = new ArrayList<>();
listDns.add(TextUtils.isEmpty(dns1) ? "8.8.8.8" : dns1);
listDns.add(TextUtils.isEmpty(dns2) ? "8.8.4.4" : dns2);
return listDns;
}
Aggregations