Listen for changes to location pProvider enabled settings.

This is needed so we can correctly update the network location checkbox
if the network location provider is disabled because the user disagreed
to the terms of service in a dialog shown by the provider.

Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2009-06-07 23:07:20 -04:00
parent d13308674b
commit 5ed2c4ad43

View File

@@ -18,9 +18,11 @@ package com.android.settings;
import android.app.Activity;
import android.content.ContentQueryMap;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.location.LocationManager;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
@@ -32,6 +34,9 @@ import android.provider.Settings;
import android.util.Config;
import android.util.Log;
import java.util.Observable;
import java.util.Observer;
import com.android.internal.widget.LockPatternUtils;
/**
@@ -62,6 +67,16 @@ public class SecuritySettings extends PreferenceActivity {
private CheckBoxPreference mNetwork;
private CheckBoxPreference mGps;
// These provide support for receiving notification when Location Manager settings change.
// This is necessary because the Network Location Provider can change settings
// if the user does not confirm enabling the provider.
private ContentQueryMap mContentQueryMap;
private final class SettingsObserver implements Observer {
public void update(Observable o, Object arg) {
updateToggles();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -74,6 +89,14 @@ public class SecuritySettings extends PreferenceActivity {
mNetwork = (CheckBoxPreference) getPreferenceScreen().findPreference(LOCATION_NETWORK);
mGps = (CheckBoxPreference) getPreferenceScreen().findPreference(LOCATION_GPS);
updateToggles();
// listen for Location Manager settings changes
Cursor settingsCursor = getContentResolver().query(Settings.Secure.CONTENT_URI, null,
"(" + Settings.System.NAME + "=?)",
new String[]{Settings.Secure.LOCATION_PROVIDERS_ALLOWED},
null);
mContentQueryMap = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, null);
mContentQueryMap.addObserver(new SettingsObserver());
}
private PreferenceScreen createPreferenceHierarchy() {