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

Commit e4044bb6 authored by Jim Miller's avatar Jim Miller
Browse files

Fix KeyguardManager.isSecure() to observe work profile

The fix passes the calling userId instead of the current userId to
allow apps running as managed profiles to work.

Fixes bug 28666104

Change-Id: I9f8676ab11bd581d9e67b2b9f385036d4d3576ee
parent 1fdeb5bd
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1121,10 +1121,11 @@ public interface WindowManagerPolicy {
     * isKeyguardSecure
     *
     * Return whether the keyguard requires a password to unlock.
     * @param userId
     *
     * @return true if in keyguard is secure.
     */
    public boolean isKeyguardSecure();
    public boolean isKeyguardSecure(int userId);

    /**
     * Return whether the keyguard is on.
+7 −5
Original line number Diff line number Diff line
@@ -3392,7 +3392,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }

        if (down) {
            long shortcutCode = (long) keyCode;
            long shortcutCode = keyCode;
            if (event.isCtrlPressed()) {
                shortcutCode |= ((long) KeyEvent.META_CTRL_ON) << Integer.SIZE;
            }
@@ -3511,6 +3511,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return false;
    }

    @Override
    public void registerShortcutKey(long shortcutCode, IShortcutService shortcutService)
            throws RemoteException {
        synchronized (mLock) {
@@ -4816,7 +4817,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mShowingLockscreen = false;
        mShowingDream = false;
        mWinShowWhenLocked = null;
        mKeyguardSecure = isKeyguardSecure();
        mKeyguardSecure = isKeyguardSecure(mCurrentUserId);
        mKeyguardSecureIncludingHidden = mKeyguardSecure
                && (mKeyguardDelegate != null && mKeyguardDelegate.isShowing());
    }
@@ -6283,9 +6284,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    /** {@inheritDoc} */
    @Override
    public boolean isKeyguardSecure() {
    public boolean isKeyguardSecure(int userId) {
        if (mKeyguardDelegate == null) return false;
        return mKeyguardDelegate.isSecure();
        return mKeyguardDelegate.isSecure(userId);
    }

    /** {@inheritDoc} */
@@ -6315,6 +6316,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    @Override
    public void notifyActivityDrawnForKeyguardLw() {
        if (mKeyguardDelegate != null) {
            mHandler.post(new Runnable() {
@@ -6830,7 +6832,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private void updateLockScreenTimeout() {
        synchronized (mScreenLockTimeout) {
            boolean enable = (mAllowLockscreenWhenOn && mAwake &&
                    mKeyguardDelegate != null && mKeyguardDelegate.isSecure());
                    mKeyguardDelegate != null && mKeyguardDelegate.isSecure(mCurrentUserId));
            if (mLockScreenTimerActive != enable) {
                if (enable) {
                    if (localLOGV) Log.v(TAG, "setting lockscreen timer");
+2 −2
Original line number Diff line number Diff line
@@ -226,9 +226,9 @@ public class KeyguardServiceDelegate {
        }
    }

    public boolean isSecure() {
    public boolean isSecure(int userId) {
        if (mKeyguardService != null) {
            mKeyguardState.secure = mKeyguardService.isSecure();
            mKeyguardState.secure = mKeyguardService.isSecure(userId);
        }
        return mKeyguardState.secure;
    }
+2 −2
Original line number Diff line number Diff line
@@ -234,8 +234,8 @@ public class KeyguardServiceWrapper implements IKeyguardService {
        return mKeyguardStateMonitor.isShowing();
    }

    public boolean isSecure() {
        return mKeyguardStateMonitor.isSecure();
    public boolean isSecure(int userId) {
        return mKeyguardStateMonitor.isSecure(userId);
    }

    public boolean isInputRestricted() {
+2 −2
Original line number Diff line number Diff line
@@ -62,8 +62,8 @@ public class KeyguardStateMonitor extends IKeyguardStateCallback.Stub {
        return mIsShowing;
    }

    public boolean isSecure() {
        return mLockPatternUtils.isSecure(getCurrentUser()) || mSimSecure;
    public boolean isSecure(int userId) {
        return mLockPatternUtils.isSecure(userId) || mSimSecure;
    }

    public boolean isInputRestricted() {
Loading