From 151dffcd649329741d6b49f17dea4598a2ba30ec Mon Sep 17 00:00:00 2001 From: Fyodor Kupolov Date: Fri, 18 Sep 2015 18:22:24 -0700 Subject: [PATCH] Moved restricted profile setup logic to UserManagerService Bug: 24212155 Change-Id: Ifd19cf5833fb8f2d61cfd6d0019849aa27701c38 --- src/com/android/settings/DeviceAdminAdd.java | 3 ++- .../android/settings/accounts/AccountSyncSettings.java | 4 ++-- src/com/android/settings/users/UserSettings.java | 16 ---------------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java index bcd247e0ca..6c6f8d3c67 100644 --- a/src/com/android/settings/DeviceAdminAdd.java +++ b/src/com/android/settings/DeviceAdminAdd.java @@ -38,6 +38,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.res.Resources; +import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.RemoteCallback; @@ -472,7 +473,7 @@ public class DeviceAdminAdd extends Activity { private void addDeviceAdminPolicies(boolean showDescription) { if (!mAdminPoliciesInitialized) { - boolean isOwner = UserHandle.getCallingUserHandle().isOwner(); + boolean isOwner = Binder.getCallingUserHandle().isOwner(); for (DeviceAdminInfo.PolicyInfo pi : mDeviceAdmin.getUsedPolicies()) { int descriptionId = isOwner ? pi.description : pi.descriptionForSecondaryUsers; int labelId = isOwner ? pi.label : pi.labelForSecondaryUsers; diff --git a/src/com/android/settings/accounts/AccountSyncSettings.java b/src/com/android/settings/accounts/AccountSyncSettings.java index 59ca995ba0..2fbae85036 100644 --- a/src/com/android/settings/accounts/AccountSyncSettings.java +++ b/src/com/android/settings/accounts/AccountSyncSettings.java @@ -36,6 +36,7 @@ import android.content.SyncInfo; import android.content.SyncStatusInfo; import android.content.pm.ProviderInfo; import android.content.pm.UserInfo; +import android.os.Binder; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; @@ -219,8 +220,7 @@ public class AccountSyncSettings extends AccountPreferenceBase { removePreference("dummy"); mAuthenticatorHelper.listenToAccountUpdates(); updateAuthDescriptions(); - onAccountsUpdate(UserHandle.getCallingUserHandle()); - + onAccountsUpdate(Binder.getCallingUserHandle()); super.onResume(); } diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java index 1211c7682b..d62d672cfe 100644 --- a/src/com/android/settings/users/UserSettings.java +++ b/src/com/android/settings/users/UserSettings.java @@ -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; } -- 2.11.0