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

Commit ab28fff9 authored by Leo Hsu's avatar Leo Hsu
Browse files

Add UserManager APIs to SystemApi.

Bug: 124940146
Test: make
Change-Id: I1cac9a6106b3da099e08f10f2c08d90e9f515e42
parent 9873510a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5537,6 +5537,7 @@ package android.os {
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public android.os.PersistableBundle getSeedAccountOptions();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public String getSeedAccountType();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public long[] getSerialNumbersOfUsers(boolean);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public android.graphics.Bitmap getUserIcon();
    method @Deprecated @android.os.UserManager.UserRestrictionSource @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public int getUserRestrictionSource(String, android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public java.util.List<android.os.UserManager.EnforcingUser> getUserRestrictionSources(String, android.os.UserHandle);
    method public boolean hasRestrictedProfiles();
@@ -5547,6 +5548,8 @@ package android.os {
    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 removeUser(android.os.UserHandle);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public void setUserIcon(android.graphics.Bitmap);
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public void setUserName(String);
    field public static final String ACTION_USER_RESTRICTIONS_CHANGED = "android.os.action.USER_RESTRICTIONS_CHANGED";
    field @Deprecated public static final String DISALLOW_OEM_UNLOCK = "no_oem_unlock";
    field public static final String DISALLOW_RUN_IN_BACKGROUND = "no_run_in_background";
+40 −0
Original line number Diff line number Diff line
@@ -2696,6 +2696,19 @@ public class UserManager {
        }
    }

    /**
     * Updates the calling user's name.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     *
     * @param name the new name for the user
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public void setUserName(String name) {
        setUserName(getUserHandle(), name);
    }

    /**
     * Sets the user's photo.
     * @param userHandle the user for whom to change the photo.
@@ -2710,6 +2723,19 @@ public class UserManager {
        }
    }

    /**
     * Sets the calling user's photo.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     *
     * @param icon the bitmap to set as the photo.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public void setUserIcon(Bitmap icon) {
        setUserIcon(getUserHandle(), icon);
    }

    /**
     * Returns a file descriptor for the user's photo. PNG data can be read from this file.
     * @param userHandle the user whose photo we want to read.
@@ -2736,6 +2762,20 @@ public class UserManager {
        return null;
    }

    /**
     * Returns a Bitmap for the calling user's photo.
     * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
     *
     * @return a {@link Bitmap} of the user's photo, or null if there's no photo.
     * @see com.android.internal.util.UserIcons#getDefaultUserIcon for a default.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
    public Bitmap getUserIcon() {
        return getUserIcon(getUserHandle());
    }

    /**
     * Returns the maximum number of users that can be created on this device. A return value
     * of 1 means that it is a single user device.
+1 −0
Original line number Diff line number Diff line
@@ -1324,6 +1324,7 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public ParcelFileDescriptor getUserIcon(int targetUserId) {
        checkManageUsersPermission("get user icon");
        String iconPath;
        synchronized (mPackagesLock) {
            UserInfo targetUserInfo = getUserInfoNoChecks(targetUserId);