1package com.android.server.wifi.anqp; 2 3import java.net.ProtocolException; 4import java.nio.ByteBuffer; 5import java.util.Arrays; 6 7/** 8 * The ANQP Capability List element, 802.11-2012 section 8.4.4.3 9 */ 10public class CapabilityListElement extends ANQPElement { 11 private final Constants.ANQPElementType[] mCapabilities; 12 13 public CapabilityListElement(Constants.ANQPElementType infoID, ByteBuffer payload) 14 throws ProtocolException { 15 super(infoID); 16 if ((payload.remaining() & 1) == 1) 17 throw new ProtocolException("Odd length"); 18 mCapabilities = new Constants.ANQPElementType[payload.remaining() / Constants.BYTES_IN_SHORT]; 19 20 int index = 0; 21 while (payload.hasRemaining()) { 22 int capID = payload.getShort() & Constants.SHORT_MASK; 23 Constants.ANQPElementType capability = Constants.mapANQPElement(capID); 24 if (capability == null) 25 throw new ProtocolException("Unknown capability: " + capID); 26 mCapabilities[index++] = capability; 27 } 28 } 29 30 public Constants.ANQPElementType[] getCapabilities() { 31 return mCapabilities; 32 } 33 34 @Override 35 public String toString() { 36 return "CapabilityList{" + 37 "mCapabilities=" + Arrays.toString(mCapabilities) + 38 '}'; 39 } 40} 41