summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-04-01 00:05:38 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-04-01 00:05:38 +0000
commit08e67125d8b18ebc16537a67f5857a79294420f7 (patch)
treeecfbb0736423f726052f5df940332091af045735
parentb687f772eacbc984f5ac4a46e19cacaebde84f4e (diff)
parentd44fca25d34d80d98c242423c3a5504a325553ab (diff)
XmlUtil: Restore networks with CURRENT status as ENABLED
am: d44fca25d3 Change-Id: Ibca1e7383d599e1e966a8ee54828759aed26015d
-rw-r--r--service/java/com/android/server/wifi/util/XmlUtil.java12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java15
2 files changed, 26 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/util/XmlUtil.java b/service/java/com/android/server/wifi/util/XmlUtil.java
index 42303b009..853136b90 100644
--- a/service/java/com/android/server/wifi/util/XmlUtil.java
+++ b/service/java/com/android/server/wifi/util/XmlUtil.java
@@ -59,6 +59,10 @@ import java.util.HashMap;
* </Sub Section 1 Header>
* </Section 1 Header>
* </Document Header>
+ *
+ * Note: These utility methods are meant to be used for:
+ * 1. Backup/restore wifi network data to/from cloud.
+ * 2. Persisting wifi network data to/from disk.
*/
public class XmlUtil {
private static final String TAG = "WifiXmlUtil";
@@ -555,7 +559,13 @@ public class XmlUtil {
configuration.shared = (boolean) value;
break;
case XML_TAG_STATUS:
- configuration.status = (int) value;
+ int status = (int) value;
+ // Any network which was CURRENT before reboot needs
+ // to be restored to ENABLED.
+ if (status == WifiConfiguration.Status.CURRENT) {
+ status = WifiConfiguration.Status.ENABLED;
+ }
+ configuration.status = status;
break;
case XML_TAG_FQDN:
configuration.FQDN = (String) value;
diff --git a/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java
index d61809882..0942b8328 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java
@@ -212,6 +212,21 @@ public class XmlUtilTest {
}
/**
+ * Verify that a WifiConfiguration with status as CURRENT when serializing
+ * is deserialized as ENABLED.
+ */
+ @Test
+ public void testCurrentStatusConfigurationSerializeDeserializeForConfigStore()
+ throws IOException, XmlPullParserException {
+ WifiConfiguration configuration = WifiConfigurationTestUtil.createEapNetwork();
+ configuration.status = WifiConfiguration.Status.CURRENT;
+ byte[] xmlData = serializeWifiConfigurationForConfigStore(configuration);
+ Pair<String, WifiConfiguration> deserializedConfiguration =
+ deserializeWifiConfiguration(xmlData);
+ assertEquals(WifiConfiguration.Status.ENABLED, deserializedConfiguration.second.status);
+ }
+
+ /**
* Verify that an enabled network selection status object is serialized & deserialized
* correctly.
*/