diff options
| author | 2019-02-01 16:03:27 -0800 | |
|---|---|---|
| committer | 2019-02-28 14:55:39 -0800 | |
| commit | 4fb074e7f41a1095c0a20bdab47a053bd9bd2551 (patch) | |
| tree | 1b63565bf1577a86e77d7a91edbb2a2e0168194f /location/java | |
| parent | 6dabb47132d6ce169a8592a209556a5791eb84d3 (diff) | |
Adding new Battery Saver location mode.
When this new mode (LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF) is
enabled, LocationManagerService will avoid sending almost all
LocationRequests to providers. The only requests that will continue to
be sent will be providers are the requests that ignore location
settings.
Bug: 121256487
Bug: 122849003
Bug: 119261320
Test: atest android.os.cts.batterysaving.BatterySaverLocationTest
Change-Id: Iee95a6fb5ca11d4db7a0f0661bf3cb1051a5d710
Diffstat (limited to 'location/java')
4 files changed, 20 insertions, 10 deletions
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl index 57a0a725fb41..142f84dc494c 100644 --- a/location/java/android/location/ILocationManager.aidl +++ b/location/java/android/location/ILocationManager.aidl @@ -102,6 +102,7 @@ interface ILocationManager void removeTestProvider(String provider, String opPackageName); void setTestProviderLocation(String provider, in Location loc, String opPackageName); void setTestProviderEnabled(String provider, boolean enabled, String opPackageName); + List<LocationRequest> getTestProviderCurrentRequests(String provider, String opPackageName); // --- deprecated --- void setTestProviderStatus(String provider, int status, in Bundle extras, long updateTime, diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 586ee2a43683..6828c597fe9a 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -1626,6 +1626,23 @@ public class LocationManager { setTestProviderStatus(provider, LocationProvider.AVAILABLE, null, 0L); } + /** + * Get the last list of {@link LocationRequest}s sent to the provider. + * + * @hide + */ + @TestApi + @NonNull + public List<LocationRequest> getTestProviderCurrentRequests(String providerName) { + checkProvider(providerName); + try { + return mService.getTestProviderCurrentRequests(providerName, + mContext.getOpPackageName()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + // --- GPS-specific support --- // This class is used to send Gnss status events to the client's specific thread. diff --git a/location/java/android/location/LocationRequest.java b/location/java/android/location/LocationRequest.java index b3953fddb622..37770c662c6e 100644 --- a/location/java/android/location/LocationRequest.java +++ b/location/java/android/location/LocationRequest.java @@ -270,7 +270,7 @@ public final class LocationRequest implements Parcelable { * Set the quality of the request. * * <p>Use with a accuracy constant such as {@link #ACCURACY_FINE}, or a power - * constant such as {@link #POWER_LOW}. You cannot request both and accuracy and + * constant such as {@link #POWER_LOW}. You cannot request both accuracy and * power, only one or the other can be specified. The system will then * maximize accuracy or minimize power as appropriate. * @@ -384,10 +384,8 @@ public final class LocationRequest implements Parcelable { * * @param locationSettingsIgnored Whether to ignore location settings * @return the same object, so that setters can be chained - * @hide */ @RequiresPermission(Manifest.permission.WRITE_SECURE_SETTINGS) - @SystemApi public LocationRequest setLocationSettingsIgnored(boolean locationSettingsIgnored) { mLocationSettingsIgnored = locationSettingsIgnored; return this; @@ -395,10 +393,7 @@ public final class LocationRequest implements Parcelable { /** * Returns true if location settings will be ignored in order to satisfy this request. - * - * @hide */ - @SystemApi public boolean isLocationSettingsIgnored() { return mLocationSettingsIgnored; } @@ -558,9 +553,6 @@ public final class LocationRequest implements Parcelable { } } - - /** @hide */ - @SystemApi public LocationRequest setProvider(String provider) { checkProvider(provider); mProvider = provider; diff --git a/location/java/com/android/internal/location/ProviderRequest.java b/location/java/com/android/internal/location/ProviderRequest.java index af8123ac52f4..155f788cb33e 100644 --- a/location/java/com/android/internal/location/ProviderRequest.java +++ b/location/java/com/android/internal/location/ProviderRequest.java @@ -56,7 +56,7 @@ public final class ProviderRequest implements Parcelable { * low power fast interval request. */ @UnsupportedAppUsage - public List<LocationRequest> locationRequests = new ArrayList<LocationRequest>(); + public final List<LocationRequest> locationRequests = new ArrayList<>(); @UnsupportedAppUsage public ProviderRequest() { |