diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-01-13 06:14:22 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-01-13 06:14:22 +0000 |
commit | f91694ff0b589d5b9fbe55b5da1b80642990321a (patch) | |
tree | 21f23a1c46f98a77e19f34d332c92a39ee5b9ef8 /service | |
parent | 50f36ec6fe906445db996bf3918e5cb3f170bc79 (diff) | |
parent | b86089a48fae8878b5a27533a116c97b0be6d0e7 (diff) |
Merge "util: fix parsing logic for ExtendedCapabilities IE"
Diffstat (limited to 'service')
3 files changed, 41 insertions, 29 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 3d730d933..1ceb03b45 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -1812,7 +1812,7 @@ public class WifiNative { } } - if (extendedCaps.is80211McRTTResponder) { + if (extendedCaps.is80211McRTTResponder()) { result.setFlag(ScanResult.FLAG_80211mc_RESPONDER); } else { result.clearFlag(ScanResult.FLAG_80211mc_RESPONDER); @@ -1844,8 +1844,9 @@ public class WifiNative { if(DBG) { Log.d(TAG, dbg + "SSID: " + result.SSID + " ChannelWidth is: " + result.channelWidth + " PrimaryFreq: " + result.frequency + " mCenterfreq0: " + result.centerFreq0 - + " mCenterfreq1: " + result.centerFreq1 + (extendedCaps.is80211McRTTResponder - ? "Support RTT reponder: " : "Do not support RTT responder") + + " mCenterfreq1: " + result.centerFreq1 + + (extendedCaps.is80211McRTTResponder() ? "Support RTT reponder: " + : "Do not support RTT responder") + " Capabilities: " + result.capabilities); } diff --git a/service/java/com/android/server/wifi/hotspot2/NetworkDetail.java b/service/java/com/android/server/wifi/hotspot2/NetworkDetail.java index 905b5b8c7..f9894f4d7 100644 --- a/service/java/com/android/server/wifi/hotspot2/NetworkDetail.java +++ b/service/java/com/android/server/wifi/hotspot2/NetworkDetail.java @@ -298,7 +298,7 @@ public class NetworkDetail { if (DBG) { Log.d(TAG, mSSID + "ChannelWidth is: " + mChannelWidth + " PrimaryFreq: " + mPrimaryFreq + " mCenterfreq0: " + mCenterfreq0 + " mCenterfreq1: " + mCenterfreq1 - + (extendedCapabilities.is80211McRTTResponder ? "Support RTT reponder" + + (extendedCapabilities.is80211McRTTResponder() ? "Support RTT responder" : "Do not support RTT responder")); Log.v("WifiMode", mSSID + ", WifiMode: " + InformationElementUtil.WifiMode.toString(mWifiMode) @@ -434,10 +434,6 @@ public class NetworkDetail { return mRoamingConsortiums; } - public Long getExtendedCapabilities() { - return mExtendedCapabilities.extendedCapabilities; - } - public Map<Constants.ANQPElementType, ANQPElement> getANQPElements() { return mANQPElements; } @@ -463,7 +459,7 @@ public class NetworkDetail { } public boolean is80211McResponderSupport() { - return mExtendedCapabilities.is80211McRTTResponder; + return mExtendedCapabilities.is80211McRTTResponder(); } public boolean isSSID_UTF8() { diff --git a/service/java/com/android/server/wifi/util/InformationElementUtil.java b/service/java/com/android/server/wifi/util/InformationElementUtil.java index 268ddce23..9d7de241a 100644 --- a/service/java/com/android/server/wifi/util/InformationElementUtil.java +++ b/service/java/com/android/server/wifi/util/InformationElementUtil.java @@ -261,37 +261,52 @@ public class InformationElementUtil { } } + /** + * This IE contained a bit field indicating the capabilities being advertised by the STA. + * The size of the bit field (number of bytes) is indicated by the |Length| field in the IE. + * + * Refer to Section 8.4.2.29 in IEEE 802.11-2012 Spec for capability associated with each + * bit. + * + * Here is the wire format of this IE: + * | Element ID | Length | Capabilities | + * 1 1 n + */ public static class ExtendedCapabilities { private static final int RTT_RESP_ENABLE_BIT = 70; - private static final long SSID_UTF8_BIT = 0x0001000000000000L; + private static final int SSID_UTF8_BIT = 48; - public Long extendedCapabilities = null; - public boolean is80211McRTTResponder = false; + public BitSet capabilitiesBitSet; - public ExtendedCapabilities() { + /** + * @return true if SSID should be interpreted using UTF-8 encoding + */ + public boolean isStrictUtf8() { + return capabilitiesBitSet.get(SSID_UTF8_BIT); } - public ExtendedCapabilities(ExtendedCapabilities other) { - extendedCapabilities = other.extendedCapabilities; - is80211McRTTResponder = other.is80211McRTTResponder; + /** + * @return true if 802.11 MC RTT Response is enabled + */ + public boolean is80211McRTTResponder() { + return capabilitiesBitSet.get(RTT_RESP_ENABLE_BIT); } - public boolean isStrictUtf8() { - return extendedCapabilities != null && (extendedCapabilities & SSID_UTF8_BIT) != 0; + public ExtendedCapabilities() { + capabilitiesBitSet = new BitSet(); } - public void from(InformationElement ie) { - ByteBuffer data = ByteBuffer.wrap(ie.bytes).order(ByteOrder.LITTLE_ENDIAN); - extendedCapabilities = - ByteBufferReader.readInteger(data, ByteOrder.LITTLE_ENDIAN, ie.bytes.length); + public ExtendedCapabilities(ExtendedCapabilities other) { + capabilitiesBitSet = other.capabilitiesBitSet; + } - int index = RTT_RESP_ENABLE_BIT / 8; - byte offset = RTT_RESP_ENABLE_BIT % 8; - if (ie.bytes.length < index + 1) { - is80211McRTTResponder = false; - } else { - is80211McRTTResponder = (ie.bytes[index] & ((byte) 0x1 << offset)) != 0; - } + /** + * Parse an ExtendedCapabilities from the IE containing raw bytes. + * + * @param ie The Information element data + */ + public void from(InformationElement ie) { + capabilitiesBitSet = BitSet.valueOf(ie.bytes); } } |