summaryrefslogtreecommitdiff
path: root/location
diff options
context:
space:
mode:
authorSoonil Nagarkar <sooniln@google.com>2020-07-15 11:28:58 -0700
committerSoonil Nagarkar <sooniln@google.com>2020-07-15 13:12:54 -0700
commitd9df33d1c0e9db71f108e6935f3e2b267bd58059 (patch)
tree62f361752538113cfee9ac9c043f527c6c50ef2c /location
parent218b61acf4f7303ee2073bcad0cdf9dc167610c8 (diff)
DO NOT MERGE: Always return non null from getGpsStatus
Even though getGpsStatus is marked Nullable, some applications expect it to always return non-null. Bug: 161311411 Test: presubmits Change-Id: I8d58621588253af1dc917711e230cfd176afec37
Diffstat (limited to 'location')
-rw-r--r--location/java/android/location/GpsStatus.java9
-rw-r--r--location/java/android/location/LocationManager.java5
2 files changed, 14 insertions, 0 deletions
diff --git a/location/java/android/location/GpsStatus.java b/location/java/android/location/GpsStatus.java
index 496885cd1f37..6a689756a1c0 100644
--- a/location/java/android/location/GpsStatus.java
+++ b/location/java/android/location/GpsStatus.java
@@ -151,6 +151,15 @@ public final class GpsStatus {
return status;
}
+ /**
+ * Builds an empty GpsStatus.
+ *
+ * @hide
+ */
+ static GpsStatus createEmpty() {
+ return new GpsStatus();
+ }
+
private GpsStatus() {
}
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 241e9399be0a..2a2aaea035ff 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -1922,12 +1922,17 @@ public class LocationManager {
GnssStatus gnssStatus = mGnssStatusListenerManager.getGnssStatus();
int ttff = mGnssStatusListenerManager.getTtff();
+
+ // even though this method is marked nullable, there are legacy applications that expect
+ // this to never return null, so avoid breaking those apps
if (gnssStatus != null) {
if (status == null) {
status = GpsStatus.create(gnssStatus, ttff);
} else {
status.setStatus(gnssStatus, ttff);
}
+ } else if (status == null) {
+ status = GpsStatus.createEmpty();
}
return status;
}