diff options
author | Soonil Nagarkar <sooniln@google.com> | 2020-01-24 13:12:41 -0800 |
---|---|---|
committer | Soonil Nagarkar <sooniln@google.com> | 2020-01-24 13:32:26 -0800 |
commit | 56a2a445372e47cccdbf35249142adfaa44af6cb (patch) | |
tree | 151a9549a8f8a95ed0f7b512680bb97ffe0a95ff | |
parent | 4b0dec268d45ec89d884fe0e054cf255af8eee8a (diff) |
Remove setLocationExtra per API feedback
Bug: 142828735
Test: atest LocationManagerFineTest
Change-Id: I73193dc2484a2b8051c5cff42cd3fcec9a44a015
-rwxr-xr-x | api/system-current.txt | 1 | ||||
-rw-r--r-- | api/test-current.txt | 1 | ||||
-rw-r--r-- | location/java/android/location/Location.java | 18 | ||||
-rw-r--r-- | services/core/java/com/android/server/LocationManagerService.java | 7 | ||||
-rw-r--r-- | services/core/java/com/android/server/location/LocationFudger.java | 15 |
5 files changed, 17 insertions, 25 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index a4e9136e5dce..1ecefeea81c1 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4091,7 +4091,6 @@ package android.location { public class Location implements android.os.Parcelable { method public boolean isComplete(); method public void makeComplete(); - method public void setExtraLocation(@Nullable String, @Nullable android.location.Location); method public void setIsFromMockProvider(boolean); field public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation"; } diff --git a/api/test-current.txt b/api/test-current.txt index 76af40318fb8..e07217f2732d 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -1270,7 +1270,6 @@ package android.location { public class Location implements android.os.Parcelable { method public void makeComplete(); - method public void setExtraLocation(@Nullable String, @Nullable android.location.Location); field public static final String EXTRA_NO_GPS_LOCATION = "noGPSLocation"; } diff --git a/location/java/android/location/Location.java b/location/java/android/location/Location.java index 7a12cee899d8..eb76c29301c6 100644 --- a/location/java/android/location/Location.java +++ b/location/java/android/location/Location.java @@ -16,7 +16,6 @@ package android.location; -import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TestApi; import android.compat.annotation.UnsupportedAppUsage; @@ -1214,23 +1213,6 @@ public class Location implements Parcelable { } /** - * Attaches an extra {@link Location} to this Location. This is useful for location providers - * to set the {@link #EXTRA_NO_GPS_LOCATION} extra to provide coarse locations for clients. - * - * @param key the key associated with the Location extra - * @param value the Location to attach - * @hide - */ - @TestApi - @SystemApi - public void setExtraLocation(@Nullable String key, @Nullable Location value) { - if (mExtras == null) { - mExtras = new Bundle(); - } - mExtras.putParcelable(key, value); - } - - /** * Returns true if the Location came from a mock provider. * * @return true if this Location came from a mock provider, false otherwise diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java index de0b6fcbd4ae..14dc9deebaee 100644 --- a/services/core/java/com/android/server/LocationManagerService.java +++ b/services/core/java/com/android/server/LocationManagerService.java @@ -2704,7 +2704,12 @@ public class LocationManagerService extends ILocationManager.Stub { if (noGPSLocation == null && lastNoGPSLocation != null) { // New location has no no-GPS location: adopt last no-GPS location. This is set // directly into location because we do not want to notify COARSE clients. - location.setExtraLocation(Location.EXTRA_NO_GPS_LOCATION, lastNoGPSLocation); + Bundle extras = location.getExtras(); + if (extras == null) { + extras = new Bundle(); + } + extras.putParcelable(Location.EXTRA_NO_GPS_LOCATION, lastNoGPSLocation); + location.setExtras(extras); } } lastLocation.set(location); diff --git a/services/core/java/com/android/server/location/LocationFudger.java b/services/core/java/com/android/server/location/LocationFudger.java index ae71fe36c31c..04c7714f07f7 100644 --- a/services/core/java/com/android/server/location/LocationFudger.java +++ b/services/core/java/com/android/server/location/LocationFudger.java @@ -16,17 +16,19 @@ package com.android.server.location; -import java.io.FileDescriptor; -import java.io.PrintWriter; -import java.security.SecureRandom; import android.content.Context; import android.database.ContentObserver; import android.location.Location; +import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.provider.Settings; import android.util.Log; +import java.io.FileDescriptor; +import java.io.PrintWriter; +import java.security.SecureRandom; + /** * Contains the logic to obfuscate (fudge) locations for coarse applications. @@ -177,7 +179,12 @@ public class LocationFudger { private Location addCoarseLocationExtraLocked(Location location) { Location coarse = createCoarseLocked(location); - location.setExtraLocation(Location.EXTRA_COARSE_LOCATION, coarse); + Bundle extras = location.getExtras(); + if (extras == null) { + extras = new Bundle(); + } + extras.putParcelable(Location.EXTRA_COARSE_LOCATION, coarse); + location.setExtras(extras); return coarse; } |