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

Commit 215116f8 authored by Ying Zheng's avatar Ying Zheng
Browse files

Not support flag primary in headless system user mode for now.

Test: build
Bug: 139950070
Change-Id: I5b06cb857fa1917f479c3018963970743b211087
parent 65b59001
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public class UserInfo implements Parcelable {

    /**
     * Primary user. Only one user can have this flag set. It identifies the first human user
     * on a device.
     * on a device. This flag is not supported in headless system user mode.
     */
    @UnsupportedAppUsage
    public static final int FLAG_PRIMARY = 0x00000001;
+1 −1
Original line number Diff line number Diff line
@@ -1404,7 +1404,7 @@ public class UserManager {

    /**
     * Used to check if this process is running under the primary user. The primary user
     * is the first human user on a device.
     * is the first human user on a device. This is not supported in headless system user mode.
     *
     * @return whether this process is running under the primary user.
     * @hide
+5 −14
Original line number Diff line number Diff line
@@ -2253,10 +2253,11 @@ public class UserManagerService extends IUserManager.Stub {

    @GuardedBy({"mPackagesLock", "mRestrictionsLock"})
    private void fallbackToSingleUserLP() {
        int flags = UserInfo.FLAG_SYSTEM | UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_ADMIN;
        // In headless system user mode, the primary flag is assigned to the first human user.
        int flags = UserInfo.FLAG_SYSTEM | UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_ADMIN
                | UserInfo.FLAG_PRIMARY;
        // In headless system user mode, headless system user is not a full user.
        if (!UserManager.isHeadlessSystemUserMode()) {
            flags |= UserInfo.FLAG_PRIMARY | UserInfo.FLAG_FULL;
            flags |= UserInfo.FLAG_FULL;
        }
        // Create the system user
        UserInfo system = new UserInfo(UserHandle.USER_SYSTEM, null, null, flags);
@@ -2770,17 +2771,7 @@ public class UserManagerService extends IUserManager.Stub {
                        return null;
                    }
                }
                // In headless system user mode, we assign the first human user the primary flag.
                // And if there is no device owner, we also assign the admin flag to primary user.
                if (UserManager.isHeadlessSystemUserMode()
                        && !isGuest && !isManagedProfile && getPrimaryUser() == null) {
                    flags |= UserInfo.FLAG_PRIMARY;
                    synchronized (mUsersLock) {
                        if (!mIsDeviceManaged) {
                            flags |= UserInfo.FLAG_ADMIN;
                        }
                    }
                }

                if (!isManagedProfile) {
                    // New users cannot be system, and it's not a profile, so per-force it's FULL.
                    flags |= UserInfo.FLAG_FULL;