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

Commit 7c064caa authored by Hai Zhang's avatar Hai Zhang
Browse files

Add API for checking whether a user is restricted.

This is used by the SMS role.

Bug: 124452117
Test: build
Change-Id: I90bb17654e63cda34b3253024836aa9f4dbc2a4f
parent 9c18f9df
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5616,6 +5616,7 @@ package android.os {
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isManagedProfile(int);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isPrimaryUser();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isRestrictedProfile();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isRestrictedProfile(@NonNull android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean removeUser(@NonNull android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public void setUserIcon(@NonNull android.graphics.Bitmap);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public void setUserName(@Nullable String);
+18 −0
Original line number Diff line number Diff line
@@ -1469,6 +1469,24 @@ public class UserManager {
        }
    }

    /**
     * Check if a user is a restricted profile. Restricted profiles may have a reduced number of
     * available apps, app restrictions, and account restrictions.
     *
     * @param user the user to check
     * @return whether the user is a restricted profile.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public boolean isRestrictedProfile(@NonNull UserHandle user) {
        try {
            return mService.getUserInfo(user.getIdentifier()).isRestricted();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Checks if specified user can have restricted profile.
     * @hide