summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/util/InformationElementUtil.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java59
2 files changed, 58 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/util/InformationElementUtil.java b/service/java/com/android/server/wifi/util/InformationElementUtil.java
index b341b4356..6e6dfcc77 100644
--- a/service/java/com/android/server/wifi/util/InformationElementUtil.java
+++ b/service/java/com/android/server/wifi/util/InformationElementUtil.java
@@ -311,6 +311,7 @@ public class InformationElementUtil {
* by wpa_supplicant.
*/
public static class Capabilities {
+ private static final int CAP_ESS_BIT_OFFSET = 0;
private static final int CAP_PRIVACY_BIT_OFFSET = 4;
private static final int WPA_VENDOR_OUI_TYPE_ONE = 0x01f25000;
@@ -526,6 +527,7 @@ public class InformationElementUtil {
return capabilities;
}
+ boolean ess = beaconCap.get(CAP_ESS_BIT_OFFSET);
boolean privacy = beaconCap.get(CAP_PRIVACY_BIT_OFFSET);
for (InformationElement ie : ies) {
@@ -547,6 +549,10 @@ public class InformationElementUtil {
capabilities += "[WEP]";
}
+ if (ess) {
+ capabilities += "[ESS]";
+ }
+
return capabilities;
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
index 7ee3f8f88..ef9e1200d 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
@@ -241,7 +241,6 @@ public class InformationElementUtilTest {
/**
* Test Capabilities.buildCapabilities() with a RSN IE.
* Expect the function to return a string with the proper security information.
- *
*/
@Test
public void buildCapabilities_rsnElement() {
@@ -267,7 +266,6 @@ public class InformationElementUtilTest {
/**
* Test Capabilities.buildCapabilities() with a WPA type 1 IE.
* Expect the function to return a string with the proper security information.
- *
*/
@Test
public void buildCapabilities_wpa1Element() {
@@ -293,11 +291,10 @@ public class InformationElementUtilTest {
/**
* Test Capabilities.buildCapabilities() with a vendor specific element which
- * is not WPA type 1 however. Beacon Capability Information field has the Privacy
+ * is not WPA type 1. Beacon Capability Information field has the Privacy
* bit set.
*
* Expect the function to return a string with the proper security information.
- *
*/
@Test
public void buildCapabilities_nonRsnWpa1Element_privacySet() {
@@ -319,11 +316,10 @@ public class InformationElementUtilTest {
/**
* Test Capabilities.buildCapabilities() with a vendor specific element which
- * is not WPA type 1 however. Beacon Capability Information field doesn't have the
+ * is not WPA type 1. Beacon Capability Information field doesn't have the
* Privacy bit set.
*
- * Expect the function to return a string with the proper security information.
- *
+ * Expect the function to return an empty string.
*/
@Test
public void buildCapabilities_nonRsnWpa1Element_privacyClear() {
@@ -344,6 +340,55 @@ public class InformationElementUtilTest {
}
/**
+ * Test Capabilities.buildCapabilities() with a vendor specific element which
+ * is not WPA type 1. Beacon Capability Information field has the ESS bit set.
+ *
+ * Expect the function to return a string with [ESS] there.
+ */
+ @Test
+ public void buildCapabilities_nonRsnWpa1Element_essSet() {
+ InformationElement ie = new InformationElement();
+ ie.id = InformationElement.EID_VSA;
+ ie.bytes = new byte[] { (byte) 0x00, (byte) 0x04, (byte) 0x0E, (byte) 0x01,
+ (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+
+ InformationElement[] ies = new InformationElement[] { ie };
+
+ BitSet beaconCap = new BitSet(16);
+ beaconCap.set(0);
+
+ String result = InformationElementUtil.Capabilities.buildCapabilities(ies, beaconCap);
+
+ assertEquals("[ESS]", result);
+ }
+
+ /**
+ * Test Capabilities.buildCapabilities() with a vendor specific element which
+ * is not WPA type 1. Beacon Capability Information field doesn't have the
+ * ESS bit set.
+ *
+ * Expect the function to return an empty string.
+ */
+ @Test
+ public void buildCapabilities_nonRsnWpa1Element_essClear() {
+ InformationElement ie = new InformationElement();
+ ie.id = InformationElement.EID_VSA;
+ ie.bytes = new byte[] { (byte) 0x00, (byte) 0x04, (byte) 0x0E, (byte) 0x01,
+ (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+
+ InformationElement[] ies = new InformationElement[] { ie };
+
+ BitSet beaconCap = new BitSet(16);
+ beaconCap.clear(0);
+
+ String result = InformationElementUtil.Capabilities.buildCapabilities(ies, beaconCap);
+
+ assertEquals("", result);
+ }
+
+ /**
* Test a that a correctly formed TIM Information Element is decoded into a valid TIM element,
* and the values are captured
*/