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

Commit 44216415 authored by Clara Thomas's avatar Clara Thomas
Browse files

Add the supervision profile type.

This new user type is based on the parentless profile used by the
communal profile. This profile can be started in the background by any
user and can show UI over any user. It is meant to run very infrequently
only for actions involved in setting the supervision credentials.

This CL just allows for creating the supervision profile, but does not
yet introduce changes required for the keyboard to work correctly for
activities running in the context of this user. Future work will also
limit the number of applications installed into the profile.

Test: atest com.android.server.pm.UserManagerTest
Bug: 389712089
Flag: android.multiuser.allow_supervising_profile
Change-Id: Ic3fe1c2b11b24dd709721a858e88adf2cdb1e640
parent d280057b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11725,6 +11725,7 @@ package android.os {
    field public static final String USER_TYPE_FULL_GUEST = "android.os.usertype.full.GUEST";
    field public static final String USER_TYPE_FULL_SECONDARY = "android.os.usertype.full.SECONDARY";
    field public static final String USER_TYPE_FULL_SYSTEM = "android.os.usertype.full.SYSTEM";
    field @FlaggedApi("android.multiuser.allow_supervising_profile") public static final String USER_TYPE_PROFILE_SUPERVISING = "android.os.usertype.profile.SUPERVISING";
    field public static final String USER_TYPE_SYSTEM_HEADLESS = "android.os.usertype.system.HEADLESS";
  }
+1 −0
Original line number Diff line number Diff line
@@ -1199,6 +1199,7 @@ package android.content.pm {
    method public boolean isProfile();
    method public boolean isQuietModeEnabled();
    method public boolean isRestricted();
    method @FlaggedApi("android.multiuser.allow_supervising_profile") public boolean isSupervisingProfile();
    method public boolean supportsSwitchTo();
    method @Deprecated public boolean supportsSwitchToByUser();
    method public void writeToParcel(android.os.Parcel, int);
+5 −0
Original line number Diff line number Diff line
@@ -410,6 +410,11 @@ public class UserInfo implements Parcelable {
        return UserManager.isUserTypePrivateProfile(userType);
    }

    @FlaggedApi(android.multiuser.Flags.FLAG_ALLOW_SUPERVISING_PROFILE)
    public boolean isSupervisingProfile() {
        return UserManager.isUserTypeSupervisingProfile(userType);
    }

    /** See {@link #FLAG_DISABLED}*/
    @UnsupportedAppUsage
    public boolean isEnabled() {
+7 −0
Original line number Diff line number Diff line
@@ -629,3 +629,10 @@ flag {
    description: "Enable moving content into the Private Space"
    bug: "360066001"
}

flag {
    name: "allow_supervising_profile"
    namespace: "supervision"
    description: "Enables support for new supervising user type"
    bug: "389712089"
}
+29 −0
Original line number Diff line number Diff line
@@ -208,6 +208,23 @@ public class UserManager {
     */
    public static final String USER_TYPE_PROFILE_COMMUNAL = "android.os.usertype.profile.COMMUNAL";

    /**
     * User type representing a user who manages supervision on the device.
     * When any full user on the device is supervised, the credentials for this profile will be
     * required in order to perform certain actions for that user (i.e. those controlled by
     * {@link android.app.supervision.SupervisionManager} or the
     * {@link android.app.role.RoleManager#ROLE_SYSTEM_SUPERVISION supervision role holder}).
     * There can only be one supervising profile per device, and the credentials set for that
     * profile will be used to authorize actions for any supervised user on the device. This is
     * distinct from a managed profile in that it functions only to authorize certain supervised
     * actions; it does not represent the user to which restriction or management is applied.
     * @hide
     */
    @FlaggedApi(android.multiuser.Flags.FLAG_ALLOW_SUPERVISING_PROFILE)
    @SystemApi
    public static final String USER_TYPE_PROFILE_SUPERVISING =
            "android.os.usertype.profile.SUPERVISING";

    /**
     * User type representing a {@link UserHandle#USER_SYSTEM system} user that is <b>not</b> a
     * human user.
@@ -3225,6 +3242,18 @@ public class UserManager {
        return USER_TYPE_PROFILE_PRIVATE.equals(userType);
    }

    /**
     * Returns whether the user type is a
     * {@link UserManager#USER_TYPE_PROFILE_SUPERVISING supervising profile}.
     *
     * @hide
     */
    @FlaggedApi(android.multiuser.Flags.FLAG_ALLOW_SUPERVISING_PROFILE)
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isUserTypeSupervisingProfile(@Nullable String userType) {
        return USER_TYPE_PROFILE_SUPERVISING.equals(userType);
    }

    /**
     * @hide
     * @deprecated Use {@link #isRestrictedProfile()}
Loading