diff options
author | Roshan Pius <rpius@google.com> | 2016-06-08 14:04:53 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2016-06-09 13:35:41 -0700 |
commit | 2fafcc56fda54b1adf8b6743beaac59dbb84dfec (patch) | |
tree | c1a4dd8874f269c2893f7c1fdd32c5e63e1687f8 /tests | |
parent | d8ee2a06475a6d437df11a8c6eeb3138dc384afe (diff) |
WifiBackupRestore: Handle network UIDs
Don't save creatorUID element for backup/restore. All networks will be
restored with the System UID set as the creatorUID. The creator UID is
hard to preserve across backup/restore.
Also, since the creatorUID is not being backed, there are genuine cases
where the configKey mismatch might occur. So, move the |configKey|
mismatch check out of |XmlUtil| and let backup/restore & config store
handle it differently as needed.
PS: Need to also figure out if we should stop backing up all networks
not saved by settings agent (creatorUid != SYSTEM_UD). Will wait for
discussions in b/29201888 to decide on that.
BUG: 29201888
TEST: Unit-tests
Change-Id: I668281893de9260a803872c04646b5af28ee45e5
Diffstat (limited to 'tests')
3 files changed, 35 insertions, 10 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java index 0ca9eab15..c813cfaf6 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java @@ -775,7 +775,7 @@ public class WifiBackupRestoreTest { for (WifiConfiguration actualConfiguration : actual) { String actualConfigKey = actualConfiguration.configKey(); if (actualConfigKey.equals(expectedConfigKey)) { - WifiConfigurationTestUtil.assertConfigurationEqual( + WifiConfigurationTestUtil.assertConfigurationEqualForBackup( expectedConfiguration, actualConfiguration); didCompare = true; } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java index 85fe81b58..a7e47ffae 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java @@ -96,9 +96,10 @@ public class WifiConfigurationTestUtil { } /** - * Asserts that the 2 WifiConfigurations are equal + * Asserts that the 2 WifiConfigurations are equal in the elements saved for both backup/restore + * and config store. */ - public static void assertConfigurationEqual( + private static void assertCommonConfigurationElementsEqual( WifiConfiguration expected, WifiConfiguration actual) { assertEquals(expected.SSID, actual.SSID); assertEquals(expected.BSSID, actual.BSSID); @@ -110,7 +111,26 @@ public class WifiConfigurationTestUtil { assertEquals(expected.allowedProtocols, actual.allowedProtocols); assertEquals(expected.allowedAuthAlgorithms, actual.allowedAuthAlgorithms); assertEquals(expected.shared, actual.shared); - assertEquals(expected.creatorUid, actual.creatorUid); assertEquals(expected.getIpConfiguration(), actual.getIpConfiguration()); } + + /** + * Asserts that the 2 WifiConfigurations are equal. This only compares the elements saved + * fpr backup/restore. + */ + public static void assertConfigurationEqualForBackup( + WifiConfiguration expected, WifiConfiguration actual) { + assertCommonConfigurationElementsEqual(expected, actual); + } + + /** + * Asserts that the 2 WifiConfigurations are equal. This compares all the elements saved for + * config store. + */ + public static void assertConfigurationEqualForConfigStore( + WifiConfiguration expected, WifiConfiguration actual) { + assertCommonConfigurationElementsEqual(expected, actual); + assertEquals(expected.creatorUid, actual.creatorUid); + assertEquals(expected.creatorName, actual.creatorName); + } } 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 fd07ab2c1..d53c51384 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/XmlUtilTest.java @@ -23,6 +23,7 @@ import android.net.ProxyInfo; import android.net.StaticIpConfiguration; import android.net.wifi.WifiConfiguration; import android.test.suitebuilder.annotation.SmallTest; +import android.util.Pair; import android.util.Xml; import com.android.internal.util.FastXmlSerializer; @@ -286,7 +287,7 @@ public class XmlUtilTest { return outputStream.toByteArray(); } - private WifiConfiguration deserializeWifiConfiguration(byte[] data) + private Pair<String, WifiConfiguration> deserializeWifiConfiguration(byte[] data) throws IOException, XmlPullParserException { // Deserialize the configuration object. final XmlPullParser in = Xml.newPullParser(); @@ -301,18 +302,22 @@ public class XmlUtilTest { */ private void serializeDeserializeWifiConfiguration(WifiConfiguration configuration) throws IOException, XmlPullParserException { - WifiConfiguration retrievedConfiguration; + Pair<String, WifiConfiguration> retrieved; // Test serialization/deserialization for backup first. - retrievedConfiguration = + retrieved = deserializeWifiConfiguration( serializeWifiConfigurationForBackup(configuration)); - WifiConfigurationTestUtil.assertConfigurationEqual(configuration, retrievedConfiguration); + assertEquals(retrieved.first, retrieved.second.configKey()); + WifiConfigurationTestUtil.assertConfigurationEqualForBackup( + configuration, retrieved.second); // Test serialization/deserialization for config store. - retrievedConfiguration = + retrieved = deserializeWifiConfiguration( serializeWifiConfigurationForConfigStore(configuration)); - WifiConfigurationTestUtil.assertConfigurationEqual(configuration, retrievedConfiguration); + assertEquals(retrieved.first, retrieved.second.configKey()); + WifiConfigurationTestUtil.assertConfigurationEqualForConfigStore( + configuration, retrieved.second); } private void serializeDeserializeIpConfiguration(IpConfiguration configuration) |