diff options
author | Ecco Park <eccopark@google.com> | 2019-04-17 10:53:24 -0700 |
---|---|---|
committer | Ecco Park <eccopark@google.com> | 2019-04-17 15:33:04 -0700 |
commit | f61e141c8f344e9e92dfdc4203b7dee0762a8a09 (patch) | |
tree | c00581c9ebb58d07d27d2d25e3f27a891cda69a8 /tests | |
parent | 43c1e848f2b848a02738f3ccce7440c331e9262b (diff) |
PasspointNetworkEvaluator: Ignore networks disconnected by user.
WifiConfigManager maintains a blacklist of all ephemeral networks that
the user decided to disconnect. Avoid connecting back to them in all the
evaluators (already handled in suggestion & scored evaluators).
Bug: 130309348
Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: If72207b166b76bd32ad1bcfcd70fb069464d650f
Signed-off-by: Ecco Park <eccopark@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 34 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java | 25 |
2 files changed, 54 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index d21808981..2f73ca7f0 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -4415,8 +4415,7 @@ public class WifiConfigManagerTest { */ @Test public void testDisableEphemeralNetwork() throws Exception { - WifiConfiguration ephemeralNetwork = WifiConfigurationTestUtil.createOpenNetwork(); - ephemeralNetwork.ephemeral = true; + WifiConfiguration ephemeralNetwork = WifiConfigurationTestUtil.createEphemeralNetwork(); List<WifiConfiguration> networks = new ArrayList<>(); networks.add(ephemeralNetwork); @@ -4427,21 +4426,46 @@ public class WifiConfigManagerTest { WifiConfigurationTestUtil.assertConfigurationsEqualForConfigManagerAddOrUpdate( networks, retrievedNetworks); + verifyExpiryOfTimeout(ephemeralNetwork); + } + + /** + * Verifies the disconnection of Passpoint network using + * {@link WifiConfigManager#disableEphemeralNetwork(String)}. + */ + @Test + public void testDisablePasspointNetwork() throws Exception { + WifiConfiguration passpointNetwork = WifiConfigurationTestUtil.createPasspointNetwork(); + + verifyAddPasspointNetworkToWifiConfigManager(passpointNetwork); + + List<WifiConfiguration> networks = new ArrayList<>(); + networks.add(passpointNetwork); + + List<WifiConfiguration> retrievedNetworks = + mWifiConfigManager.getConfiguredNetworksWithPasswords(); + WifiConfigurationTestUtil.assertConfigurationsEqualForConfigManagerAddOrUpdate( + networks, retrievedNetworks); + + verifyExpiryOfTimeout(passpointNetwork); + } + + private void verifyExpiryOfTimeout(WifiConfiguration config) { // Disable the ephemeral network. long disableTimeMs = 546643L; long currentTimeMs = disableTimeMs; when(mClock.getWallClockMillis()).thenReturn(currentTimeMs); - mWifiConfigManager.disableEphemeralNetwork(ephemeralNetwork.SSID); + mWifiConfigManager.disableEphemeralNetwork(config.SSID); // Before the expiry of timeout. currentTimeMs = disableTimeMs + WifiConfigManager.DELETED_EPHEMERAL_SSID_EXPIRY_MS - 1; when(mClock.getWallClockMillis()).thenReturn(currentTimeMs); - assertTrue(mWifiConfigManager.wasEphemeralNetworkDeleted(ephemeralNetwork.SSID)); + assertTrue(mWifiConfigManager.wasEphemeralNetworkDeleted(config.SSID)); // After the expiry of timeout. currentTimeMs = disableTimeMs + WifiConfigManager.DELETED_EPHEMERAL_SSID_EXPIRY_MS + 1; when(mClock.getWallClockMillis()).thenReturn(currentTimeMs); - assertFalse(mWifiConfigManager.wasEphemeralNetworkDeleted(ephemeralNetwork.SSID)); + assertFalse(mWifiConfigManager.wasEphemeralNetworkDeleted(config.SSID)); } private NetworkUpdateResult verifyAddOrUpdateNetworkWithProxySettingsAndPermissions( diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java index 591db7d09..ce6aaf277 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkEvaluatorTest.java @@ -637,4 +637,29 @@ public class PasspointNetworkEvaluatorTest { anyInt()); verify(mOnConnectableListener, never()).onConnectable(any(), any(), anyInt()); } + + /** + * Verify that when a network matching a home provider is found, but the network was + * disconnected previously by user, it returns {@code null} for candidate. + */ + @Test + public void evaluateScanResultWithHomeMatchButPreviouslyUserDisconnected() { + List<ScanDetail> scanDetails = Arrays.asList(new ScanDetail[]{ + generateScanDetail(TEST_SSID1, TEST_BSSID1)}); + + // Setup matching providers for ScanDetail with TEST_SSID1. + Pair<PasspointProvider, PasspointMatch> homeProvider = Pair.create( + TEST_PROVIDER1, PasspointMatch.HomeProvider); + + // Return homeProvider for the first ScanDetail (TEST_SSID1). + when(mPasspointManager.matchProvider(any(ScanResult.class))).thenReturn(homeProvider); + when(mWifiConfigManager.addOrUpdateNetwork(any(WifiConfiguration.class), anyInt())) + .thenReturn(new NetworkUpdateResult(TEST_NETWORK_ID)); + when(mWifiConfigManager.getConfiguredNetwork(TEST_NETWORK_ID)).thenReturn(TEST_CONFIG1); + when(mWifiConfigManager.wasEphemeralNetworkDeleted("\"" + TEST_SSID1 + "\"")) + .thenReturn(true); + assertEquals(null, mEvaluator.evaluateNetworks( + scanDetails, null, null, false, false, mOnConnectableListener)); + verify(mOnConnectableListener, never()).onConnectable(any(), any(), anyInt()); + } } |