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

Commit 3a687e93 authored by Adam Bookatz's avatar Adam Bookatz Committed by Android (Google) Code Review
Browse files

Merge changes from topics "isCommunalProfileAPI", "isForegroundUserAnAdmin" into main

* changes:
  isForegroundUserAdmin public API
  Public isCommunalProfile() API
parents e978a45c 7144cbf7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -33455,7 +33455,9 @@ package android.os {
    method @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.INTERACT_ACROSS_USERS"}, conditional=true) public android.os.Bundle getUserRestrictions(android.os.UserHandle);
    method public boolean hasUserRestriction(String);
    method public boolean isAdminUser();
    method @FlaggedApi("android.multiuser.support_communal_profile") public boolean isCommunalProfile();
    method public boolean isDemoUser();
    method @FlaggedApi("android.multiuser.support_communal_profile_nextgen") public boolean isForegroundUserAdmin();
    method public static boolean isHeadlessSystemUserMode();
    method public boolean isManagedProfile();
    method public boolean isProfile();
+1 −0
Original line number Diff line number Diff line
@@ -2357,6 +2357,7 @@ package android.os {
    method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public android.content.pm.UserInfo createUser(@Nullable String, @NonNull String, int);
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public java.util.List<android.content.pm.UserInfo> getAliveUsers();
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public android.os.UserHandle getBootUser();
    method @FlaggedApi("android.multiuser.support_communal_profile") @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public android.os.UserHandle getCommunalProfile();
    method public int getMainDisplayIdAssignedToUser();
    method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public java.util.Set<java.lang.String> getPreInstallableSystemPackages(@NonNull String);
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public String getUserType();
+7 −0
Original line number Diff line number Diff line
@@ -28,3 +28,10 @@ flag {
    description: "Framework support for communal profile."
    bug: "285426179"
}

flag {
    name: "support_communal_profile_nextgen"
    namespace: "multiuser"
    description: "Further framework support for communal profile, beyond the basics, for later releases."
    bug: "285426179"
}
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ interface IUserManager {
    boolean isUserVisible(int userId);
    int[] getVisibleUsers();
    int getMainDisplayIdAssignedToUser();
    boolean isForegroundUserAdmin();
    boolean isUserNameSet(int userId);
    boolean hasRestrictedProfiles(int userId);
    boolean requestQuietModeEnabled(String callingPackage, boolean enableQuietMode, int userId, in IntentSender target, int flags);
+47 −11
Original line number Diff line number Diff line
@@ -2774,6 +2774,8 @@ public class UserManager {
     * Returns the designated "communal profile" of the device, or {@code null} if there is none.
     * @hide
     */
    @FlaggedApi(android.multiuser.Flags.FLAG_SUPPORT_COMMUNAL_PROFILE)
    @TestApi
    @RequiresPermission(anyOf = {
            Manifest.permission.MANAGE_USERS,
            Manifest.permission.CREATE_USERS,
@@ -2790,17 +2792,34 @@ public class UserManager {
        }
    }

    /**
     * Checks if the context user is running in a communal profile.
     *
     * A communal profile is a {@link #isProfile() profile}, but instead of being associated with a
     * particular parent user, it is communal to the device.
     *
     * @return whether the context user is a communal profile.
     */
    @FlaggedApi(android.multiuser.Flags.FLAG_SUPPORT_COMMUNAL_PROFILE)
    @UserHandleAware(
            requiresAnyOfPermissionsIfNotCallerProfileGroup = {
                    android.Manifest.permission.MANAGE_USERS,
                    android.Manifest.permission.QUERY_USERS,
                    android.Manifest.permission.INTERACT_ACROSS_USERS})
    public boolean isCommunalProfile() {
        return isCommunalProfile(mUserId);
    }

    /**
     * Returns {@code true} if the given user is the designated "communal profile" of the device.
     * @hide
     */
    @RequiresPermission(anyOf = {
            Manifest.permission.MANAGE_USERS,
            Manifest.permission.CREATE_USERS,
            Manifest.permission.QUERY_USERS})
    public boolean isCommunalProfile(@UserIdInt int userId) {
        final UserInfo user = getUserInfo(userId);
        return user != null && user.isCommunalProfile();
            android.Manifest.permission.MANAGE_USERS,
            android.Manifest.permission.QUERY_USERS,
            android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional = true)
    private boolean isCommunalProfile(@UserIdInt int userId) {
        return isUserTypeCommunalProfile(getProfileType(userId));
    }

    /**
@@ -2839,6 +2858,23 @@ public class UserManager {
        return user != null && user.isAdmin();
    }

    /**
     * Used to check if the user currently running in the <b>foreground</b> is an
     * {@link #isAdminUser() admin} user.
     *
     * @return whether the foreground user is an admin user.
     * @see #isAdminUser()
     * @see #isUserForeground()
     */
    @FlaggedApi(android.multiuser.Flags.FLAG_SUPPORT_COMMUNAL_PROFILE_NEXTGEN)
    public boolean isForegroundUserAdmin() {
        try {
            return mService.isForegroundUserAdmin();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Returns whether the context user is of the given user type.
     *
@@ -2997,7 +3033,7 @@ public class UserManager {
    }

    /**
     * Checks if the calling context user can have a restricted profile.
     * Checks if the context user can have a restricted profile.
     * @return whether the context user can have a restricted profile.
     * @hide
     */
@@ -3101,11 +3137,11 @@ public class UserManager {
    }

    /**
     * Checks if the calling context user is running in a profile. A profile is a user that
     * Checks if the context user is running in a profile. A profile is a user that
     * typically has its own separate data but shares its UI with some parent user. For example, a
     * {@link #isManagedProfile() managed profile} is a type of profile.
     *
     * @return whether the caller is in a profile.
     * @return whether the context user is in a profile.
     */
    @UserHandleAware(
            requiresAnyOfPermissionsIfNotCallerProfileGroup = {
@@ -5247,7 +5283,7 @@ public class UserManager {

    /**
     * Returns the parent of the profile which this method is called from
     * or null if called from a user that is not a profile.
     * or null if it has no parent (e.g. if it is not a profile).
     *
     * @hide
     */
@@ -5269,7 +5305,7 @@ public class UserManager {
     *
     * @param user the handle of the user profile
     *
     * @return the parent of the user or {@code null} if the user is not profile
     * @return the parent of the user or {@code null} if the user has no parent
     *
     * @hide
     */
Loading