diff options
author | 2024-08-05 13:21:29 +0000 | |
---|---|---|
committer | 2024-08-05 13:21:29 +0000 | |
commit | 06d5b870dbed121847cc1832b1ece17ebccbfb56 (patch) | |
tree | c7e71baf72da687ffb9962a33f39da3216dcf2ab | |
parent | 1b56ff5a0f05c71cb815a6564fcf7e6a9de33b8e (diff) | |
parent | 8115d9965e97b2d5d08352763990b80e81f94e1f (diff) |
Merge "Define new error code to send on profile create restrition" into main
-rw-r--r-- | core/java/android/os/UserManager.java | 8 | ||||
-rw-r--r-- | services/core/java/com/android/server/pm/UserManagerService.java | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 392b6eb6d51b..06c516aee8f3 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -2391,10 +2391,15 @@ public class UserManager { */ public static final int USER_OPERATION_ERROR_DISABLED_USER = 8; /** - * Indicates user operation failed because user is disabled on the device. + * Indicates user operation failed because private space is disabled on the device. * @hide */ public static final int USER_OPERATION_ERROR_PRIVATE_PROFILE = 9; + /** + * Indicates user operation failed because user is restricted on the device. + * @hide + */ + public static final int USER_OPERATION_ERROR_USER_RESTRICTED = 10; /** * Result returned from various user operations. @@ -2413,6 +2418,7 @@ public class UserManager { USER_OPERATION_ERROR_USER_ACCOUNT_ALREADY_EXISTS, USER_OPERATION_ERROR_DISABLED_USER, USER_OPERATION_ERROR_PRIVATE_PROFILE, + USER_OPERATION_ERROR_USER_RESTRICTED, }) public @interface UserOperationResult {} diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index c902fb26495a..829ee27287c2 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -29,6 +29,7 @@ import static android.os.UserManager.DEV_CREATE_OVERRIDE_PROPERTY; import static android.os.UserManager.DISALLOW_USER_SWITCH; import static android.os.UserManager.SYSTEM_USER_MODE_EMULATION_PROPERTY; import static android.os.UserManager.USER_OPERATION_ERROR_UNKNOWN; +import static android.os.UserManager.USER_OPERATION_ERROR_USER_RESTRICTED; import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE; import static com.android.internal.app.SetScreenLockDialogActivity.EXTRA_ORIGIN_USER_ID; @@ -8039,8 +8040,13 @@ public class UserManagerService extends IUserManager.Stub { String errorMessage = (message != null ? (message + ": ") : "") + restriction + " is enabled."; Slog.w(LOG_TAG, errorMessage); - throw new UserManager.CheckedUserOperationException(errorMessage, + if (android.multiuser.Flags.showDifferentCreationErrorForUnsupportedDevices()) { + throw new UserManager.CheckedUserOperationException(errorMessage, + USER_OPERATION_ERROR_USER_RESTRICTED); + } else { + throw new UserManager.CheckedUserOperationException(errorMessage, USER_OPERATION_ERROR_UNKNOWN); + } } } |