diff options
author | Peter Qiu <zqiu@google.com> | 2017-05-25 11:00:32 -0700 |
---|---|---|
committer | Peter Qiu <zqiu@google.com> | 2017-05-26 09:16:50 -0700 |
commit | 4c29caec80ebfc32a3c4047679082dca52cc18cc (patch) | |
tree | c493c11ea38c7b797cc40d576cbb7e990d6cd450 /tests/wifitests/src/com/android/server/wifi/hotspot2/anqp | |
parent | efe18a90941645b907fa2b50d922e7373303613e (diff) | |
download | android_frameworks_opt_net_wifi-4c29caec80ebfc32a3c4047679082dca52cc18cc.tar.gz android_frameworks_opt_net_wifi-4c29caec80ebfc32a3c4047679082dca52cc18cc.tar.bz2 android_frameworks_opt_net_wifi-4c29caec80ebfc32a3c4047679082dca52cc18cc.zip |
hotspot2: parse OSU Providers ANQP element
Instead of storing OSU providers list as raw bytes,
parse it using the HSOsuProvidersElement.
Also do not broadcast the raw bytes to the app, since it
will be parsed by us now.
The app will be able to retrieve the parsed information
via a new API in the future (to be implemented).
Bug: 38351209
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: manual testing with Boingo Passpoint AP, verify
via debug logs
Change-Id: Idc15c4b00580d65133bde57ba43be590d50321c0
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/hotspot2/anqp')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/ANQPParserTest.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/ANQPParserTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/ANQPParserTest.java index 8f019e017..59332e4fb 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/ANQPParserTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/ANQPParserTest.java @@ -18,6 +18,7 @@ package com.android.server.wifi.hotspot2.anqp; import static org.junit.Assert.assertEquals; +import android.net.wifi.WifiSsid; import android.test.suitebuilder.annotation.SmallTest; import org.junit.Test; @@ -216,6 +217,22 @@ public class ANQPParserTest { } /** + * Helper function for generating payload for a Hotspot 2.0 OSU Providers List ANQP + * element. + * + * @param osuSsidBytes Bytes of OSU SSID + * @return byte[] + */ + private static byte[] getHSOsuProvidersPayload(byte[] osuSsidBytes) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + out.write((byte) osuSsidBytes.length); + out.write(osuSsidBytes); + out.write((byte) 1); + out.write(OsuProviderInfoTestUtil.TEST_OSU_PROVIDER_INFO_RAW_BYTES); + return out.toByteArray(); + } + + /** * Helper function for generating payload for a list of I18Name. * * @param language Array of language @@ -473,10 +490,12 @@ public class ANQPParserTest { */ @Test public void parseHSOUSProvidersElement() throws Exception { - byte[] data = new byte[10]; + byte[] osuSsidBytes = "Test SSID".getBytes(StandardCharsets.UTF_8); + byte[] data = getHSOsuProvidersPayload(osuSsidBytes); - RawByteElement expected = - new RawByteElement(Constants.ANQPElementType.HSOSUProviders, data); + HSOsuProvidersElement expected = new HSOsuProvidersElement( + WifiSsid.createFromByteArray(osuSsidBytes), + Arrays.asList(OsuProviderInfoTestUtil.TEST_OSU_PROVIDER_INFO)); ByteBuffer buffer = ByteBuffer.wrap(data); assertEquals(expected, |