diff options
author | Roshan Pius <rpius@google.com> | 2016-07-27 11:41:26 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2016-07-27 13:48:04 -0700 |
commit | a063576ca089dcc6341372c30dd1bf0a7ca82efa (patch) | |
tree | 9e67ea5478ee5022aceb3322cc1bf30ae4bb7d04 /tests | |
parent | 1d780915a0f00d23a81e19b2157d1b16463e09b6 (diff) |
WifiBackupRestore: Ignore non system created networks
Changes in the CL:
1. For new backup data, ignore networks non system app networks
during backup data generation.
2. For older wpa_supplicant.conf backup data, ignore non system
app networks during backup data restoration.
BUG: 29201888
Change-Id: Ie22a8f6d5eae03b01edf1420e2b8d3db5979449a
TEST: Unit tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java index c17f2aeb1..29e8fce19 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.*; import static org.mockito.Mockito.*; import android.net.wifi.WifiConfiguration; +import android.os.Process; import android.test.suitebuilder.annotation.SmallTest; import com.android.server.net.IpConfigStore; @@ -343,6 +344,44 @@ public class WifiBackupRestoreTest { } /** + * Verify that multiple networks of different types except the non system app created ones are + * serialized and deserialized correctly. + */ + @Test + public void testMultipleNetworksSystemAppBackupRestore() { + List<WifiConfiguration> configurations = new ArrayList<>(); + List<WifiConfiguration> expectedConfigurations = new ArrayList<>(); + + WifiConfiguration wepNetwork = WifiConfigurationTestUtil.createWepNetwork(); + configurations.add(wepNetwork); + expectedConfigurations.add(wepNetwork); + + // These should not be in |expectedConfigurations|. + WifiConfiguration nonSystemAppWepNetwork = WifiConfigurationTestUtil.createWepNetwork(); + nonSystemAppWepNetwork.creatorUid = Process.FIRST_APPLICATION_UID; + configurations.add(nonSystemAppWepNetwork); + + WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork(); + configurations.add(pskNetwork); + expectedConfigurations.add(pskNetwork); + + // These should not be in |expectedConfigurations|. + WifiConfiguration nonSystemAppPskNetwork = WifiConfigurationTestUtil.createPskNetwork(); + nonSystemAppPskNetwork.creatorUid = Process.FIRST_APPLICATION_UID + 1; + configurations.add(nonSystemAppPskNetwork); + + WifiConfiguration openNetwork = WifiConfigurationTestUtil.createOpenNetwork(); + configurations.add(openNetwork); + expectedConfigurations.add(openNetwork); + + byte[] backupData = mWifiBackupRestore.retrieveBackupDataFromConfigurations(configurations); + List<WifiConfiguration> retrievedConfigurations = + mWifiBackupRestore.retrieveConfigurationsFromBackupData(backupData); + WifiConfigurationTestUtil.assertConfigurationsEqualForBackup( + expectedConfigurations, retrievedConfigurations); + } + + /** * Verify that a single open network configuration is serialized & deserialized correctly from * old backups. */ @@ -541,6 +580,46 @@ public class WifiBackupRestoreTest { } /** + * Verify that multiple networks of different types except the non system app created ones are + * serialized and deserialized correctly from old backups. + */ + @Test + public void testMultipleNetworksSystemAppSupplicantBackupRestore() { + List<WifiConfiguration> configurations = new ArrayList<>(); + List<WifiConfiguration> expectedConfigurations = new ArrayList<>(); + + WifiConfiguration wepNetwork = WifiConfigurationTestUtil.createWepNetwork(); + configurations.add(wepNetwork); + expectedConfigurations.add(wepNetwork); + + // These should not be in |expectedConfigurations|. + WifiConfiguration nonSystemAppWepNetwork = WifiConfigurationTestUtil.createWepNetwork(); + nonSystemAppWepNetwork.creatorUid = Process.FIRST_APPLICATION_UID; + configurations.add(nonSystemAppWepNetwork); + + WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork(); + configurations.add(pskNetwork); + expectedConfigurations.add(pskNetwork); + + // These should not be in |expectedConfigurations|. + WifiConfiguration nonSystemAppPskNetwork = WifiConfigurationTestUtil.createPskNetwork(); + nonSystemAppPskNetwork.creatorUid = Process.FIRST_APPLICATION_UID + 1; + configurations.add(nonSystemAppPskNetwork); + + WifiConfiguration openNetwork = WifiConfigurationTestUtil.createOpenNetwork(); + configurations.add(openNetwork); + expectedConfigurations.add(openNetwork); + + byte[] supplicantData = createWpaSupplicantConfBackupData(configurations); + byte[] ipConfigData = createIpConfBackupData(configurations); + List<WifiConfiguration> retrievedConfigurations = + mWifiBackupRestore.retrieveConfigurationsFromSupplicantBackupData( + supplicantData, ipConfigData); + WifiConfigurationTestUtil.assertConfigurationsEqualForBackup( + expectedConfigurations, retrievedConfigurations); + } + + /** * Verify that any corrupted data provided by Backup/Restore is ignored correctly. */ @Test |