Use NaN to indicate altitude/bearing unavailable
NaN seems to be incompatible with FloatRange, so that was unfortunately
removed in the process.
Relnote: NaN now used to indicate bearing/altitude unavailable
Test: ./gradlew :health:health-services-client:test
Bug: 240489206
Change-Id: Ie8774ec09a7e21e51e8ac2f2b024b33d54c580cf
diff --git a/health/health-services-client/api/1.0.0-beta01.txt b/health/health-services-client/api/1.0.0-beta01.txt
index 84e9862..e1a88ef 100644
--- a/health/health-services-client/api/1.0.0-beta01.txt
+++ b/health/health-services-client/api/1.0.0-beta01.txt
@@ -660,7 +660,7 @@
}
public final class LocationData {
- ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional @FloatRange double altitude, optional @FloatRange(from=-1.0, to=360.0, toInclusive=false) double bearing);
+ ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional double altitude, optional double bearing);
method public double getAltitude();
method public double getBearing();
method public double getLatitude();
@@ -669,8 +669,8 @@
property public final double bearing;
property public final double latitude;
property public final double longitude;
- field public static final double ALTITUDE_UNAVAILABLE = 1.7976931348623157E308;
- field public static final double BEARING_UNAVAILABLE = -1.0;
+ field public static final double ALTITUDE_UNAVAILABLE = (0.0/0.0);
+ field public static final double BEARING_UNAVAILABLE = (0.0/0.0);
}
public final class MeasureCapabilities {
diff --git a/health/health-services-client/api/current.txt b/health/health-services-client/api/current.txt
index 84e9862..e1a88ef 100644
--- a/health/health-services-client/api/current.txt
+++ b/health/health-services-client/api/current.txt
@@ -660,7 +660,7 @@
}
public final class LocationData {
- ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional @FloatRange double altitude, optional @FloatRange(from=-1.0, to=360.0, toInclusive=false) double bearing);
+ ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional double altitude, optional double bearing);
method public double getAltitude();
method public double getBearing();
method public double getLatitude();
@@ -669,8 +669,8 @@
property public final double bearing;
property public final double latitude;
property public final double longitude;
- field public static final double ALTITUDE_UNAVAILABLE = 1.7976931348623157E308;
- field public static final double BEARING_UNAVAILABLE = -1.0;
+ field public static final double ALTITUDE_UNAVAILABLE = (0.0/0.0);
+ field public static final double BEARING_UNAVAILABLE = (0.0/0.0);
}
public final class MeasureCapabilities {
diff --git a/health/health-services-client/api/public_plus_experimental_1.0.0-beta01.txt b/health/health-services-client/api/public_plus_experimental_1.0.0-beta01.txt
index 84e9862..e1a88ef 100644
--- a/health/health-services-client/api/public_plus_experimental_1.0.0-beta01.txt
+++ b/health/health-services-client/api/public_plus_experimental_1.0.0-beta01.txt
@@ -660,7 +660,7 @@
}
public final class LocationData {
- ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional @FloatRange double altitude, optional @FloatRange(from=-1.0, to=360.0, toInclusive=false) double bearing);
+ ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional double altitude, optional double bearing);
method public double getAltitude();
method public double getBearing();
method public double getLatitude();
@@ -669,8 +669,8 @@
property public final double bearing;
property public final double latitude;
property public final double longitude;
- field public static final double ALTITUDE_UNAVAILABLE = 1.7976931348623157E308;
- field public static final double BEARING_UNAVAILABLE = -1.0;
+ field public static final double ALTITUDE_UNAVAILABLE = (0.0/0.0);
+ field public static final double BEARING_UNAVAILABLE = (0.0/0.0);
}
public final class MeasureCapabilities {
diff --git a/health/health-services-client/api/public_plus_experimental_current.txt b/health/health-services-client/api/public_plus_experimental_current.txt
index 84e9862..e1a88ef 100644
--- a/health/health-services-client/api/public_plus_experimental_current.txt
+++ b/health/health-services-client/api/public_plus_experimental_current.txt
@@ -660,7 +660,7 @@
}
public final class LocationData {
- ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional @FloatRange double altitude, optional @FloatRange(from=-1.0, to=360.0, toInclusive=false) double bearing);
+ ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional double altitude, optional double bearing);
method public double getAltitude();
method public double getBearing();
method public double getLatitude();
@@ -669,8 +669,8 @@
property public final double bearing;
property public final double latitude;
property public final double longitude;
- field public static final double ALTITUDE_UNAVAILABLE = 1.7976931348623157E308;
- field public static final double BEARING_UNAVAILABLE = -1.0;
+ field public static final double ALTITUDE_UNAVAILABLE = (0.0/0.0);
+ field public static final double BEARING_UNAVAILABLE = (0.0/0.0);
}
public final class MeasureCapabilities {
diff --git a/health/health-services-client/api/restricted_1.0.0-beta01.txt b/health/health-services-client/api/restricted_1.0.0-beta01.txt
index 84e9862..e1a88ef 100644
--- a/health/health-services-client/api/restricted_1.0.0-beta01.txt
+++ b/health/health-services-client/api/restricted_1.0.0-beta01.txt
@@ -660,7 +660,7 @@
}
public final class LocationData {
- ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional @FloatRange double altitude, optional @FloatRange(from=-1.0, to=360.0, toInclusive=false) double bearing);
+ ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional double altitude, optional double bearing);
method public double getAltitude();
method public double getBearing();
method public double getLatitude();
@@ -669,8 +669,8 @@
property public final double bearing;
property public final double latitude;
property public final double longitude;
- field public static final double ALTITUDE_UNAVAILABLE = 1.7976931348623157E308;
- field public static final double BEARING_UNAVAILABLE = -1.0;
+ field public static final double ALTITUDE_UNAVAILABLE = (0.0/0.0);
+ field public static final double BEARING_UNAVAILABLE = (0.0/0.0);
}
public final class MeasureCapabilities {
diff --git a/health/health-services-client/api/restricted_current.txt b/health/health-services-client/api/restricted_current.txt
index 84e9862..e1a88ef 100644
--- a/health/health-services-client/api/restricted_current.txt
+++ b/health/health-services-client/api/restricted_current.txt
@@ -660,7 +660,7 @@
}
public final class LocationData {
- ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional @FloatRange double altitude, optional @FloatRange(from=-1.0, to=360.0, toInclusive=false) double bearing);
+ ctor public LocationData(@FloatRange(from=-90.0, to=90.0) double latitude, @FloatRange(from=-180.0, to=180.0) double longitude, optional double altitude, optional double bearing);
method public double getAltitude();
method public double getBearing();
method public double getLatitude();
@@ -669,8 +669,8 @@
property public final double bearing;
property public final double latitude;
property public final double longitude;
- field public static final double ALTITUDE_UNAVAILABLE = 1.7976931348623157E308;
- field public static final double BEARING_UNAVAILABLE = -1.0;
+ field public static final double ALTITUDE_UNAVAILABLE = (0.0/0.0);
+ field public static final double BEARING_UNAVAILABLE = (0.0/0.0);
}
public final class MeasureCapabilities {
diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/DataPoints.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/DataPoints.kt
index 07c0479..9d188b9 100644
--- a/health/health-services-client/src/main/java/androidx/health/services/client/data/DataPoints.kt
+++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/DataPoints.kt
@@ -391,9 +391,8 @@
@FloatRange(from = -90.0, to = 90.0) latitude: Double,
@FloatRange(from = -180.0, to = 180.0) longitude: Double,
timeDurationFromBoot: Duration,
- @FloatRange altitude: Double = LocationData.ALTITUDE_UNAVAILABLE,
- @FloatRange(from = -1.0, to = 360.0, toInclusive = false) bearing: Double =
- LocationData.BEARING_UNAVAILABLE,
+ altitude: Double = LocationData.ALTITUDE_UNAVAILABLE,
+ bearing: Double = LocationData.BEARING_UNAVAILABLE,
accuracy: LocationAccuracy? = null
): SampleDataPoint<LocationData> {
if (latitude !in -90.0..90.0) {
diff --git a/health/health-services-client/src/main/java/androidx/health/services/client/data/LocationData.kt b/health/health-services-client/src/main/java/androidx/health/services/client/data/LocationData.kt
index c1a68a5..8537b1b 100644
--- a/health/health-services-client/src/main/java/androidx/health/services/client/data/LocationData.kt
+++ b/health/health-services-client/src/main/java/androidx/health/services/client/data/LocationData.kt
@@ -27,12 +27,11 @@
/** Longitude of location. Range from -180.0 to = 180.0. */
@FloatRange(from = -180.0, to = 180.0) public val longitude: Double,
/** Altitude of location in meters or [ALTITUDE_UNAVAILABLE] if not available. */
- @FloatRange public val altitude: Double = ALTITUDE_UNAVAILABLE,
+ public val altitude: Double = ALTITUDE_UNAVAILABLE,
/** Bearing in degrees within the range of [0.0 (inclusive), 360.0(exclusive)] or
* [BEARING_UNAVAILABLE] if not available.
*/
- @FloatRange(from = -1.0, to = 360.0, toInclusive = false) public val bearing: Double =
- BEARING_UNAVAILABLE,
+ public val bearing: Double = BEARING_UNAVAILABLE,
) {
init {
if (latitude !in -90.0..90.0) {
@@ -114,10 +113,10 @@
private const val BEARING_INDEX: Int = 3
/** When using [DataType.LOCATION], the default value if altitude value is not available. */
- public const val ALTITUDE_UNAVAILABLE: Double = Double.MAX_VALUE
+ public const val ALTITUDE_UNAVAILABLE: Double = Double.NaN
/** When using [DataType.LOCATION], the default value if bearing value is not available. */
- public const val BEARING_UNAVAILABLE: Double = -1.0
+ public const val BEARING_UNAVAILABLE: Double = Double.NaN
internal fun fromDataProtoValue(proto: DataProto.Value): LocationData {
require(proto.hasDoubleArrayVal())