Settings: Add preference to enable/disable assisted GPS.

Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2009-06-25 16:39:48 -04:00
parent a4e9f21075
commit d75fb2f92f
3 changed files with 27 additions and 3 deletions

View File

@@ -1143,6 +1143,12 @@
<string name="location_street_level">When locating, accurate to street level (deselect to conserve battery)</string>
<!-- Security & location settings screen, setting summary when Enable GPS satellites check box is clear -->
<string name="location_gps_disabled">Locate to street-level (requires more battery plus view of sky)</string>
<!-- Security & location settings screen, setting check box label if Assisted GPS should be enabled -->
<string name="assisted_gps">Enable assisted GPS</string>
<!-- Security & location settings screen, setting summary when Assisted GPS check box is selected -->
<string name="assisted_gps_enabled">Use server to assist GPS (deselect to reduce network usage)</string>
<!-- Security & location settings screen, setting summary when Assisted GPS check box is clear -->
<string name="assisted_gps_disabled">Use server to assist GPS (select to improve GPS performance)</string>
<!-- Setting title for allow sending location to google -->
<string name="use_location_title">Share with Google</string>
<!-- Title of dialog to user requesting use of location information to improve services -->

View File

@@ -32,6 +32,12 @@
android:summaryOn="@string/location_street_level"
android:summaryOff="@string/location_gps_disabled"/>
<CheckBoxPreference
android:key="assisted_gps"
android:title="@string/assisted_gps"
android:summaryOn="@string/assisted_gps_enabled"
android:summaryOff="@string/assisted_gps_disabled"/>
<CheckBoxPreference
android:key="use_location"
android:title="@string/use_location_title"

View File

@@ -70,6 +70,7 @@ public class SecuritySettings extends PreferenceActivity implements
private static final String LOCATION_CATEGORY = "location_category";
private static final String LOCATION_NETWORK = "location_network";
private static final String LOCATION_GPS = "location_gps";
private static final String ASSISTED_GPS = "assisted_gps";
// Vendor specific
private static final String GSETTINGS_PROVIDER = "com.google.android.providers.settings";
@@ -81,6 +82,7 @@ public class SecuritySettings extends PreferenceActivity implements
private CheckBoxPreference mNetwork;
private CheckBoxPreference mGps;
private CheckBoxPreference mAssistedGps;
// These provide support for receiving notification when Location Manager settings change.
// This is necessary because the Network Location Provider can change settings
@@ -103,6 +105,7 @@ public class SecuritySettings extends PreferenceActivity implements
mNetwork = (CheckBoxPreference) getPreferenceScreen().findPreference(LOCATION_NETWORK);
mGps = (CheckBoxPreference) getPreferenceScreen().findPreference(LOCATION_GPS);
mAssistedGps = (CheckBoxPreference) getPreferenceScreen().findPreference(ASSISTED_GPS);
mUseLocation = (CheckBoxPreference) getPreferenceScreen().findPreference(USE_LOCATION);
// Vendor specific
@@ -263,8 +266,13 @@ public class SecuritySettings extends PreferenceActivity implements
Settings.Secure.setLocationProviderEnabled(getContentResolver(),
LocationManager.NETWORK_PROVIDER, mNetwork.isChecked());
} else if (preference == mGps) {
boolean enabled = mGps.isChecked();
Settings.Secure.setLocationProviderEnabled(getContentResolver(),
LocationManager.GPS_PROVIDER, mGps.isChecked());
LocationManager.GPS_PROVIDER, enabled);
mAssistedGps.setEnabled(enabled);
} else if (preference == mAssistedGps) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSISTED_GPS_ENABLED,
mAssistedGps.isChecked() ? 1 : 0);
} else if (preference == mUseLocation) {
//normally called on the toggle click
if (mUseLocation.isChecked()) {
@@ -306,10 +314,14 @@ public class SecuritySettings extends PreferenceActivity implements
*/
private void updateToggles() {
ContentResolver res = getContentResolver();
boolean gpsEnabled = Settings.Secure.isLocationProviderEnabled(
res, LocationManager.GPS_PROVIDER);
mNetwork.setChecked(Settings.Secure.isLocationProviderEnabled(
res, LocationManager.NETWORK_PROVIDER));
mGps.setChecked(Settings.Secure.isLocationProviderEnabled(
res, LocationManager.GPS_PROVIDER));
mGps.setChecked(gpsEnabled);
mAssistedGps.setChecked(Settings.Secure.getInt(res,
Settings.Secure.ASSISTED_GPS_ENABLED, 2) == 1);
mAssistedGps.setEnabled(gpsEnabled);
mUseLocation.setChecked(Settings.Secure.getInt(res,
Settings.Secure.USE_LOCATION_FOR_SERVICES, 2) == 1);
}