Fix configured network status
For a connected network, keep status as CURRENT. For a network,
that is disconnected it should be ENABLED. A disabled network
will have the status as DISABLED
Also, add a unit test to ensure there is only one CURRENT network
that is connected
Change-Id: Iaa4a7124a0c372a8f6df3d846ae8c15d9b29cf13
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiClientTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiClientTest.java
index e22b018..e44023b 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiClientTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiClientTest.java
@@ -271,4 +271,46 @@
}
+ // Test case 6: test configured network status
+ @LargeTest
+ public void testWifiConfiguredNetworkStatus() {
+
+ /* Initialize */
+ mWifiManager.setWifiEnabled(false);
+ sleepAfterWifiEnable();
+
+ /* Ensure no network is CURRENT */
+ List<WifiConfiguration> configList = mWifiManager.getConfiguredNetworks();
+ for (WifiConfiguration c : configList) {
+ assertTrue(c.status != WifiConfiguration.Status.CURRENT);
+ }
+
+ /* Enable wifi */
+ mWifiManager.setWifiEnabled(true);
+ sleepAfterWifiEnable();
+
+ /* Ensure connected network is CURRENT */
+ String connectedSSID = mWifiManager.getConnectionInfo().getSSID();
+ configList = mWifiManager.getConfiguredNetworks();
+ for (WifiConfiguration c : configList) {
+ if (c.SSID.contains(connectedSSID)) {
+ assertTrue(c.status == WifiConfiguration.Status.CURRENT);
+ } else {
+ assertTrue(c.status != WifiConfiguration.Status.CURRENT);
+ }
+ }
+
+ /* Disable wifi */
+ mWifiManager.setWifiEnabled(false);
+ sleepAfterWifiEnable();
+
+ /* Ensure no network is CURRENT */
+ configList = mWifiManager.getConfiguredNetworks();
+ for (WifiConfiguration c : configList) {
+ assertTrue(c.status != WifiConfiguration.Status.CURRENT);
+ }
+ }
+
+
+
}