diff options
author | Randy Pan <zpan@google.com> | 2017-04-03 12:52:18 -0700 |
---|---|---|
committer | Randy Pan <zpan@google.com> | 2017-04-03 16:57:33 -0700 |
commit | 5d0addadb370bcbb8900414fb9597bd415e6fea0 (patch) | |
tree | 2be20ca77da224e1b63e46e49ba3c2f769e253d9 /tests | |
parent | d44fca25d34d80d98c242423c3a5504a325553ab (diff) |
Update PNO scan network list upon network update
Add a listener interface in WifiConfigManager to notify events
such as network being enabled, disabled, blacklisted or
un-blacklisted.
WifiConnectivityManager listens to the above events and update
the PNO scan network list if necessary.
Bug: 30399964
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I75523a3a53ff62b14d485fd722354c4d6c3b18c1
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java | 9 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 951f8e114..b9a8266f4 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -109,6 +109,7 @@ public class WifiConfigManagerTest { @Mock private WifiPermissionsWrapper mWifiPermissionsWrapper; @Mock private NetworkListStoreData mNetworkListStoreData; @Mock private DeletedEphemeralSsidsStoreData mDeletedEphemeralSsidsStoreData; + @Mock private WifiConfigManager.OnSavedNetworkUpdateListener mWcmListener; private MockResources mResources; private InOrder mContextConfigStoreMockOrder; @@ -177,6 +178,7 @@ public class WifiConfigManagerTest { when(mWifiPermissionsWrapper.getDevicePolicyManagerInternal()) .thenReturn(mDevicePolicyManagerInternal); createWifiConfigManager(); + mWifiConfigManager.setOnSavedNetworkUpdateListener(mWcmListener); } /** @@ -240,6 +242,7 @@ public class WifiConfigManagerTest { mWifiConfigManager.getConfiguredNetworksWithPasswords(); WifiConfigurationTestUtil.assertConfigurationsEqualForConfigManagerAddOrUpdate( networks, retrievedNetworks); + verify(mWcmListener, times(2)).onSavedNetworkUpdate(); } /** @@ -263,6 +266,7 @@ public class WifiConfigManagerTest { // Ensure that this is not returned in the saved network list. assertTrue(mWifiConfigManager.getSavedNetworks().isEmpty()); + verify(mWcmListener, never()).onSavedNetworkUpdate(); } /** @@ -440,6 +444,7 @@ public class WifiConfigManagerTest { verifyRemoveNetworkFromWifiConfigManager(openNetwork); // Ensure that configured network list is empty now. assertTrue(mWifiConfigManager.getConfiguredNetworks().isEmpty()); + verify(mWcmListener, times(2)).onSavedNetworkUpdate(); } /** @@ -458,6 +463,7 @@ public class WifiConfigManagerTest { verifyRemoveEphemeralNetworkFromWifiConfigManager(ephemeralNetwork); // Ensure that configured network list is empty now. assertTrue(mWifiConfigManager.getConfiguredNetworks().isEmpty()); + verify(mWcmListener, never()).onSavedNetworkUpdate(); } /** @@ -475,6 +481,7 @@ public class WifiConfigManagerTest { verifyRemovePasspointNetworkFromWifiConfigManager(passpointNetwork); // Ensure that configured network list is empty now. assertTrue(mWifiConfigManager.getConfiguredNetworks().isEmpty()); + verify(mWcmListener, never()).onSavedNetworkUpdate(); } /** @@ -582,10 +589,12 @@ public class WifiConfigManagerTest { // Now set it to permanently disabled. verifyUpdateNetworkSelectionStatus( result.getNetworkId(), NetworkSelectionStatus.DISABLED_BY_WIFI_MANAGER, 0); + verify(mWcmListener, times(3)).onSavedNetworkUpdate(); // Now set it back to enabled. verifyUpdateNetworkSelectionStatus( result.getNetworkId(), NetworkSelectionStatus.NETWORK_SELECTION_ENABLE, 0); + verify(mWcmListener, times(4)).onSavedNetworkUpdate(); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 55438449e..68c2ca359 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -87,6 +87,7 @@ public class WifiConnectivityManagerTest { mWifiConnectivityHelper = mockWifiConnectivityHelper(); mWifiNS = mockWifiNetworkSelector(); mWifiConnectivityManager = createConnectivityManager(); + verify(mWifiConfigManager).setOnSavedNetworkUpdateListener(anyObject()); mWifiConnectivityManager.setWifiEnabled(true); when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime()); } |