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

Commit 61d94092 authored by Adam Lesinski's avatar Adam Lesinski
Browse files

Show the lockscreen when more than 1 user is present

Bug:17399024
Change-Id: Iaf2ea2747cbcd9db45ba9faa7c8fe0389a799855
parent 49c0e737
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -27,11 +27,13 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.IMountService;
import android.os.storage.StorageManager;
import android.provider.Settings;
@@ -499,7 +501,19 @@ public class LockPatternUtils {
     * @return true if lock screen is can be disabled
     */
    public boolean isLockScreenDisabled() {
        return !isSecure() && getLong(DISABLE_LOCKSCREEN_KEY, 0) != 0;
        if (!isSecure() && getLong(DISABLE_LOCKSCREEN_KEY, 0) != 0) {
            // 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++;
                }
            }
            return switchableUsers < 2;
        }
        return false;
    }

    /**
+1 −2
Original line number Diff line number Diff line
@@ -683,8 +683,7 @@ public class KeyguardViewMediator extends SystemUI {
    }

    private void maybeSendUserPresentBroadcast() {
        if (mSystemReady && mLockPatternUtils.isLockScreenDisabled()
                && !mUserManager.isUserSwitcherEnabled()) {
        if (mSystemReady && mLockPatternUtils.isLockScreenDisabled()) {
            // Lock screen is disabled because the user has set the preference to "None".
            // In this case, send out ACTION_USER_PRESENT here instead of in
            // handleKeyguardDone()