From 9ef555a48ac600c8766f703fa60db15b69e20301 Mon Sep 17 00:00:00 2001 From: Peter Qiu Date: Fri, 10 Mar 2017 13:59:46 -0800 Subject: WifiConfigurationXmlUtil: persist additional fields for legacy Passpoint configuration When migrating legacy Passpoint configurations, the configuration will only get migrated when its owner logs in. In the meantime, we will need persist all the required data in the share store temporarily. So persist the additional required fields for Passpoint to the storage to avoid any data loss in the case when migration took multiple boots to complete. Bug: 36099588 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: manual test updating a device from N to O, verify all configs are migrated. Change-Id: I040dfd9f207ed1a9b2e3ccd50eca50560d6e1444 --- .../java/com/android/server/wifi/util/XmlUtil.java | 23 ++++++++++++++++++++++ .../server/wifi/NetworkListStoreDataTest.java | 6 ++++++ .../android/server/wifi/WifiConfigStoreTest.java | 2 ++ .../server/wifi/WifiConfigurationTestUtil.java | 1 + .../com/android/server/wifi/util/XmlUtilTest.java | 16 +++++++++++++++ 5 files changed, 48 insertions(+) diff --git a/service/java/com/android/server/wifi/util/XmlUtil.java b/service/java/com/android/server/wifi/util/XmlUtil.java index 76b8a3292..42303b009 100644 --- a/service/java/com/android/server/wifi/util/XmlUtil.java +++ b/service/java/com/android/server/wifi/util/XmlUtil.java @@ -336,6 +336,8 @@ public class XmlUtil { public static final String XML_TAG_LAST_UPDATE_UID = "LastUpdateUid"; public static final String XML_TAG_LAST_UPDATE_NAME = "LastUpdateName"; public static final String XML_TAG_LAST_CONNECT_UID = "LastConnectUid"; + public static final String XML_TAG_IS_LEGACY_PASSPOINT_CONFIG = "IsLegacyPasspointConfig"; + public static final String XML_TAG_ROAMING_CONSORTIUM_OIS = "RoamingConsortiumOIs"; /** * Write WepKeys to the XML stream. @@ -448,6 +450,11 @@ public class XmlUtil { XmlUtil.writeNextValue(out, XML_TAG_LAST_UPDATE_UID, configuration.lastUpdateUid); XmlUtil.writeNextValue(out, XML_TAG_LAST_UPDATE_NAME, configuration.lastUpdateName); XmlUtil.writeNextValue(out, XML_TAG_LAST_CONNECT_UID, configuration.lastConnectUid); + XmlUtil.writeNextValue( + out, XML_TAG_IS_LEGACY_PASSPOINT_CONFIG, + configuration.isLegacyPasspointConfig); + XmlUtil.writeNextValue( + out, XML_TAG_ROAMING_CONSORTIUM_OIS, configuration.roamingConsortiumIds); } /** @@ -598,6 +605,12 @@ public class XmlUtil { case XML_TAG_LAST_CONNECT_UID: configuration.lastConnectUid = (int) value; break; + case XML_TAG_IS_LEGACY_PASSPOINT_CONFIG: + configuration.isLegacyPasspointConfig = (boolean) value; + break; + case XML_TAG_ROAMING_CONSORTIUM_OIS: + configuration.roamingConsortiumIds = (long[]) value; + break; default: throw new XmlPullParserException( "Unknown value name found: " + valueName[0]); @@ -949,6 +962,8 @@ public class XmlUtil { public static final String XML_TAG_CA_PATH = "CaPath"; public static final String XML_TAG_EAP_METHOD = "EapMethod"; public static final String XML_TAG_PHASE2_METHOD = "Phase2Method"; + public static final String XML_TAG_PLMN = "PLMN"; + public static final String XML_TAG_REALM = "Realm"; /** * Write the WifiEnterpriseConfig data elements from the provided config to the XML @@ -985,6 +1000,8 @@ public class XmlUtil { enterpriseConfig.getFieldValue(WifiEnterpriseConfig.CA_PATH_KEY)); XmlUtil.writeNextValue(out, XML_TAG_EAP_METHOD, enterpriseConfig.getEapMethod()); XmlUtil.writeNextValue(out, XML_TAG_PHASE2_METHOD, enterpriseConfig.getPhase2Method()); + XmlUtil.writeNextValue(out, XML_TAG_PLMN, enterpriseConfig.getPlmn()); + XmlUtil.writeNextValue(out, XML_TAG_REALM, enterpriseConfig.getRealm()); } /** @@ -1060,6 +1077,12 @@ public class XmlUtil { case XML_TAG_PHASE2_METHOD: enterpriseConfig.setPhase2Method((int) value); break; + case XML_TAG_PLMN: + enterpriseConfig.setPlmn((String) value); + break; + case XML_TAG_REALM: + enterpriseConfig.setRealm((String) value); + break; default: throw new XmlPullParserException( "Unknown value name found: " + valueName[0]); diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java index 7532b7d31..01257c16e 100644 --- a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java @@ -83,6 +83,8 @@ public class NetworkListStoreDataTest { + "\n" + "\n" + "\n" + + "\n" + + "\n" + "\n" + "\n" + "NETWORK_SELECTION_ENABLED\n" @@ -131,6 +133,8 @@ public class NetworkListStoreDataTest { + "\n" + "\n" + "\n" + + "\n" + + "\n" + "\n" + "\n" + "NETWORK_SELECTION_ENABLED\n" @@ -158,6 +162,8 @@ public class NetworkListStoreDataTest { + "\n" + "\n" + "\n" + + "\n" + + "\n" + "\n" + "\n"; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java index 9b5af549f..47efed3c4 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java @@ -99,6 +99,8 @@ public class WifiConfigStoreTest { + "\n" + "\n" + "\n" + + "\n" + + "\n" + "\n" + "\n" + "NETWORK_SELECTION_ENABLED\n" diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java index 6b411dad5..917a64cc9 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java @@ -455,6 +455,7 @@ public class WifiConfigurationTestUtil { assertEquals(expected.lastUpdateName, actual.lastUpdateName); assertEquals(expected.lastConnectUid, actual.lastConnectUid); assertEquals(expected.updateTime, actual.updateTime); + assertEquals(expected.isLegacyPasspointConfig, actual.isLegacyPasspointConfig); assertNetworkSelectionStatusEqualForConfigStore( expected.getNetworkSelectionStatus(), actual.getNetworkSelectionStatus()); assertWifiEnterpriseConfigEqualForConfigStore( 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 fdb26e489..d61809882 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java @@ -396,6 +396,22 @@ public class XmlUtilTest { deserializeWifiEnterpriseConfig(xmlString.getBytes(StandardCharsets.UTF_8)); } + /** + * Verify that WifiConfiguration representation of a legacy Passpoint configuration is + * serialized & deserialized correctly. + * + *@throws Exception + */ + @Test + public void testLegacyPasspointConfigSerializeDeserialize() throws Exception { + WifiConfiguration config = WifiConfigurationTestUtil.createPasspointNetwork(); + config.isLegacyPasspointConfig = true; + config.roamingConsortiumIds = new long[] {0x12345678}; + config.enterpriseConfig.setPlmn("1234"); + config.enterpriseConfig.setRealm("test.com"); + serializeDeserializeWifiConfigurationForConfigStore(config); + } + private byte[] serializeWifiConfigurationForBackup(WifiConfiguration configuration) throws IOException, XmlPullParserException { final XmlSerializer out = new FastXmlSerializer(); -- cgit v1.2.3