Merge "Increased precision of Lat/Lng decoder and enabled BSSID list to be explicit (client)" into qt-r1-dev

This commit is contained in:
TreeHugger Robot
2019-08-19 20:37:12 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 15 deletions

View File

@@ -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++) {

View File

@@ -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);