Switch location Settings and Power widget to use new Settings api.

Change-Id: I06b7a2e21876a18d9ad42fda2a6c6d4c7b6add48
This commit is contained in:
David Christie
2013-08-20 15:24:21 -07:00
parent 0f5578ce2d
commit 512183ea8e
4 changed files with 28 additions and 69 deletions

View File

@@ -521,7 +521,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
@Override
public int getActualState(Context context) {
ContentResolver resolver = context.getContentResolver();
return Settings.Secure.isLocationMasterSwitchEnabled(resolver)
return Settings.Secure.getLocationMode(resolver) != Settings.Secure.LOCATION_MODE_OFF
? STATE_ENABLED : STATE_DISABLED;
}
@@ -541,11 +541,15 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
final UserManager um =
(UserManager) context.getSystemService(Context.USER_SERVICE);
if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
Settings.Secure.setLocationMasterSwitchEnabled(resolver, desiredState);
int mode = desiredState
? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY
: Settings.Secure.LOCATION_MODE_OFF;
Settings.Secure.setLocationMode(resolver, mode);
return desiredState;
}
return Settings.Secure.isLocationMasterSwitchEnabled(resolver);
return Settings.Secure.getLocationMode(resolver)
!= Settings.Secure.LOCATION_MODE_OFF;
}
@Override