From 06e37f67de54ea047039ef9a98eb37861ece89c7 Mon Sep 17 00:00:00 2001 From: Soonil Nagarkar Date: Wed, 4 Dec 2019 16:05:08 -0800 Subject: Update location broadcast behavior Updates location broadcast behavior in preparation for future changes that will remove writes to LOCATION_PROVIDERS_ALLOWED. These changes ensure that clients can properly listen for changes to provider enabled status without being reliant on the deprecated LOCATION_PROVIDERS_ALLOWED. Bug: 145752928 Test: presubmits Change-Id: I073749a895a6a206023290d83ea815a361353460 --- .../java/android/location/LocationManager.java | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'location/java/android') diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index c0041722c475..1f8c1d5352b0 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -164,24 +164,51 @@ public class LocationManager { * Broadcast intent action when the set of enabled location providers changes. To check the * status of a provider, use {@link #isProviderEnabled(String)}. From Android Q and above, will * include a string intent extra, {@link #EXTRA_PROVIDER_NAME}, with the name of the provider - * whose state has changed. + * whose state has changed. From Android R and above, will include a boolean intent extra, + * {@link #EXTRA_PROVIDER_ENABLED}, with the enabled state of the provider. * * @see #EXTRA_PROVIDER_NAME + * @see #EXTRA_PROVIDER_ENABLED + * @see #isProviderEnabled(String) */ public static final String PROVIDERS_CHANGED_ACTION = "android.location.PROVIDERS_CHANGED"; /** * Intent extra included with {@link #PROVIDERS_CHANGED_ACTION} broadcasts, containing the name - * of the location provider that has changed, to be used with location provider APIs. + * of the location provider that has changed. + * + * @see #PROVIDERS_CHANGED_ACTION + * @see #EXTRA_PROVIDER_ENABLED */ public static final String EXTRA_PROVIDER_NAME = "android.location.extra.PROVIDER_NAME"; /** - * Broadcast intent action when the device location mode changes. To check the location mode, - * use {@link #isLocationEnabled()}. + * Intent extra included with {@link #PROVIDERS_CHANGED_ACTION} broadcasts, containing the + * boolean enabled state of the location provider that has changed. + * + * @see #PROVIDERS_CHANGED_ACTION + * @see #EXTRA_PROVIDER_NAME + */ + public static final String EXTRA_PROVIDER_ENABLED = "android.location.extra.PROVIDER_ENABLED"; + + /** + * Broadcast intent action when the device location enabled state changes. From Android R and + * above, will include a boolean intent extra, {@link #EXTRA_LOCATION_ENABLED}, with the enabled + * state of location. + * + * @see #EXTRA_LOCATION_ENABLED + * @see #isLocationEnabled() */ public static final String MODE_CHANGED_ACTION = "android.location.MODE_CHANGED"; + /** + * Intent extra included with {@link #MODE_CHANGED_ACTION} broadcasts, containing the boolean + * enabled state of location. + * + * @see #MODE_CHANGED_ACTION + */ + public static final String EXTRA_LOCATION_ENABLED = "android.location.extra.LOCATION_ENABLED"; + /** * Broadcast intent action indicating that a high power location requests * has either started or stopped being active. The current state of -- cgit v1.2.3-59-g8ed1b