diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-08-19 20:37:12 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-08-19 20:37:12 +0000 |
commit | 4e027572e31d7fc7b6128b6dbd339cb1ec0eed90 (patch) | |
tree | f8c5ad2a18ae0d932838f6437bb54499e866df58 | |
parent | 6201d2895223691191ec2d5a08a8f6c6b7bdb4a7 (diff) | |
parent | 2d2b916cd352225b5db9a96206fa8ab794c97fa2 (diff) | |
download | base-4e027572e31d7fc7b6128b6dbd339cb1ec0eed90.tar.gz |
Merge "Increased precision of Lat/Lng decoder and enabled BSSID list to be explicit (client)" into qt-r1-dev
-rw-r--r-- | wifi/java/android/net/wifi/rtt/ResponderLocation.java | 13 | ||||
-rw-r--r-- | wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java | 18 |
2 files changed, 16 insertions, 15 deletions
diff --git a/wifi/java/android/net/wifi/rtt/ResponderLocation.java b/wifi/java/android/net/wifi/rtt/ResponderLocation.java index e1d82f8d3a09..970a75d7c418 100644 --- a/wifi/java/android/net/wifi/rtt/ResponderLocation.java +++ b/wifi/java/android/net/wifi/rtt/ResponderLocation.java @@ -605,11 +605,11 @@ public final class ResponderLocation implements Parcelable { // Negative 2's complement value // Note: The Math.pow(...) method cannot return a NaN value because the bitFieldSize // for Lat or Lng is limited to exactly 34 bits. - angle = Math.scalb(fields[offset] - Math.pow(2, bitFieldSizes[offset]), + angle = Math.scalb((double) fields[offset] - Math.pow(2, bitFieldSizes[offset]), -LATLNG_FRACTION_BITS); } else { // Positive 2's complement value - angle = Math.scalb(fields[offset], -LATLNG_FRACTION_BITS); + angle = Math.scalb((double) fields[offset], -LATLNG_FRACTION_BITS); } if (angle > limit) { angle = limit; @@ -732,10 +732,11 @@ public final class ResponderLocation implements Parcelable { int maxBssidIndicator = (int) buffer[SUBELEMENT_BSSID_MAX_INDICATOR_INDEX] & BYTE_MASK; int bssidListLength = (buffer.length - 1) / BYTES_IN_A_BSSID; - // Check the max number of BSSIDs agrees with the list length. - if (maxBssidIndicator != bssidListLength) { - return false; - } + // The maxBSSIDIndicator is ignored. Its use is still being clarified in 802.11REVmd, + // which is not published at this time. This field will be used in a future + // release of Android after 802.11REVmd is public. Here, we interpret the following + // params as an explicit list of BSSIDs. + int bssidOffset = SUBELEMENT_BSSID_LIST_INDEX; for (int i = 0; i < bssidListLength; i++) { diff --git a/wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java b/wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java index 47c304097372..b02eebbe9a01 100644 --- a/wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java +++ b/wifi/tests/src/android/net/wifi/rtt/ResponderLocationTest.java @@ -37,7 +37,7 @@ import java.util.List; */ @RunWith(JUnit4.class) public class ResponderLocationTest { - private static final double LATLNG_TOLERANCE_DEGREES = 0.00001; + private static final double LATLNG_TOLERANCE_DEGREES = 0.000_000_05D; // 5E-8 = 6mm of meridian private static final double ALT_TOLERANCE_METERS = 0.01; private static final double HEIGHT_TOLERANCE_METERS = 0.01; private static final int INDEX_ELEMENT_TYPE = 2; @@ -103,7 +103,7 @@ public class ResponderLocationTest { private static final byte[] sTestBssidListSE = { (byte) 0x07, // Subelement BSSID list (byte) 13, // length dependent on number of BSSIDs in list - (byte) 0x02, // Number of BSSIDs in list + (byte) 0x00, // List is explicit; no expansion of list required (byte) 0x01, // BSSID #1 (MSB) (byte) 0x02, (byte) 0x03, @@ -266,11 +266,11 @@ public class ResponderLocationTest { assertTrue(valid); assertTrue(lciValid); assertFalse(zValid); - assertEquals(0.0009765625, responderLocation.getLatitudeUncertainty()); - assertEquals(-33.857009, responderLocation.getLatitude(), + assertEquals(0.0009765625D, responderLocation.getLatitudeUncertainty()); + assertEquals(-33.8570095D, responderLocation.getLatitude(), LATLNG_TOLERANCE_DEGREES); - assertEquals(0.0009765625, responderLocation.getLongitudeUncertainty()); - assertEquals(151.215200, responderLocation.getLongitude(), + assertEquals(0.0009765625D, responderLocation.getLongitudeUncertainty()); + assertEquals(151.2152005D, responderLocation.getLongitude(), LATLNG_TOLERANCE_DEGREES); assertEquals(1, responderLocation.getAltitudeType()); assertEquals(64.0, responderLocation.getAltitudeUncertainty()); @@ -282,11 +282,11 @@ public class ResponderLocationTest { assertEquals(1, responderLocation.getLciVersion()); // Testing Location Object - assertEquals(-33.857009, location.getLatitude(), + assertEquals(-33.8570095D, location.getLatitude(), LATLNG_TOLERANCE_DEGREES); - assertEquals(151.215200, location.getLongitude(), + assertEquals(151.2152005D, location.getLongitude(), LATLNG_TOLERANCE_DEGREES); - assertEquals((0.0009765625 + 0.0009765625) / 2, location.getAccuracy(), + assertEquals((0.0009765625D + 0.0009765625D) / 2, location.getAccuracy(), LATLNG_TOLERANCE_DEGREES); assertEquals(11.2, location.getAltitude(), ALT_TOLERANCE_METERS); assertEquals(64.0, location.getVerticalAccuracyMeters(), ALT_TOLERANCE_METERS); |