diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java index da085f745c8..bf3f4977873 100644 --- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java +++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java @@ -548,9 +548,23 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider { final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) { - int mode = desiredState - ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY - : Settings.Secure.LOCATION_MODE_BATTERY_SAVING; + int currentMode = Settings.Secure.getInt(resolver, + Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF); + int mode = Settings.Secure.LOCATION_MODE_HIGH_ACCURACY; + switch (currentMode) { + case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY: + mode = Settings.Secure.LOCATION_MODE_BATTERY_SAVING; + break; + case Settings.Secure.LOCATION_MODE_BATTERY_SAVING: + mode = Settings.Secure.LOCATION_MODE_HIGH_ACCURACY; + break; + case Settings.Secure.LOCATION_MODE_SENSORS_ONLY: + mode = Settings.Secure.LOCATION_MODE_OFF; + break; + case Settings.Secure.LOCATION_MODE_OFF: + mode = Settings.Secure.LOCATION_MODE_HIGH_ACCURACY; + break; + } Settings.Secure.putInt(resolver, Settings.Secure.LOCATION_MODE, mode); return desiredState; }