summaryrefslogtreecommitdiff
path: root/location/java
diff options
context:
space:
mode:
author Soonil Nagarkar <sooniln@google.com> 2019-11-12 17:31:11 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-11-12 17:31:11 +0000
commit4fc597fe15185a6816f20aa60d87dbb3104f8aad (patch)
treee791f76a1b4c3acf924746fe9bca33430f8cde52 /location/java
parentb4eae193e8b90fa61ea58655b6e41b2137cdb327 (diff)
parent394b86831bee279822a74d012830f9b2a50168d6 (diff)
Merge "Reduce GpsStatus API crashes to SDK S+"
Diffstat (limited to 'location/java')
-rw-r--r--location/java/android/location/LocationManager.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index c48f6e83ff20..2eef2747d682 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -1810,6 +1810,14 @@ public class LocationManager {
@Deprecated
@RequiresPermission(ACCESS_FINE_LOCATION)
public @Nullable GpsStatus getGpsStatus(@Nullable GpsStatus status) {
+ UnsupportedOperationException ex = new UnsupportedOperationException(
+ "GpsStatus APIs not supported in S and above, use GnssStatus APIs instead");
+ if (mContext.getApplicationInfo().targetSdkVersion > Build.VERSION_CODES.R) {
+ throw ex;
+ } else {
+ Log.w(TAG, ex);
+ }
+
if (status == null) {
status = new GpsStatus();
}
@@ -1837,8 +1845,8 @@ public class LocationManager {
@RequiresPermission(ACCESS_FINE_LOCATION)
public boolean addGpsStatusListener(GpsStatus.Listener listener) {
UnsupportedOperationException ex = new UnsupportedOperationException(
- "GpsStatus APIs not supported in R and above, use GnssStatus APIs instead");
- if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.R) {
+ "GpsStatus APIs not supported in S and above, use GnssStatus APIs instead");
+ if (mContext.getApplicationInfo().targetSdkVersion > Build.VERSION_CODES.R) {
throw ex;
} else {
Log.w(TAG, ex);
@@ -1862,8 +1870,8 @@ public class LocationManager {
@Deprecated
public void removeGpsStatusListener(GpsStatus.Listener listener) {
UnsupportedOperationException ex = new UnsupportedOperationException(
- "GpsStatus APIs not supported in R and above, use GnssStatus APIs instead");
- if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.R) {
+ "GpsStatus APIs not supported in S and above, use GnssStatus APIs instead");
+ if (mContext.getApplicationInfo().targetSdkVersion > Build.VERSION_CODES.R) {
throw ex;
} else {
Log.w(TAG, ex);