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

Commit 51ed794e authored by Benjamin Franz's avatar Benjamin Franz
Browse files

Allow disabling the lock screen when multiple users are present

Disallowing disabling the lock screen when multiple switchable users
are present on the device was a legacy from the time when the lock
screen was the only way of switching between users. As we offer other
ways to switch users now, e.g. quick settings, we no longer need this
check.

Also introduce a per user version of disabling the lock screen.

Bug: 19962043
Change-Id: I131568a5dadd1706762b8a626e8f9b06e973b7ae
parent 80ac6036
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());
    }

    /**