Allow ephemeral users on the split-system-user systems only.

am: 024f979dfd

* commit '024f979dfdae1938afc3c509ea9762c06784cef5':
  Allow ephemeral users on the split-system-user systems only.
This commit is contained in:
Lenka Trochtova
2016-02-19 12:39:50 +00:00
committed by android-build-merger
2 changed files with 15 additions and 0 deletions

View File

@@ -1833,6 +1833,11 @@ public class UserManagerService extends IUserManager.Stub {
return null;
}
}
if (!UserManager.isSplitSystemUser() && (flags & UserInfo.FLAG_EPHEMERAL) != 0) {
Log.e(LOG_TAG,
"Ephemeral users are supported on split-system-user systems only.");
return null;
}
// In split system user mode, we assign the first human user the primary flag.
// And if there is no device owner, we also assign the admin flag to primary user.
if (UserManager.isSplitSystemUser()

View File

@@ -4968,6 +4968,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
return;
}
Preconditions.checkNotNull(who, "ComponentName is null");
// Allow setting this policy to true only if there is a split system user.
if (forceEphemeralUsers && !mInjector.userManagerIsSplitSystemUser()) {
throw new IllegalArgumentException(
"Cannot force ephemeral users on systems without split system user.");
}
boolean removeAllUsers = false;
synchronized (this) {
final ActiveAdmin deviceOwner =
@@ -6818,6 +6823,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
if (!mInjector.binderGetCallingUserHandle().isSystem()) {
throw new SecurityException("createAndManageUser was called from non-system user");
}
if (!mInjector.userManagerIsSplitSystemUser()
&& (flags & DevicePolicyManager.MAKE_USER_EPHEMERAL) != 0) {
throw new IllegalArgumentException(
"Ephemeral users are only supported on systems with a split system user.");
}
// Create user.
UserHandle user = null;
synchronized (this) {