1 package com.android.server.wifi.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 Domain Name ANQP Element, IEEE802.11-2012 section 8.4.4.15 12 */ 13 public class DomainNameElement extends ANQPElement { 14 private final List<String> mDomains; 15 16 public DomainNameElement(Constants.ANQPElementType infoID, ByteBuffer payload) 17 throws ProtocolException { 18 super(infoID); 19 mDomains = new ArrayList<>(); 20 21 while (payload.hasRemaining()) { 22 // Use latin-1 to decode for now - safe for ASCII and retains encoding 23 mDomains.add(Constants.getPrefixedString(payload, 1, StandardCharsets.ISO_8859_1)); 24 } 25 } 26 27 public List<String> getDomains() { 28 return Collections.unmodifiableList(mDomains); 29 } 30 31 @Override 32 public String toString() { 33 return "DomainName{" + 34 "mDomains=" + mDomains + 35 '}'; 36 } 37 } 38