summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Etan Cohen <etancohen@google.com> 2018-05-07 03:58:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-05-07 03:58:42 +0000
commit51f3c4481c175b1ccc14c843f963da142b633e5d (patch)
treec5773e0c449d8d93fa22f82e49130c74e9f6d3dc
parentf7416d1fe0f906d7bec1db767de2ab1ec4bb1026 (diff)
parent67f5ffb7e85465bdb6e97f64992c446e0b7f8c01 (diff)
Merge "[RTT] Update RTT preamble selection algorithm" into pi-dev
-rw-r--r--wifi/java/android/net/wifi/ScanResult.java2
-rw-r--r--wifi/java/android/net/wifi/rtt/ResponderConfig.java32
-rw-r--r--wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java92
3 files changed, 122 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java
index 8024bf08b1d4..f210b61e9f71 100644
--- a/wifi/java/android/net/wifi/ScanResult.java
+++ b/wifi/java/android/net/wifi/ScanResult.java
@@ -402,12 +402,14 @@ public class ScanResult implements Parcelable {
public static final int EID_TIM = 5;
public static final int EID_BSS_LOAD = 11;
public static final int EID_ERP = 42;
+ public static final int EID_HT_CAPABILITIES = 45;
public static final int EID_RSN = 48;
public static final int EID_EXTENDED_SUPPORTED_RATES = 50;
public static final int EID_HT_OPERATION = 61;
public static final int EID_INTERWORKING = 107;
public static final int EID_ROAMING_CONSORTIUM = 111;
public static final int EID_EXTENDED_CAPS = 127;
+ public static final int EID_VHT_CAPABILITIES = 191;
public static final int EID_VHT_OPERATION = 192;
public static final int EID_VSA = 221;
diff --git a/wifi/java/android/net/wifi/rtt/ResponderConfig.java b/wifi/java/android/net/wifi/rtt/ResponderConfig.java
index fb723c594e15..166af6cd0a51 100644
--- a/wifi/java/android/net/wifi/rtt/ResponderConfig.java
+++ b/wifi/java/android/net/wifi/rtt/ResponderConfig.java
@@ -16,6 +16,9 @@
package android.net.wifi.rtt;
+import static android.net.wifi.ScanResult.InformationElement.EID_HT_CAPABILITIES;
+import static android.net.wifi.ScanResult.InformationElement.EID_VHT_CAPABILITIES;
+
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
@@ -24,6 +27,7 @@ import android.net.wifi.ScanResult;
import android.net.wifi.aware.PeerHandle;
import android.os.Parcel;
import android.os.Parcelable;
+import android.util.Log;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -40,6 +44,7 @@ import java.util.Objects;
*/
@SystemApi
public final class ResponderConfig implements Parcelable {
+ private static final String TAG = "ResponderConfig";
private static final int AWARE_BAND_2_DISCOVERY_CHANNEL = 2437;
/** @hide */
@@ -297,12 +302,31 @@ public final class ResponderConfig implements Parcelable {
int centerFreq0 = scanResult.centerFreq0;
int centerFreq1 = scanResult.centerFreq1;
- // TODO: b/68936111 - extract preamble info from IE
int preamble;
- if (channelWidth == CHANNEL_WIDTH_80MHZ || channelWidth == CHANNEL_WIDTH_160MHZ) {
- preamble = PREAMBLE_VHT;
+ if (scanResult.informationElements != null && scanResult.informationElements.length != 0) {
+ boolean htCapabilitiesPresent = false;
+ boolean vhtCapabilitiesPresent = false;
+ for (ScanResult.InformationElement ie : scanResult.informationElements) {
+ if (ie.id == EID_HT_CAPABILITIES) {
+ htCapabilitiesPresent = true;
+ } else if (ie.id == EID_VHT_CAPABILITIES) {
+ vhtCapabilitiesPresent = true;
+ }
+ }
+ if (vhtCapabilitiesPresent) {
+ preamble = PREAMBLE_VHT;
+ } else if (htCapabilitiesPresent) {
+ preamble = PREAMBLE_HT;
+ } else {
+ preamble = PREAMBLE_LEGACY;
+ }
} else {
- preamble = PREAMBLE_HT;
+ Log.e(TAG, "Scan Results do not contain IEs - using backup method to select preamble");
+ if (channelWidth == CHANNEL_WIDTH_80MHZ || channelWidth == CHANNEL_WIDTH_160MHZ) {
+ preamble = PREAMBLE_VHT;
+ } else {
+ preamble = PREAMBLE_HT;
+ }
}
return new ResponderConfig(macAddress, responderType, supports80211mc, channelWidth,
diff --git a/wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java b/wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java
index ddddde952298..ccb90319d8cd 100644
--- a/wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java
@@ -295,4 +295,96 @@ public class WifiRttManagerTest {
assertEquals(rr1, rr2);
}
+
+ /**
+ * Validate that ResponderConfig parcel works (produces same object on write/read).
+ */
+ @Test
+ public void testResponderConfigParcel() {
+ // ResponderConfig constructed with a MAC address
+ ResponderConfig config = new ResponderConfig(MacAddress.fromString("00:01:02:03:04:05"),
+ ResponderConfig.RESPONDER_AP, true, ResponderConfig.CHANNEL_WIDTH_80MHZ, 2134, 2345,
+ 2555, ResponderConfig.PREAMBLE_LEGACY);
+
+ Parcel parcelW = Parcel.obtain();
+ config.writeToParcel(parcelW, 0);
+ byte[] bytes = parcelW.marshall();
+ parcelW.recycle();
+
+ Parcel parcelR = Parcel.obtain();
+ parcelR.unmarshall(bytes, 0, bytes.length);
+ parcelR.setDataPosition(0);
+ ResponderConfig rereadConfig = ResponderConfig.CREATOR.createFromParcel(parcelR);
+
+ assertEquals(config, rereadConfig);
+
+ // ResponderConfig constructed with a PeerHandle
+ config = new ResponderConfig(new PeerHandle(10), ResponderConfig.RESPONDER_AWARE, false,
+ ResponderConfig.CHANNEL_WIDTH_80MHZ_PLUS_MHZ, 5555, 6666, 7777,
+ ResponderConfig.PREAMBLE_VHT);
+
+ parcelW = Parcel.obtain();
+ config.writeToParcel(parcelW, 0);
+ bytes = parcelW.marshall();
+ parcelW.recycle();
+
+ parcelR = Parcel.obtain();
+ parcelR.unmarshall(bytes, 0, bytes.length);
+ parcelR.setDataPosition(0);
+ rereadConfig = ResponderConfig.CREATOR.createFromParcel(parcelR);
+
+ assertEquals(config, rereadConfig);
+ }
+
+ /**
+ * Validate preamble selection from ScanResults.
+ */
+ @Test
+ public void testResponderPreambleSelection() {
+ ScanResult.InformationElement htCap = new ScanResult.InformationElement();
+ htCap.id = ScanResult.InformationElement.EID_HT_CAPABILITIES;
+
+ ScanResult.InformationElement vhtCap = new ScanResult.InformationElement();
+ vhtCap.id = ScanResult.InformationElement.EID_VHT_CAPABILITIES;
+
+ ScanResult.InformationElement vsa = new ScanResult.InformationElement();
+ vsa.id = ScanResult.InformationElement.EID_VSA;
+
+ // no IE
+ ScanResult scan = new ScanResult();
+ scan.BSSID = "00:01:02:03:04:05";
+ scan.informationElements = null;
+ scan.channelWidth = ResponderConfig.CHANNEL_WIDTH_80MHZ;
+
+ ResponderConfig config = ResponderConfig.fromScanResult(scan);
+
+ assertEquals(ResponderConfig.PREAMBLE_VHT, config.preamble);
+
+ // IE with HT & VHT
+ scan.channelWidth = ResponderConfig.CHANNEL_WIDTH_40MHZ;
+
+ scan.informationElements = new ScanResult.InformationElement[2];
+ scan.informationElements[0] = htCap;
+ scan.informationElements[1] = vhtCap;
+
+ config = ResponderConfig.fromScanResult(scan);
+
+ assertEquals(ResponderConfig.PREAMBLE_VHT, config.preamble);
+
+ // IE with some entries but no HT or VHT
+ scan.informationElements[0] = vsa;
+ scan.informationElements[1] = vsa;
+
+ config = ResponderConfig.fromScanResult(scan);
+
+ assertEquals(ResponderConfig.PREAMBLE_LEGACY, config.preamble);
+
+ // IE with HT
+ scan.informationElements[0] = vsa;
+ scan.informationElements[1] = htCap;
+
+ config = ResponderConfig.fromScanResult(scan);
+
+ assertEquals(ResponderConfig.PREAMBLE_HT, config.preamble);
+ }
}