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

Commit 9200a398 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Handle KeyguardViewMediator.setHidden() asynchronously to avoid deadlocks.



Fixes b/2267046 (Could not shut off alarm; then device reboot)

Change-Id: Id8f3e24edc5e1242a39c5d43bd549b5cb05abb36
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 5425930b
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
    private static final int KEYGUARD_DONE = 9;
    private static final int KEYGUARD_DONE_DRAWING = 10;
    private static final int KEYGUARD_DONE_AUTHENTICATING = 11;
    private static final int SET_HIDDEN = 12;
    
    /**
     * The default amount of time we stay awake (used for all key input)
@@ -425,11 +426,22 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
     */
    public void setHidden(boolean isHidden) {
        if (DEBUG) Log.d(TAG, "setHidden " + isHidden);
        mHandler.removeMessages(SET_HIDDEN);
        Message msg = mHandler.obtainMessage(SET_HIDDEN, (isHidden ? 1 : 0), 0);
        mHandler.sendMessage(msg);
    }

    /**
     * Handles SET_HIDDEN message sent by setHidden()
     */
    private void handleSetHidden(boolean isHidden) {
        synchronized (KeyguardViewMediator.this) {
            if (mHidden != isHidden) {
                mHidden = isHidden;
                adjustUserActivityLocked();
            }
        }
    }

    /**
     * Given the state of the keyguard, is the input restricted?
@@ -812,6 +824,9 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
                case KEYGUARD_DONE_AUTHENTICATING:
                    keyguardDone(true);
                    return;
                case SET_HIDDEN:
                    handleSetHidden(msg.arg1 != 0);
                    break;
            }
        }
    };