Merge "Add PROVIDERS_CHANGED_ACTION extra for provider"

This commit is contained in:
Soonil Nagarkar
2019-03-18 21:45:44 +00:00
committed by Android (Google) Code Review
3 changed files with 21 additions and 5 deletions

View File

@@ -22965,6 +22965,7 @@ package android.location {
method public void unregisterGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback);
method public void unregisterGnssNavigationMessageCallback(@NonNull android.location.GnssNavigationMessage.Callback);
method public void unregisterGnssStatusCallback(@NonNull android.location.GnssStatus.Callback);
field public static final String EXTRA_PROVIDER_NAME = "android.location.extra.PROVIDER_NAME";
field public static final String GPS_PROVIDER = "gps";
field public static final String KEY_LOCATION_CHANGED = "location";
field public static final String KEY_PROVIDER_ENABLED = "providerEnabled";

View File

@@ -167,10 +167,20 @@ 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)}.
* status of a provider, use {@link #isProviderEnabled(String)}. Depending on API level, may
* include a string intent extra, {@link #EXTRA_PROVIDER_NAME}, with the name of the provider
* whose state has changed. See {@link #EXTRA_PROVIDER_NAME} for the supported API level.
*
* @see #EXTRA_PROVIDER_NAME
*/
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.
*/
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()}.

View File

@@ -501,6 +501,8 @@ public class LocationManagerService extends ILocationManager.Stub {
}
if (broadcast) {
// needs to be sent to everyone because we don't know which user may have changed
// LOCATION_MODE state.
mContext.sendBroadcastAsUser(
new Intent(LocationManager.MODE_CHANGED_ACTION),
UserHandle.ALL);
@@ -1212,6 +1214,13 @@ public class LocationManagerService extends ILocationManager.Stub {
"-" + mName,
mCurrentUserId);
}
// needs to be sent to all users because whether or not a provider is enabled for
// a given user is complicated... we broadcast to everyone and let them figure it
// out via isProviderEnabled()
Intent intent = new Intent(LocationManager.PROVIDERS_CHANGED_ACTION);
intent.putExtra(LocationManager.EXTRA_PROVIDER_NAME, mName);
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
}
if (useable == mUseable) {
@@ -1232,10 +1241,6 @@ public class LocationManagerService extends ILocationManager.Stub {
}
updateProviderUseableLocked(this);
mContext.sendBroadcastAsUser(
new Intent(LocationManager.PROVIDERS_CHANGED_ACTION),
UserHandle.ALL);
}
@GuardedBy("mLock")