Search in sources :

Example 81 with Network

use of android.net.Network in project android_frameworks_base by ResurrectionRemix.

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);
}
Also used : HomeSP(com.android.hotspot2.pps.HomeSP) WifiConfiguration(android.net.wifi.WifiConfiguration) Network(android.net.Network) IOException(java.io.IOException) WifiInfo(android.net.wifi.WifiInfo)

Example 82 with Network

use of android.net.Network in project android_frameworks_base by ResurrectionRemix.

the class NetdEventListenerServiceTest method testConcurrentDnsBatchesAndNetworkLoss.

@SmallTest
public void testConcurrentDnsBatchesAndNetworkLoss() throws Exception {
    logDnsAsync(105, LATENCIES);
    Thread.sleep(10L);
    // call onLost() asynchronously to logDnsAsync's onDnsEvent() calls.
    mCallbackCaptor.getValue().onLost(new Network(105));
    // do not verify unpredictable batch
    verify(mLog, timeout(500).times(1)).log(any());
}
Also used : Network(android.net.Network) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 83 with Network

use of android.net.Network in project android_frameworks_base by ResurrectionRemix.

the class NetdEventListenerServiceTest method testDnsBatchAndNetworkLost.

@SmallTest
public void testDnsBatchAndNetworkLost() throws Exception {
    byte[] eventTypes = Arrays.copyOf(EVENT_TYPES, 20);
    byte[] returnCodes = Arrays.copyOf(RETURN_CODES, 20);
    int[] latencies = Arrays.copyOf(LATENCIES, 20);
    log(105, LATENCIES);
    log(105, latencies);
    mCallbackCaptor.getValue().onLost(new Network(105));
    log(105, LATENCIES);
    verifyLoggedDnsEvents(new DnsEvent(105, eventTypes, returnCodes, latencies), new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES), new DnsEvent(105, EVENT_TYPES, RETURN_CODES, LATENCIES));
}
Also used : Network(android.net.Network) DnsEvent(android.net.metrics.DnsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 84 with Network

use of android.net.Network in project android_frameworks_base by ResurrectionRemix.

the class NetworkTest method testGetNetworkHandle.

@SmallTest
public void testGetNetworkHandle() {
    Network one = new Network(1);
    Network two = new Network(2);
    Network three = new Network(3);
    // None of the hashcodes are zero.
    assertNotEqual(0, one.hashCode());
    assertNotEqual(0, two.hashCode());
    assertNotEqual(0, three.hashCode());
    // All the hashcodes are distinct.
    assertNotEqual(one.hashCode(), two.hashCode());
    assertNotEqual(one.hashCode(), three.hashCode());
    assertNotEqual(two.hashCode(), three.hashCode());
    // None of the handles are zero.
    assertNotEqual(0, one.getNetworkHandle());
    assertNotEqual(0, two.getNetworkHandle());
    assertNotEqual(0, three.getNetworkHandle());
    // All the handles are distinct.
    assertNotEqual(one.getNetworkHandle(), two.getNetworkHandle());
    assertNotEqual(one.getNetworkHandle(), three.getNetworkHandle());
    assertNotEqual(two.getNetworkHandle(), three.getNetworkHandle());
    // The handles are not equal to the hashcodes.
    assertNotEqual(one.hashCode(), one.getNetworkHandle());
    assertNotEqual(two.hashCode(), two.getNetworkHandle());
    assertNotEqual(three.hashCode(), three.getNetworkHandle());
    // Adjust as necessary to test an implementation's specific constants.
    // When running with runtest, "adb logcat -s TestRunner" can be useful.
    assertEquals(4311403230L, one.getNetworkHandle());
    assertEquals(8606370526L, two.getNetworkHandle());
    assertEquals(12901337822L, three.getNetworkHandle());
}
Also used : Network(android.net.Network) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 85 with Network

use of android.net.Network in project android_frameworks_base by DirtyUnicorns.

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);
}
Also used : HomeSP(com.android.hotspot2.pps.HomeSP) WifiConfiguration(android.net.wifi.WifiConfiguration) Network(android.net.Network) IOException(java.io.IOException) WifiInfo(android.net.wifi.WifiInfo)

Aggregations

Network (android.net.Network)92 SmallTest (android.test.suitebuilder.annotation.SmallTest)28 NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)25 NetworkCapabilities (android.net.NetworkCapabilities)22 NetworkRequest (android.net.NetworkRequest)18 NetworkInfo (android.net.NetworkInfo)17 LinkProperties (android.net.LinkProperties)16 ConnectivityManager (android.net.ConnectivityManager)11 NetworkCallback (android.net.ConnectivityManager.NetworkCallback)11 Test (org.junit.Test)7 InetAddress (java.net.InetAddress)6 Nullable (android.annotation.Nullable)5 NetworkMisc (android.net.NetworkMisc)5 NetworkState (android.net.NetworkState)5 WifiConfiguration (android.net.wifi.WifiConfiguration)5 WifiInfo (android.net.wifi.WifiInfo)5 ConditionVariable (android.os.ConditionVariable)5 WebSettings (android.webkit.WebSettings)5 HomeSP (com.android.hotspot2.pps.HomeSP)5 LegacyVpnInfo (com.android.internal.net.LegacyVpnInfo)5