summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/pm/UserInfo.java2
-rw-r--r--core/java/android/os/UserManager.java2
-rw-r--r--services/core/java/com/android/server/pm/UserManagerService.java19
3 files changed, 7 insertions, 16 deletions
diff --git a/core/java/android/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java
index d03bea2fb19e..e65d761cb77e 100644
--- a/core/java/android/content/pm/UserInfo.java
+++ b/core/java/android/content/pm/UserInfo.java
@@ -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;
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index baf748f4a20d..af574da084f0 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -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
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 81723cbe22c5..dd1adb703e62 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -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;