1 package com.android.anqp; 2 3 import java.net.ProtocolException; 4 import java.nio.ByteBuffer; 5 import java.nio.charset.StandardCharsets; 6 import java.util.ArrayList; 7 import java.util.Collections; 8 import java.util.List; 9 10 /** 11 * The OSU Providers List vendor specific ANQP Element, 12 * Wi-Fi Alliance Hotspot 2.0 (Release 2) Technical Specification - Version 5.00, 13 * section 4.8 14 */ 15 public class HSOsuProvidersElement extends ANQPElement { 16 private final String mSSID; 17 private final List<OSUProvider> mProviders; 18 19 public HSOsuProvidersElement(Constants.ANQPElementType infoID, ByteBuffer payload) 20 throws ProtocolException { 21 super(infoID); 22 23 mSSID = Constants.getPrefixedString(payload, 1, StandardCharsets.UTF_8); 24 int providerCount = payload.get() & Constants.BYTE_MASK; 25 26 mProviders = new ArrayList<>(providerCount); 27 28 while (providerCount > 0) { 29 mProviders.add(new OSUProvider(mSSID, payload)); 30 providerCount--; 31 } 32 } 33 34 public String getSSID() { 35 return mSSID; 36 } 37 38 public List<OSUProvider> getProviders() { 39 return Collections.unmodifiableList(mProviders); 40 } 41 42 @Override 43 public String toString() { 44 return "HSOsuProviders{" + 45 "SSID='" + mSSID + '\'' + 46 ", providers=" + mProviders + 47 '}'; 48 } 49 } 50