Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e142e336 authored by Varun Shah's avatar Varun Shah
Browse files

Exposes user type related hidden APIs in UserManager.

UserManager#isAdminUser, UserManager#isPrimaryUser,
UserManager#isGuestUser, and UserManager#isRestrictedProfile
are now exposed as System APIs for SUW. All of them require the
MANAGE_USERS permission.

Bug: 115270753
Test: manual (run setup wizard)
Change-Id: I5b9685d486738c3d5a7f5cfa6748adb6efef91bb
parent abc7143e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4153,8 +4153,11 @@ package android.os {
    method public deprecated int getUserRestrictionSource(java.lang.String, android.os.UserHandle);
    method public java.util.List<android.os.UserManager.EnforcingUser> getUserRestrictionSources(java.lang.String, android.os.UserHandle);
    method public boolean hasRestrictedProfiles();
    method public boolean isAdminUser();
    method public boolean isGuestUser();
    method public boolean isManagedProfile();
    method public boolean isManagedProfile(int);
    method public boolean isPrimaryUser();
    method public boolean isRestrictedProfile();
    field public static final java.lang.String ACTION_USER_RESTRICTIONS_CHANGED = "android.os.action.USER_RESTRICTIONS_CHANGED";
    field public static final deprecated java.lang.String DISALLOW_OEM_UNLOCK = "no_oem_unlock";
+0 −1
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ Landroid/os/SystemService;->stop(Ljava/lang/String;)V
Landroid/os/SystemVibrator;-><init>()V
Landroid/os/UserHandle;->isSameApp(II)Z
Landroid/os/UserManager;->hasUserRestriction(Ljava/lang/String;Landroid/os/UserHandle;)Z
Landroid/os/UserManager;->isAdminUser()Z
Landroid/R$styleable;->CheckBoxPreference:[I
Landroid/telephony/ims/compat/feature/MMTelFeature;-><init>()V
Landroid/telephony/ims/compat/ImsService;-><init>()V
+19 −7
Original line number Diff line number Diff line
@@ -1278,6 +1278,8 @@ public class UserManager {
     * @return whether this process is running under the primary user.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public boolean isPrimaryUser() {
        UserInfo user = getUserInfo(UserHandle.myUserId());
        return user != null && user.isPrimary();
@@ -1295,10 +1297,15 @@ public class UserManager {
    }

    /**
     * Used to check if this process is running as an admin user. An admin user is allowed to
     * modify or configure certain settings that aren't available to non-admin users,
     * create and delete additional users, etc. There can be more than one admin users.
     *
     * @return whether this process is running under an admin user.
     * @hide
     * Returns whether the caller is running as an admin user. There can be more than one admin
     * user.
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public boolean isAdminUser() {
        return isUserAdmin(UserHandle.myUserId());
    }
@@ -1323,12 +1330,14 @@ public class UserManager {
    }

    /**
     * Returns whether the caller is running as restricted profile. Restricted profile may have
     * a reduced number of available apps, app restrictions and account restrictions.
     * @return whether the user making this call is a linked user
     * Used to check if this process is running under a restricted profile. Restricted profiles
     * may have a reduced number of available apps, app restrictions, and account restrictions.
     *
     * @return whether this process is running under a restricted profile.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public boolean isRestrictedProfile() {
        try {
            return mService.isRestricted();
@@ -1374,10 +1383,13 @@ public class UserManager {
    }

    /**
     * Checks if the calling app is running as a guest user.
     * @return whether the caller is a guest user.
     * Used to check if this process is running under a guest user. A guest user may be transient.
     *
     * @return whether this process is running under a guest user.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public boolean isGuestUser() {
        UserInfo user = getUserInfo(UserHandle.myUserId());
        return user != null && user.isGuest();