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

Commit 2c93da22 authored by Danny Baumann's avatar Danny Baumann Committed by Steve Kondik
Browse files

Send out USER_PRESENT broadcast on screen on if lockscreen is disabled.

This makes sure to turn off the notification LED on screen on when the
lockscreen is disabled by profile or e.g. by lockscreen toggle tile.

Change-Id: Ibf2fdcd912a2719d973a253aaf3752add7a22e00
parent 2d983f5e
Loading
Loading
Loading
Loading
+28 −35
Original line number Original line Diff line number Diff line
@@ -733,14 +733,34 @@ public class KeyguardViewMediator {
    }
    }


    private void maybeSendUserPresentBroadcast() {
    private void maybeSendUserPresentBroadcast() {
        if (mSystemReady && mLockPatternUtils.isLockScreenDisabled()
        if (mSystemReady && isKeyguardDisabled()) {
                && mUserManager.getUsers(true).size() == 1) {
            // Keyguard can be showing even if disabled in case the SIM PIN entry
            // Lock screen is disabled because the user has set the preference to "None".
            // screen is showing; so make sure to not send user present if it's
            // In this case, send out ACTION_USER_PRESENT here instead of in
            // actually showing
            // handleKeyguardDone()
            if (!mShowing && !mShowKeyguardWakeLock.isHeld()) {
                sendUserPresentBroadcast();
                sendUserPresentBroadcast();
            }
            }
        }
        }
    }

    private boolean isKeyguardDisabled() {
        if (!mExternallyEnabled) {
            if (DEBUG) Log.d(TAG, "isKeyguardDisabled: keyguard is disabled externally");
            return true;
        }
        if (mLockPatternUtils.isLockScreenDisabled() && mUserManager.getUsers(true).size() == 1) {
            if (DEBUG) Log.d(TAG, "isKeyguardDisabled: keyguard is disabled by setting");
            return true;
        }
        Profile profile = mProfileManager.getActiveProfile();
        if (profile != null) {
            if (profile.getScreenLockMode() == Profile.LockMode.DISABLE) {
                if (DEBUG) Log.d(TAG, "isKeyguardDisabled: keyguard is disabled by profile");
                return true;
            }
        }
        return false;
    }


    /**
    /**
     * A dream started.  We should lock after the usual screen-off lock timeout but only
     * A dream started.  We should lock after the usual screen-off lock timeout but only
@@ -948,37 +968,10 @@ public class KeyguardViewMediator {
            return;
            return;
        }
        }


        // if another app is disabling us, don't show
        if (isKeyguardDisabled() && !lockedOrMissing) {
        if (!mExternallyEnabled && !lockedOrMissing) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because disabled");
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled");

            // note: we *should* set mNeedToReshowWhenReenabled=true here, but that makes
            // for an occasional ugly flicker in this situation:
            // 1) receive a call with the screen on (no keyguard) or make a call
            // 2) screen times out
            // 3) user hits key to turn screen back on
            // instead, we reenable the keyguard when we know the screen is off and the call
            // ends (see the broadcast receiver below)
            // TODO: clean this up when we have better support at the window manager level
            // for apps that wish to be on top of the keyguard
            return;
        }

        if (mUserManager.getUsers(true).size() < 2
                && mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off");
            return;
        }

        // if the current profile has disabled us, don't show
        Profile profile = mProfileManager.getActiveProfile();
        if (profile != null) {
            if (!lockedOrMissing
                    && profile.getScreenLockMode() == Profile.LockMode.DISABLE) {
                if (DEBUG) Log.d(TAG, "doKeyguard: not showing because of profile override");
            return;
            return;
        }
        }
        }


        if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
        if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
        showLocked(options);
        showLocked(options);