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

Commit b601162a authored by Adrian Roos's avatar Adrian Roos
Browse files

Fix visibility and add bouncer event in KeyguardUpdateMonitor

Bug: 14087751
Change-Id: I45bc2213dfcce751180762d18ead0382f68cac74
parent 54b6fd0c
Loading
Loading
Loading
Loading
+40 −2
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private static final int MSG_SCREEN_TURNED_ON = 319;
    private static final int MSG_SCREEN_TURNED_OFF = 320;
    private static final int MSG_NFC_UNLOCK = 321;
    private static final int MSG_KEYGUARD_BOUNCER_CHANGED = 322;

    private static KeyguardUpdateMonitor sInstance;

@@ -111,6 +112,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private int mRingMode;
    private int mPhoneState;
    private boolean mKeyguardIsVisible;
    private boolean mBouncer;
    private boolean mBootCompleted;

    // Device provisioning state
@@ -178,6 +180,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                case MSG_KEYGUARD_VISIBILITY_CHANGED:
                    handleKeyguardVisibilityChanged(msg.arg1);
                    break;
                case MSG_KEYGUARD_BOUNCER_CHANGED:
                    handleKeyguardBouncerChanged(msg.arg1);
                    break;
                case MSG_BOOT_COMPLETED:
                    handleBootCompleted();
                    break;
@@ -886,6 +891,22 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
    }

    /**
     * Handle {@link #MSG_KEYGUARD_BOUNCER_CHANGED}
     * @see #sendKeyguardBouncerChanged(boolean)
     */
    private void handleKeyguardBouncerChanged(int bouncer) {
        if (DEBUG) Log.d(TAG, "handleKeyguardBouncerChanged(" + bouncer + ")");
        boolean isBouncer = (bouncer == 1);
        mBouncer = isBouncer;
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onKeyguardBouncerChanged(isBouncer);
            }
        }
    }

    /**
     * Handle {@link #MSG_REPORT_EMERGENCY_CALL_ACTION}
     */
@@ -902,6 +923,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        return mKeyguardIsVisible;
    }

    /**
     * @return if the keyguard is currently in bouncer mode.
     */
    public boolean isKeyguardBouncer() {
        return mBouncer;
    }

    public boolean isSwitchingUser() {
        return mSwitchingUser;
    }
@@ -1021,6 +1049,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        message.sendToTarget();
    }

    /**
     * @see #handleKeyguardBouncerChanged(int)
     */
    public void sendKeyguardBouncerChanged(boolean showingBouncer) {
        if (DEBUG) Log.d(TAG, "sendKeyguardBouncerChanged(" + showingBouncer + ")");
        Message message = mHandler.obtainMessage(MSG_KEYGUARD_BOUNCER_CHANGED);
        message.arg1 = showingBouncer ? 1 : 0;
        message.sendToTarget();
    }

    public void reportClockVisible(boolean visible) {
        mClockVisible = visible;
        mHandler.obtainMessage(MSG_CLOCK_VISIBILITY_CHANGED).sendToTarget();
+6 −0
Original line number Diff line number Diff line
@@ -86,6 +86,12 @@ public class KeyguardUpdateMonitorCallback {
        mShowing = showing;
    }

    /**
     * Called when the keyguard enters or leaves bouncer mode.
     * @param bouncer if true, keyguard is now in bouncer mode.
     */
    public void onKeyguardBouncerChanged(boolean bouncer) { }

    /**
     * Called when visibility of lockscreen clock changes, such as when
     * obscured by a widget.
+0 −1
Original line number Diff line number Diff line
@@ -807,7 +807,6 @@ public class KeyguardViewMediator extends SystemUI {
     */
    public void setOccluded(boolean isOccluded) {
        if (DEBUG) Log.d(TAG, "setOccluded " + isOccluded);
        mUpdateMonitor.sendKeyguardVisibilityChanged(!isOccluded);
        mHandler.removeMessages(SET_OCCLUDED);
        Message msg = mHandler.obtainMessage(SET_OCCLUDED, (isOccluded ? 1 : 0), 0);
        mHandler.sendMessage(msg);
+46 −12
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.view.ViewGroup;

import com.android.internal.policy.IKeyguardShowCallback;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;

/**
@@ -51,6 +52,12 @@ public class StatusBarKeyguardViewManager {
    private boolean mShowing;
    private boolean mOccluded;

    private boolean mFirstUpdate = true;
    private boolean mLastShowing;
    private boolean mLastOccluded;
    private boolean mLastBouncerShowing;
    private boolean mLastBouncerDismissible;

    public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback,
            LockPatternUtils lockPatternUtils) {
        mContext = context;
@@ -208,21 +215,48 @@ public class StatusBarKeyguardViewManager {

    private void updateStates() {
        int vis = mContainer.getSystemUiVisibility();
        boolean bouncerDismissable = mBouncer.isShowing() && !mBouncer.needsFullscreenBouncer();
        if (bouncerDismissable || !mShowing) {
        boolean showing = mShowing;
        boolean occluded = mOccluded;
        boolean bouncerShowing = mBouncer.isShowing();
        boolean bouncerDismissible = bouncerShowing && !mBouncer.needsFullscreenBouncer();

        if ((bouncerDismissible || !showing) != (mLastBouncerDismissible || !mLastShowing)
                || mFirstUpdate) {
            if (bouncerDismissible || !showing) {
                mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK);
            } else {
                mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK);
            }
        }
        if ((!(showing && !occluded) || bouncerShowing)
                != (!(mLastShowing && !mLastOccluded) || mLastBouncerShowing) || mFirstUpdate) {
            if (mPhoneStatusBar.getNavigationBarView() != null) {
            if (!(mShowing && !mOccluded) || mBouncer.isShowing()) {
                if (!(showing && !occluded) || bouncerShowing) {
                    mPhoneStatusBar.getNavigationBarView().setVisibility(View.VISIBLE);
                } else {
                    mPhoneStatusBar.getNavigationBarView().setVisibility(View.GONE);
                }
            }
        mStatusBarWindowManager.setBouncerShowing(mBouncer.isShowing());
        mPhoneStatusBar.setBouncerShowing(mBouncer.isShowing());
        }

        if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) {
            mStatusBarWindowManager.setBouncerShowing(bouncerShowing);
            mPhoneStatusBar.setBouncerShowing(bouncerShowing);
        }

        KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
        if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) {
            updateMonitor.sendKeyguardVisibilityChanged(showing && !occluded);
        }
        if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) {
            updateMonitor.sendKeyguardBouncerChanged(bouncerShowing);
        }

        mFirstUpdate = false;
        mLastShowing = showing;
        mLastOccluded = occluded;
        mLastBouncerShowing = bouncerShowing;
        mLastBouncerDismissible = bouncerDismissible;
    }

    public boolean onMenuPressed() {