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

Commit 23ccd216 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Fix visibility and add bouncer event in KeyguardUpdateMonitor"

parents f28d1ac6 b601162a
Loading
Loading
Loading
Loading
+40 −2
Original line number Original line 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_ON = 319;
    private static final int MSG_SCREEN_TURNED_OFF = 320;
    private static final int MSG_SCREEN_TURNED_OFF = 320;
    private static final int MSG_NFC_UNLOCK = 321;
    private static final int MSG_NFC_UNLOCK = 321;
    private static final int MSG_KEYGUARD_BOUNCER_CHANGED = 322;


    private static KeyguardUpdateMonitor sInstance;
    private static KeyguardUpdateMonitor sInstance;


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


    // Device provisioning state
    // Device provisioning state
@@ -178,6 +180,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                case MSG_KEYGUARD_VISIBILITY_CHANGED:
                case MSG_KEYGUARD_VISIBILITY_CHANGED:
                    handleKeyguardVisibilityChanged(msg.arg1);
                    handleKeyguardVisibilityChanged(msg.arg1);
                    break;
                    break;
                case MSG_KEYGUARD_BOUNCER_CHANGED:
                    handleKeyguardBouncerChanged(msg.arg1);
                    break;
                case MSG_BOOT_COMPLETED:
                case MSG_BOOT_COMPLETED:
                    handleBootCompleted();
                    handleBootCompleted();
                    break;
                    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}
     * Handle {@link #MSG_REPORT_EMERGENCY_CALL_ACTION}
     */
     */
@@ -902,6 +923,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        return mKeyguardIsVisible;
        return mKeyguardIsVisible;
    }
    }


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

    public boolean isSwitchingUser() {
    public boolean isSwitchingUser() {
        return mSwitchingUser;
        return mSwitchingUser;
    }
    }
@@ -1021,6 +1049,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        message.sendToTarget();
        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) {
    public void reportClockVisible(boolean visible) {
        mClockVisible = visible;
        mClockVisible = visible;
        mHandler.obtainMessage(MSG_CLOCK_VISIBILITY_CHANGED).sendToTarget();
        mHandler.obtainMessage(MSG_CLOCK_VISIBILITY_CHANGED).sendToTarget();
+6 −0
Original line number Original line Diff line number Diff line
@@ -86,6 +86,12 @@ public class KeyguardUpdateMonitorCallback {
        mShowing = showing;
        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
     * Called when visibility of lockscreen clock changes, such as when
     * obscured by a widget.
     * obscured by a widget.
+0 −1
Original line number Original line Diff line number Diff line
@@ -807,7 +807,6 @@ public class KeyguardViewMediator extends SystemUI {
     */
     */
    public void setOccluded(boolean isOccluded) {
    public void setOccluded(boolean isOccluded) {
        if (DEBUG) Log.d(TAG, "setOccluded " + isOccluded);
        if (DEBUG) Log.d(TAG, "setOccluded " + isOccluded);
        mUpdateMonitor.sendKeyguardVisibilityChanged(!isOccluded);
        mHandler.removeMessages(SET_OCCLUDED);
        mHandler.removeMessages(SET_OCCLUDED);
        Message msg = mHandler.obtainMessage(SET_OCCLUDED, (isOccluded ? 1 : 0), 0);
        Message msg = mHandler.obtainMessage(SET_OCCLUDED, (isOccluded ? 1 : 0), 0);
        mHandler.sendMessage(msg);
        mHandler.sendMessage(msg);
+46 −12
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import android.view.ViewGroup;


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


/**
/**
@@ -51,6 +52,12 @@ public class StatusBarKeyguardViewManager {
    private boolean mShowing;
    private boolean mShowing;
    private boolean mOccluded;
    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,
    public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback,
            LockPatternUtils lockPatternUtils) {
            LockPatternUtils lockPatternUtils) {
        mContext = context;
        mContext = context;
@@ -208,21 +215,48 @@ public class StatusBarKeyguardViewManager {


    private void updateStates() {
    private void updateStates() {
        int vis = mContainer.getSystemUiVisibility();
        int vis = mContainer.getSystemUiVisibility();
        boolean bouncerDismissable = mBouncer.isShowing() && !mBouncer.needsFullscreenBouncer();
        boolean showing = mShowing;
        if (bouncerDismissable || !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);
                mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK);
            } else {
            } else {
                mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK);
                mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK);
            }
            }
        }
        if ((!(showing && !occluded) || bouncerShowing)
                != (!(mLastShowing && !mLastOccluded) || mLastBouncerShowing) || mFirstUpdate) {
            if (mPhoneStatusBar.getNavigationBarView() != null) {
            if (mPhoneStatusBar.getNavigationBarView() != null) {
            if (!(mShowing && !mOccluded) || mBouncer.isShowing()) {
                if (!(showing && !occluded) || bouncerShowing) {
                    mPhoneStatusBar.getNavigationBarView().setVisibility(View.VISIBLE);
                    mPhoneStatusBar.getNavigationBarView().setVisibility(View.VISIBLE);
                } else {
                } else {
                    mPhoneStatusBar.getNavigationBarView().setVisibility(View.GONE);
                    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() {
    public boolean onMenuPressed() {