From 0df9f8946fbfef556a8cc59deb8b52d4fbb7ae7a Mon Sep 17 00:00:00 2001 From: lesl Date: Mon, 9 Mar 2020 18:39:27 +0800 Subject: wifi: Add bssid in SoftAp Store Bug: 151060474 Test: atest frameworks/opt/net/wifi/tests/wifitests/ Change-Id: Ic92cf088779bf4f6795e0bfa19a4b01d90dfd6be --- .../android/server/wifi/SoftApStoreDataTest.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java index 9726882ee..e03f41048 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java @@ -63,6 +63,7 @@ import java.util.ArrayList; @SmallTest public class SoftApStoreDataTest extends WifiBaseTest { private static final String TEST_SSID = "SSID"; + private static final String TEST_BSSID = "11:22:33:aa:bb:cc"; private static final String TEST_PASSPHRASE = "TestPassphrase"; private static final String TEST_WPA2_PASSPHRASE = "Wpa2Test"; private static final int TEST_CHANNEL = 0; @@ -98,6 +99,7 @@ public class SoftApStoreDataTest extends WifiBaseTest { private static final String TEST_SOFTAP_CONFIG_XML_STRING_WITH_ALL_CONFIG = "" + TEST_SSID + "\n" + + "" + TEST_BSSID + "\n" + "\n" + "\n" + "\n" @@ -138,6 +140,28 @@ public class SoftApStoreDataTest extends WifiBaseTest { + "" + TEST_ALLOWED_CLIENT + "\n" + "\n"; + private static final String TEST_SOFTAP_CONFIG_XML_STRING_WITH_ALL_CONFIG_EXCEPT_BSSID = + "" + TEST_SSID + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "" + TEST_PASSPHRASE + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "" + TEST_BLOCKED_CLIENT + "\n" + + "\n" + + "\n" + + "" + TEST_ALLOWED_CLIENT + "\n" + + "\n"; + @Mock private Context mContext; @Mock SoftApStoreData.DataSource mDataSource; @Mock WifiConfigStoreMigrationDataHolder mWifiConfigStoreMigrationDataHolder; @@ -189,6 +213,7 @@ public class SoftApStoreDataTest extends WifiBaseTest { private SoftApConfiguration createDefaultTestSoftApConfiguration() { SoftApConfiguration.Builder softApConfigBuilder = new SoftApConfiguration.Builder(); softApConfigBuilder.setSsid(TEST_SSID); + softApConfigBuilder.setBssid(MacAddress.fromString(TEST_BSSID)); softApConfigBuilder.setPassphrase(TEST_PASSPHRASE, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK); softApConfigBuilder.setBand(TEST_BAND); @@ -269,6 +294,7 @@ public class SoftApStoreDataTest extends WifiBaseTest { SoftApConfiguration softApConfig = softapConfigCaptor.getValue(); assertNotNull(softApConfig); assertEquals(softApConfig.getSsid(), TEST_SSID); + assertEquals(softApConfig.getBssid().toString(), TEST_BSSID); assertEquals(softApConfig.getPassphrase(), TEST_PASSPHRASE); assertEquals(softApConfig.getSecurityType(), SoftApConfiguration.SECURITY_TYPE_WPA2_PSK); assertEquals(softApConfig.isHiddenSsid(), TEST_HIDDEN); @@ -499,4 +525,31 @@ public class SoftApStoreDataTest extends WifiBaseTest { assertFalse(softApConfig.isAutoShutdownEnabled()); } + /** + * Verify that the old format is deserialized correctly. + * + * @throws Exception + */ + @Test + public void deserializeSoftApWithNoBssidTag() throws Exception { + // Start with the old serialized data + deserializeData(TEST_SOFTAP_CONFIG_XML_STRING_WITH_ALL_CONFIG_EXCEPT_BSSID.getBytes()); + ArgumentCaptor softapConfigCaptor = + ArgumentCaptor.forClass(SoftApConfiguration.class); + verify(mDataSource).fromDeserialized(softapConfigCaptor.capture()); + SoftApConfiguration softApConfig = softapConfigCaptor.getValue(); + assertNotNull(softApConfig); + assertEquals(softApConfig.getSsid(), TEST_SSID); + assertEquals(softApConfig.getPassphrase(), TEST_PASSPHRASE); + assertEquals(softApConfig.getSecurityType(), SoftApConfiguration.SECURITY_TYPE_WPA2_PSK); + assertEquals(softApConfig.isHiddenSsid(), TEST_HIDDEN); + assertEquals(softApConfig.getBand(), TEST_BAND); + assertEquals(softApConfig.isClientControlByUserEnabled(), TEST_CLIENT_CONTROL_BY_USER); + assertEquals(softApConfig.getMaxNumberOfClients(), TEST_MAX_NUMBER_OF_CLIENTS); + assertTrue(softApConfig.isAutoShutdownEnabled()); + assertEquals(softApConfig.getShutdownTimeoutMillis(), TEST_SHUTDOWN_TIMEOUT_MILLIS); + assertEquals(softApConfig.getBlockedClientList(), TEST_BLOCKEDLIST); + assertEquals(softApConfig.getAllowedClientList(), TEST_ALLOWEDLIST); + } + } -- cgit v1.2.3