am 68093520: Merge "Fix GPS settings change listener in LocManager" into jb-mr1-dev

* commit '68093520872476fc19b50c096a9536a826c084e5':
  Fix GPS settings change listener in LocManager
This commit is contained in:
Brian Muramatsu
2012-09-04 18:39:31 -07:00
committed by Android Git Automerger

View File

@@ -26,6 +26,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.database.Cursor;
import android.location.Address;
import android.location.Criteria;
@@ -87,7 +88,7 @@ import java.util.Set;
* The service class that manages LocationProviders and issues location
* updates and alerts.
*/
public class LocationManagerService extends ILocationManager.Stub implements Observer, Runnable {
public class LocationManagerService extends ILocationManager.Stub implements Runnable {
private static final String TAG = "LocationManagerService";
public static final boolean D = false;
@@ -207,24 +208,30 @@ public class LocationManagerService extends ILocationManager.Stub implements Obs
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_KEY);
mPackageManager = mContext.getPackageManager();
mBlacklist = new LocationBlacklist(mContext, mLocationHandler);
mBlacklist.init();
mLocationFudger = new LocationFudger();
synchronized (mLock) {
loadProvidersLocked();
}
mBlacklist = new LocationBlacklist(mContext, mLocationHandler);
mBlacklist.init();
mGeofenceManager = new GeofenceManager(mContext, mBlacklist);
mLocationFudger = new LocationFudger();
// listen for settings changes
ContentResolver resolver = mContext.getContentResolver();
Cursor settingsCursor = resolver.query(Settings.Secure.CONTENT_URI, null,
"(" + NameValueTable.NAME + "=?)",
new String[]{Settings.Secure.LOCATION_PROVIDERS_ALLOWED}, null);
ContentQueryMap query = new ContentQueryMap(settingsCursor, NameValueTable.NAME, true,
mLocationHandler);
settingsCursor.close();
query.addObserver(this);
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.LOCATION_PROVIDERS_ALLOWED), true,
new ContentObserver(mLocationHandler) {
@Override
public void onChange(boolean selfChange) {
synchronized (mLock) {
updateProvidersLocked();
}
}
});
mPackageMonitor.register(mContext, Looper.myLooper(), true);
updateProvidersLocked();
}
private void loadProvidersLocked() {
@@ -299,8 +306,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Obs
if (mGeocodeProvider == null) {
Slog.e(TAG, "no geocoder provider found");
}
updateProvidersLocked();
}
/**
@@ -544,14 +549,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Obs
}
}
/** Settings Observer callback */
@Override
public void update(Observable o, Object arg) {
synchronized (mLock) {
updateProvidersLocked();
}
}
private void addProviderLocked(LocationProviderInterface provider) {
mProviders.add(provider);
mProvidersByName.put(provider.getName(), provider);