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

Commit 04e1ca02 authored by Ying Zheng's avatar Ying Zheng
Browse files

Read build flag to determine user model.

Bug: 109698349
Test: Manual
Change-Id: I180b6a877ead576b0ed1292376fe0e74b0df1fd9
parent 4eca92d5
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.UserInfo;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
@@ -42,6 +43,7 @@ import java.util.List;
@Deprecated
public final class UserManagerHelper {
    private static final String TAG = "UserManagerHelper";
    private static final String HEADLESS_SYSTEM_USER = "android.car.systemuser.headless";
    private final Context mContext;
    private final UserManager mUserManager;
    private final ActivityManager mActivityManager;
@@ -76,6 +78,15 @@ public final class UserManagerHelper {
        unregisterReceiver();
    }

    /**
     * Returns {@code true} if the system is in the headless user 0 model.
     *
     * @return {@boolean true} if headless system user.
     */
    public boolean isHeadlessSystemUser() {
        return SystemProperties.getBoolean(HEADLESS_SYSTEM_USER, false);
    }

    /**
     * Gets UserInfo for the foreground user.
     *
@@ -169,6 +180,9 @@ public final class UserManagerHelper {
     * Gets all the users on the system that are not currently being removed.
     */
    public List<UserInfo> getAllUsers() {
        if (isHeadlessSystemUser()) {
            return getAllUsersExcludesSystemUser();
        }
        return mUserManager.getUsers(true /* excludeDying */);
    }