summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/SoftApStoreData.java9
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApStoreDataTest.java53
2 files changed, 62 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/SoftApStoreData.java b/service/java/com/android/server/wifi/SoftApStoreData.java
index deea15ae1..6ed81428f 100644
--- a/service/java/com/android/server/wifi/SoftApStoreData.java
+++ b/service/java/com/android/server/wifi/SoftApStoreData.java
@@ -44,6 +44,7 @@ public class SoftApStoreData implements WifiConfigStore.StoreData {
private static final String TAG = "SoftApStoreData";
private static final String XML_TAG_SECTION_HEADER_SOFTAP = "SoftAp";
private static final String XML_TAG_SSID = "SSID";
+ private static final String XML_TAG_BSSID = "Bssid";
private static final String XML_TAG_BAND = "Band";
private static final String XML_TAG_CHANNEL = "Channel";
private static final String XML_TAG_HIDDEN_SSID = "HiddenSSID";
@@ -107,6 +108,9 @@ public class SoftApStoreData implements WifiConfigStore.StoreData {
SoftApConfiguration softApConfig = mDataSource.toSerialize();
if (softApConfig != null) {
XmlUtil.writeNextValue(out, XML_TAG_SSID, softApConfig.getSsid());
+ if (softApConfig.getBssid() != null) {
+ XmlUtil.writeNextValue(out, XML_TAG_BSSID, softApConfig.getBssid().toString());
+ }
XmlUtil.writeNextValue(out, XML_TAG_AP_BAND, softApConfig.getBand());
XmlUtil.writeNextValue(out, XML_TAG_CHANNEL, softApConfig.getChannel());
XmlUtil.writeNextValue(out, XML_TAG_HIDDEN_SSID, softApConfig.isHiddenSsid());
@@ -159,6 +163,7 @@ public class SoftApStoreData implements WifiConfigStore.StoreData {
int securityType = SoftApConfiguration.SECURITY_TYPE_OPEN;
String passphrase = null;
String ssid = null;
+ String bssid = null;
// Note that, during deserializaion, we may read the old band encoding (XML_TAG_BAND)
// or the new band encoding (XML_TAG_AP_BAND) that is used after the introduction of the
// 6GHz band. If the old encoding is found, a conversion is done.
@@ -180,6 +185,10 @@ public class SoftApStoreData implements WifiConfigStore.StoreData {
ssid = (String) value;
softApConfigBuilder.setSsid((String) value);
break;
+ case XML_TAG_BSSID:
+ bssid = (String) value;
+ softApConfigBuilder.setBssid(MacAddress.fromString(bssid));
+ break;
case XML_TAG_BAND:
apBand = ApConfigUtil.convertWifiConfigBandToSoftApConfigBand(
(int) value);
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 =
"<string name=\"SSID\">" + TEST_SSID + "</string>\n"
+ + "<string name=\"Bssid\">" + TEST_BSSID + "</string>\n"
+ "<int name=\"ApBand\" value=\"" + TEST_BAND + "\" />\n"
+ "<int name=\"Channel\" value=\"" + TEST_CHANNEL + "\" />\n"
+ "<boolean name=\"HiddenSSID\" value=\"" + TEST_HIDDEN + "\" />\n"
@@ -138,6 +140,28 @@ public class SoftApStoreDataTest extends WifiBaseTest {
+ "<string name=\"ClientMacAddress\">" + TEST_ALLOWED_CLIENT + "</string>\n"
+ "</AllowedClientList>\n";
+ private static final String TEST_SOFTAP_CONFIG_XML_STRING_WITH_ALL_CONFIG_EXCEPT_BSSID =
+ "<string name=\"SSID\">" + TEST_SSID + "</string>\n"
+ + "<int name=\"ApBand\" value=\"" + TEST_BAND + "\" />\n"
+ + "<int name=\"Channel\" value=\"" + TEST_CHANNEL + "\" />\n"
+ + "<boolean name=\"HiddenSSID\" value=\"" + TEST_HIDDEN + "\" />\n"
+ + "<int name=\"SecurityType\" value=\"" + TEST_SECURITY + "\" />\n"
+ + "<string name=\"Passphrase\">" + TEST_PASSPHRASE + "</string>\n"
+ + "<int name=\"MaxNumberOfClients\" value=\""
+ + TEST_MAX_NUMBER_OF_CLIENTS + "\" />\n"
+ + "<boolean name=\"ClientControlByUser\" value=\""
+ + TEST_CLIENT_CONTROL_BY_USER + "\" />\n"
+ + "<boolean name=\"AutoShutdownEnabled\" value=\""
+ + TEST_AUTO_SHUTDOWN_ENABLED + "\" />\n"
+ + "<int name=\"ShutdownTimeoutMillis\" value=\""
+ + TEST_SHUTDOWN_TIMEOUT_MILLIS + "\" />\n"
+ + "<BlockedClientList>\n"
+ + "<string name=\"ClientMacAddress\">" + TEST_BLOCKED_CLIENT + "</string>\n"
+ + "</BlockedClientList>\n"
+ + "<AllowedClientList>\n"
+ + "<string name=\"ClientMacAddress\">" + TEST_ALLOWED_CLIENT + "</string>\n"
+ + "</AllowedClientList>\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<SoftApConfiguration> 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);
+ }
+
}