16a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvistpackage com.android.server.wifi.anqp; 26a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist 371a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvistimport java.net.ProtocolException; 46a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvistimport java.nio.ByteBuffer; 571a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvistimport java.util.ArrayList; 671a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvistimport java.util.Collections; 771a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvistimport java.util.List; 871a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist 971a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvistimport static com.android.server.wifi.anqp.Constants.BYTE_MASK; 1071a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist 116a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist 126a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist/** 136a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist * The 3GPP Cellular Network ANQP Element, IEEE802.11-2012 section 8.4.4.11 146a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist */ 156a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvistpublic class ThreeGPPNetworkElement extends ANQPElement { 1671a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist private final int mUserData; 1771a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist private final List<CellularNetwork> mPlmns; 186a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist 1971a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist public ThreeGPPNetworkElement(Constants.ANQPElementType infoID, ByteBuffer payload) 2071a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist throws ProtocolException { 216a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist super(infoID); 2271a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist 2371a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist mPlmns = new ArrayList<CellularNetwork>(); 2471a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist mUserData = payload.get() & BYTE_MASK; 2571a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist int length = payload.get() & BYTE_MASK; 2671a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist if (length > payload.remaining()) { 2771a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist throw new ProtocolException("Runt payload"); 2871a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist } 2971a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist 3071a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist while (payload.hasRemaining()) { 3171a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist CellularNetwork network = CellularNetwork.buildCellularNetwork(payload); 3271a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist if (network != null) { 3371a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist mPlmns.add(network); 3471a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist } 3571a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist } 3671a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist } 3771a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist 3871a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist public int getUserData() { 3971a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist return mUserData; 406a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist } 416a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist 4271a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist public List<CellularNetwork> getPlmns() { 4371a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist return Collections.unmodifiableList(mPlmns); 446a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist } 456a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist 466a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist @Override 476a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist public String toString() { 4877f2b82a2e80af8da52c22d69a76def6d4209757Jan Nordqvist return "ThreeGPPNetwork{" + 4971a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist "mUserData=" + mUserData + 5071a988c8e9859244b83cd55bb6b6ee913fcaf95cJan Nordqvist ", mPlmns=" + mPlmns + 516a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist '}'; 526a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist } 536a3903fed590e369b576bddbe1ae2d788768ddfeJan Nordqvist} 54