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

Commit f63afe7b authored by Benjamin Franz's avatar Benjamin Franz Committed by Android (Google) Code Review
Browse files

Merge "Allow disabling the lock screen when multiple users are present"

parents 81b924fc 51ed794e
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -449,29 +449,29 @@ public class LockPatternUtils {
     * @param disable Disables lock screen when true
     */
    public void setLockScreenDisabled(boolean disable) {
        setBoolean(DISABLE_LOCKSCREEN_KEY, disable, getCurrentOrCallingUserId());
        setLockScreenDisabled(disable, getCurrentOrCallingUserId());
    }

    /**
     * Determine if LockScreen can be disabled. This is used, for example, to tell if we should
     * show LockScreen or go straight to the home screen.
     * Disable showing lock screen at all for a given user.
     * This is only meaningful if pattern, pin or password are not set.
     *
     * @return true if lock screen is can be disabled
     * @param disable Disables lock screen when true
     * @param userId User ID of the user this has effect on
     */
    public boolean isLockScreenDisabled() {
        if (!isSecure() && getBoolean(DISABLE_LOCKSCREEN_KEY, false, getCurrentOrCallingUserId())) {
            // Check if the number of switchable users forces the lockscreen.
            final List<UserInfo> users = UserManager.get(mContext).getUsers(true);
            final int userCount = users.size();
            int switchableUsers = 0;
            for (int i = 0; i < userCount; i++) {
                if (users.get(i).supportsSwitchTo()) {
                    switchableUsers++;
    public void setLockScreenDisabled(boolean disable, int userId) {
        setBoolean(DISABLE_LOCKSCREEN_KEY, disable, userId);
    }
            }
            return switchableUsers < 2;
        }
        return false;

    /**
     * Determine if LockScreen is disabled for the current user. This is used to decide whether
     * LockScreen is shown after reboot or after screen timeout / short press on power.
     *
     * @return true if lock screen is disabled
     */
    public boolean isLockScreenDisabled() {
        return !isSecure() &&
                getBoolean(DISABLE_LOCKSCREEN_KEY, false, getCurrentOrCallingUserId());
    }

    /**