Moved restricted profile setup logic to UserManagerService

Bug: 24212155
Change-Id: Iea214877dd856e830a42467780b7407b8991c52d
This commit is contained in:
Fyodor Kupolov
2015-09-18 18:22:24 -07:00
parent 39090f1cba
commit 1f432586b3
3 changed files with 4 additions and 19 deletions

View File

@@ -396,23 +396,7 @@ public class UserSettings extends SettingsPreferenceFragment
private UserInfo createRestrictedProfile() {
UserInfo newUserInfo = mUserManager.createRestrictedProfile(
getResources().getString(R.string.user_new_profile_name));
int userId = newUserInfo.id;
UserHandle user = new UserHandle(userId);
mUserManager.setUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS, true, user);
// Change the setting before applying the DISALLOW_SHARE_LOCATION restriction, otherwise
// the putIntForUser() will fail.
Secure.putIntForUser(getContentResolver(),
Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF, userId);
mUserManager.setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, user);
assignDefaultPhoto(newUserInfo);
// Add shared accounts
AccountManager am = AccountManager.get(getActivity());
Account [] accounts = am.getAccounts();
if (accounts != null) {
for (Account account : accounts) {
am.addSharedAccount(account, user);
}
}
return newUserInfo;
}