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

Commit 09a40408 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Do not apply keyguard's short timeout when the keyguard is hidden by another window.



Fixes bug b/2215852 (Music player doesn't grab screen wakelock)

Change-Id: I6c402cdb460d216314ad72e37dbcdc7e19518941
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent bd998018
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -184,6 +184,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
    // answer whether the input should be restricted)
    private boolean mShowing = false;

    // true if the keyguard is hidden by another window
    private boolean mHidden = false;

    /**
     * Helps remember whether the screen has turned on since the last time
     * it turned off due to timeout. see {@link #onScreenTurnedOff(int)}
@@ -417,6 +420,16 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
        return mShowing;
    }

    /**
     * Notify us when the keyguard is hidden by another window
     */
    public void setHidden(boolean isHidden) {
        synchronized (KeyguardViewMediator.this) {
            mHidden = isHidden;
            adjustUserActivityLocked();
        }
    }

    /**
     * Given the state of the keyguard, is the input restricted?
     * Input is restricted when the keyguard is showing, or when the keyguard
@@ -860,12 +873,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
            if (DEBUG) Log.d(TAG, "handleShow");
            if (!mSystemReady) return;
            
            // while we're showing, we control the wake state, so ask the power
            // manager not to honor request for userActivity.
            mRealPowerManager.enableUserActivity(false);

            mKeyguardViewManager.show();
            mShowing = true;
            adjustUserActivityLocked();
            try {
                ActivityManagerNative.getDefault().closeSystemDialogs("lock");
            } catch (RemoteException e) {
@@ -885,14 +895,18 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                Log.w(TAG, "attempt to hide the keyguard while waking, ignored");
                return;
            }
            // When we go away, tell the poewr manager to honor requests from userActivity.
            mRealPowerManager.enableUserActivity(true);

            mKeyguardViewManager.hide();
            mShowing = false;
            adjustUserActivityLocked();
        }
    }

    private void adjustUserActivityLocked() {
        // disable user activity if we are shown and not hidden
        mRealPowerManager.enableUserActivity(!mShowing || mHidden);
    }

    /**
     * Handle message sent by {@link #wakeWhenReadyLocked(int)}
     * @param keyCode The key that woke the device.
+2 −0
Original line number Diff line number Diff line
@@ -1446,12 +1446,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                }
            } else if (mHideLockScreen) {
                if (mKeyguard.hideLw(false)) {
                    mKeyguardMediator.setHidden(true);
                    changes |= FINISH_LAYOUT_REDO_LAYOUT
                            | FINISH_LAYOUT_REDO_CONFIG
                            | FINISH_LAYOUT_REDO_WALLPAPER;
                }
            } else {
                if (mKeyguard.showLw(false)) {
                    mKeyguardMediator.setHidden(false);
                    changes |= FINISH_LAYOUT_REDO_LAYOUT
                            | FINISH_LAYOUT_REDO_CONFIG
                            | FINISH_LAYOUT_REDO_WALLPAPER;