am 5301d57c: am 1f2779f2: Merge "Fixed the widget location toggle button" into klp-dev

* commit '5301d57cbe9c5e7c11f842188fb8a13127918e68':
  Fixed the widget location toggle button
This commit is contained in:
Lifu Tang
2013-08-29 11:35:22 -07:00
committed by Android Git Automerger

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;
} }