Change the location mode before applying restrictions

Once the location sharing restriction is applied, the setting cannot
be changed, so change the setting first.

Bug: 17348894
Change-Id: I9dcad230e816aaa2482f1f35f1993f51d14eabc7
This commit is contained in:
Amith Yamasani
2014-09-02 17:10:18 -07:00
parent def48d605a
commit 92c5452f08

View File

@@ -418,9 +418,11 @@ public class UserSettings extends SettingsPreferenceFragment
int userId = newUserInfo.id; int userId = newUserInfo.id;
UserHandle user = new UserHandle(userId); UserHandle user = new UserHandle(userId);
mUserManager.setUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, true, user); mUserManager.setUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, true, user);
mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user); // Change the setting before applying the DISALLOW_SHARE_LOCATION restriction, otherwise
// the putIntForUser() will fail.
Secure.putIntForUser(getContentResolver(), Secure.putIntForUser(getContentResolver(),
Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF, userId); Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF, userId);
mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user);
Bitmap bitmap = createBitmapFromDrawable( Bitmap bitmap = createBitmapFromDrawable(
USER_DRAWABLES[userId % UserSettings.USER_DRAWABLES.length]); USER_DRAWABLES[userId % UserSettings.USER_DRAWABLES.length]);
mUserManager.setUserIcon(userId, bitmap); mUserManager.setUserIcon(userId, bitmap);