Revert "Moved restricted profile setup logic to UserManagerService"

This reverts commit 151dffcd64.

Change-Id: If98fddcfc8f46c77e3491f7a9fc918ed3752a0e8
This commit is contained in:
Bart Sears
2015-09-26 02:00:46 +00:00
parent 151dffcd64
commit fbd126e423
3 changed files with 19 additions and 4 deletions

View File

@@ -38,7 +38,6 @@ 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;
@@ -473,7 +472,7 @@ public class DeviceAdminAdd extends Activity {
private void addDeviceAdminPolicies(boolean showDescription) {
if (!mAdminPoliciesInitialized) {
boolean isOwner = Binder.getCallingUserHandle().isOwner();
boolean isOwner = UserHandle.getCallingUserHandle().isOwner();
for (DeviceAdminInfo.PolicyInfo pi : mDeviceAdmin.getUsedPolicies()) {
int descriptionId = isOwner ? pi.description : pi.descriptionForSecondaryUsers;
int labelId = isOwner ? pi.label : pi.labelForSecondaryUsers;

View File

@@ -36,7 +36,6 @@ 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;
@@ -220,7 +219,8 @@ public class AccountSyncSettings extends AccountPreferenceBase {
removePreference("dummy");
mAuthenticatorHelper.listenToAccountUpdates();
updateAuthDescriptions();
onAccountsUpdate(Binder.getCallingUserHandle());
onAccountsUpdate(UserHandle.getCallingUserHandle());
super.onResume();
}

View File

@@ -396,7 +396,23 @@ 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;
}