From c66d00cefbd32ec2fbefcf1fd54c1aaf50b5ce5a Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Thu, 18 May 2017 20:30:32 -0700 Subject: Support coexistence of wpa and wpa2 IEs in scan result When there are both wpa1 and wpa2(rsn) ies in scan result, InformationElementUtil.generateCapabilitiesString() should handle it and generate capabilties string correctly. Bug: 37653951 Test: compile, unit tests, manual test, integration test Change-Id: I7160fcbbd75c07f4fe02de62a3e4539fa628eab3 --- .../wifi/util/InformationElementUtilTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests') 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 ae654468b..d94b54252 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java @@ -298,6 +298,44 @@ public class InformationElementUtilTest { assertEquals("[WPA-PSK-CCMP+TKIP]", result); } + /** + * Test Capabilities.generateCapabilitiesString() with both RSN and WPA1 IE. + * Expect the function to return a string with the proper security information. + */ + @Test + public void buildCapabilities_rsnAndWpaElement() { + InformationElement ieRsn = new InformationElement(); + ieRsn.id = InformationElement.EID_RSN; + ieRsn.bytes = new byte[] { (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x0F, + (byte) 0xAC, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x04, + (byte) 0x00, (byte) 0x0F, (byte) 0xAC, (byte) 0x02, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x0F, + (byte) 0xAC, (byte) 0x02, (byte) 0x00, (byte) 0x00 }; + + InformationElement ieWpa = new InformationElement(); + ieWpa.id = InformationElement.EID_VSA; + ieWpa.bytes = new byte[] { (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x01, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x50, + (byte) 0xF2, (byte) 0x02, (byte) 0x02, (byte) 0x00, + (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x04, + (byte) 0x00, (byte) 0x50, (byte) 0xF2, (byte) 0x02, + (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x50, + (byte) 0xF2, (byte) 0x02, (byte) 0x00, (byte) 0x00 }; + + InformationElement[] ies = new InformationElement[] { ieWpa, ieRsn }; + + BitSet beaconCap = new BitSet(16); + beaconCap.set(4); + + InformationElementUtil.Capabilities capabilities = + new InformationElementUtil.Capabilities(); + capabilities.from(ies, beaconCap); + String result = capabilities.generateCapabilitiesString(); + + assertEquals("[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP]", result); + } + /** * Test Capabilities.generateCapabilitiesString() with a vendor specific element which * is not WPA type 1. Beacon Capability Information field has the Privacy -- cgit v1.2.3