Merge "Fixed the widget location toggle button" into klp-dev

This commit is contained in:
Lifu Tang
2013-08-29 18:31:27 +00:00
committed by Android (Google) Code Review

View File

@@ -548,9 +548,23 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
final UserManager um = final UserManager um =
(UserManager) context.getSystemService(Context.USER_SERVICE); (UserManager) context.getSystemService(Context.USER_SERVICE);
if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) { if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
int mode = desiredState int currentMode = Settings.Secure.getInt(resolver,
? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
: Settings.Secure.LOCATION_MODE_BATTERY_SAVING; 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); Settings.Secure.putInt(resolver, Settings.Secure.LOCATION_MODE, mode);
return desiredState; return desiredState;
} }