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
This commit is contained in:
Soonil Nagarkar
2019-12-04 16:05:08 -08:00
parent 4d4e91db5e
commit 06e37f67de
3 changed files with 102 additions and 83 deletions

View File

@@ -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