diff options
| author | 2021-01-15 00:44:48 +0000 | |
|---|---|---|
| committer | 2021-01-15 00:44:48 +0000 | |
| commit | 40e252620ad4b60b68e32a607d56de9c82750fcf (patch) | |
| tree | 8cac9f1dca2a57f7a825ef7286aef588a2a99474 | |
| parent | cd41a81ea32cb164670a0b6e959dc609da61b9c0 (diff) | |
| parent | 112bf90c9e420168f2745ee6180447d157e1603f (diff) | |
Merge "Added profile-owner and device-owner on cmd user list."
3 files changed, 34 insertions, 4 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManagerInternal.java b/core/java/android/app/admin/DevicePolicyManagerInternal.java index ce2fd4fb60b2..a0d2977cf09a 100644 --- a/core/java/android/app/admin/DevicePolicyManagerInternal.java +++ b/core/java/android/app/admin/DevicePolicyManagerInternal.java @@ -231,7 +231,13 @@ public abstract class DevicePolicyManagerInternal { * Returns the profile owner component for the given user, or {@code null} if there is not one. */ @Nullable - public abstract ComponentName getProfileOwnerAsUser(int userHandle); + public abstract ComponentName getProfileOwnerAsUser(@UserIdInt int userId); + + /** + * Returns the user id of the device owner, or {@link UserHandle#USER_NULL} if there is not one. + */ + @UserIdInt + public abstract int getDeviceOwnerUserId(); /** * Returns whether the given package is a device owner or a profile owner in the calling user. diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index e20ed05dc4b4..19a94b39ea20 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -4762,13 +4762,32 @@ public class UserManagerService extends IUserManager.Stub { final boolean hasParent = user.profileGroupId != user.id && user.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID; if (verbose) { - pw.printf("%d: id=%d, name=%s, flags=%s%s%s%s%s%s%s\n", i, user.id, user.name, + final DevicePolicyManagerInternal dpm = getDevicePolicyManagerInternal(); + String deviceOwner = ""; + String profileOwner = ""; + if (dpm != null) { + final long ident = Binder.clearCallingIdentity(); + // NOTE: dpm methods below CANNOT be called while holding the mUsersLock + try { + if (dpm.getDeviceOwnerUserId() == user.id) { + deviceOwner = " (device-owner)"; + } + if (dpm.getProfileOwnerAsUser(user.id) != null) { + profileOwner = " (profile-owner)"; + } + } finally { + Binder.restoreCallingIdentity(ident); + } + } + pw.printf("%d: id=%d, name=%s, flags=%s%s%s%s%s%s%s%s%s\n", i, user.id, + user.name, UserInfo.flagsToString(user.flags), hasParent ? " (parentId=" + user.profileGroupId + ")" : "", running ? " (running)" : "", user.partial ? " (partial)" : "", user.preCreated ? " (pre-created)" : "", user.convertedFromPreCreated ? " (converted)" : "", + deviceOwner, profileOwner, current ? " (current)" : ""); } else { // NOTE: the standard "list users" command is used by integration tests and diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 7d199cab1d35..4fe275250ddf 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -12051,8 +12051,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } @Override - public ComponentName getProfileOwnerAsUser(int userHandle) { - return DevicePolicyManagerService.this.getProfileOwnerAsUser(userHandle); + public ComponentName getProfileOwnerAsUser(@UserIdInt int userId) { + return DevicePolicyManagerService.this.getProfileOwnerAsUser(userId); + } + + @Override + public int getDeviceOwnerUserId() { + return DevicePolicyManagerService.this.getDeviceOwnerUserId(); } @Override |