am 0c731f99: Merge "Send broadcast intent when configured location providers change." into gingerbread

Merge commit '0c731f99b05630e16dce572ac206ab75c90891cd' into gingerbread-plus-aosp

* commit '0c731f99b05630e16dce572ac206ab75c90891cd':
  Send broadcast intent when configured location providers change.
This commit is contained in:
Brad Fitzpatrick
2010-08-27 16:10:06 -07:00
committed by Android Git Automerger
2 changed files with 13 additions and 2 deletions

View File

@ -126,6 +126,13 @@ public class LocationManager {
public static final String GPS_ENABLED_CHANGE_ACTION =
"android.location.GPS_ENABLED_CHANGE";
/**
* Broadcast intent action when the configured location providers
* change.
*/
public static final String PROVIDERS_CHANGED_ACTION =
"android.location.PROVIDERS_CHANGED";
/**
* Broadcast intent action indicating that the GPS has either started or
* stopped receiving GPS fixes. An intent extra provides this state as a

View File

@ -858,18 +858,22 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
}
private void updateProvidersLocked() {
boolean changesMade = false;
for (int i = mProviders.size() - 1; i >= 0; i--) {
LocationProviderInterface p = mProviders.get(i);
boolean isEnabled = p.isEnabled();
String name = p.getName();
boolean shouldBeEnabled = isAllowedBySettingsLocked(name);
if (isEnabled && !shouldBeEnabled) {
updateProviderListenersLocked(name, false);
changesMade = true;
} else if (!isEnabled && shouldBeEnabled) {
updateProviderListenersLocked(name, true);
changesMade = true;
}
}
if (changesMade) {
mContext.sendBroadcast(new Intent(LocationManager.PROVIDERS_CHANGED_ACTION));
}
}