summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPeter Qiu <zqiu@google.com>2017-03-07 11:41:58 -0800
committerPeter Qiu <zqiu@google.com>2017-03-10 14:07:03 -0800
commit9e83e33d444446e59aa59fc355972ff804d8eafa (patch)
tree666101ad0f056c609f13710f0439df241e04c7d1 /service
parent4a5f4e08d677a6da1b436e58d027de99518a97cf (diff)
util: add utility functions for retrieving Hotspot 2.0 specific IEs
Instead of using the parsed IEs maintained in NetworkDetail, the interested party can use the newly added utility functions to retrieve the elements that it is interested in. This allows us to remove the NetworkDetail dependencies from Passpoint code. I think if we ever want to maintain a copy of parsed IEs, it should be in ScanResult instead of NetworkDetail. Bug: 35888100 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: I69849728c93d3e1f9b6c7bda1e5c21cfdb40689a
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/util/InformationElementUtil.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/util/InformationElementUtil.java b/service/java/com/android/server/wifi/util/InformationElementUtil.java
index 9d7de241a..fdb1ca318 100644
--- a/service/java/com/android/server/wifi/util/InformationElementUtil.java
+++ b/service/java/com/android/server/wifi/util/InformationElementUtil.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.BitSet;
public class InformationElementUtil {
+ private static final String TAG = "InformationElementUtil";
public static InformationElement[] parseInformationElements(byte[] bytes) {
if (bytes == null) {
@@ -63,6 +64,71 @@ public class InformationElementUtil {
return infoElements.toArray(new InformationElement[infoElements.size()]);
}
+ /**
+ * Parse and retrieve the Roaming Consortium Information Element from the list of IEs.
+ *
+ * @param ies List of IEs to retrieve from
+ * @return {@link RoamingConsortium}
+ */
+ public static RoamingConsortium getRoamingConsortiumIE(InformationElement[] ies) {
+ RoamingConsortium roamingConsortium = new RoamingConsortium();
+ if (ies != null) {
+ for (InformationElement ie : ies) {
+ if (ie.id == InformationElement.EID_ROAMING_CONSORTIUM) {
+ try {
+ roamingConsortium.from(ie);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Failed to parse Roaming Consortium IE: " + e.getMessage());
+ }
+ }
+ }
+ }
+ return roamingConsortium;
+ }
+
+ /**
+ * Parse and retrieve the Hotspot 2.0 Vendor Specific Information Element from the list of IEs.
+ *
+ * @param ies List of IEs to retrieve from
+ * @return {@link Vsa}
+ */
+ public static Vsa getHS2VendorSpecificIE(InformationElement[] ies) {
+ Vsa vsa = new Vsa();
+ if (ies != null) {
+ for (InformationElement ie : ies) {
+ if (ie.id == InformationElement.EID_VSA) {
+ try {
+ vsa.from(ie);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Failed to parse Vendor Specific IE: " + e.getMessage());
+ }
+ }
+ }
+ }
+ return vsa;
+ }
+
+ /**
+ * Parse and retrieve the Interworking information element from the list of IEs.
+ *
+ * @param ies List of IEs to retrieve from
+ * @return {@link Interworking}
+ */
+ public static Interworking getInterworkingIE(InformationElement[] ies) {
+ Interworking interworking = new Interworking();
+ if (ies != null) {
+ for (InformationElement ie : ies) {
+ if (ie.id == InformationElement.EID_INTERWORKING) {
+ try {
+ interworking.from(ie);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Failed to parse Interworking IE: " + e.getMessage());
+ }
+ }
+ }
+ }
+ return interworking;
+ }
public static class BssLoad {
public int stationCount = 0;