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

Commit 7e31317a authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "Send out USER_PRESENT broadcast on screen on if lockscreen is disabled." into cm-10.1

parents 8cadad13 b061fe53
Loading
Loading
Loading
Loading
+23 −34
Original line number Diff line number Diff line
@@ -696,15 +696,30 @@ public class KeyguardViewMediator {
    }

    private void maybeSendUserPresentBroadcast() {
        if (mSystemReady && mLockPatternUtils.isLockScreenDisabled()
                && mUserManager.getUsers(true).size() == 1) {
            // 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()
        if (mSystemReady && isKeyguardDisabled()) {
            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.getScreenLockModeWithDPM(mContext) == 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
     * if there is a secure lock pattern.
@@ -898,38 +913,12 @@ public class KeyguardViewMediator {
            return;
        }

        // if another app is disabling us, don't show
        if (!mExternallyEnabled && !lockedOrMissing) {
            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
        // if we're disabled by an app or profile, don't show
        if (!lockedOrMissing && isKeyguardDisabled()) {
            if (DEBUG) Log.d(TAG, "doKeyguard: not showing because keyguard is disabled");
            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.getScreenLockModeWithDPM(mContext) == Profile.LockMode.DISABLE) {
                if (DEBUG) Log.d(TAG, "doKeyguard: not showing because of profile override");
                return;
            }
        }

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