FileDocCategorySizeDatePackage
StatusBarKeyguardViewManager.javaAPI DocAndroid 5.1 API15401Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar.phone

StatusBarKeyguardViewManager

public class StatusBarKeyguardViewManager extends Object
Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back via {@link ViewMediatorCallback} to poke the wake lock and report that the keyguard is done, which is in turn, reported to this class by the current {@link com.android.keyguard.KeyguardViewBase}.

Fields Summary
private static final long
HIDE_TIMING_CORRECTION_MS
private static final long
NAV_BAR_SHOW_DELAY_BOUNCER
private static String
TAG
private final android.content.Context
mContext
private com.android.internal.widget.LockPatternUtils
mLockPatternUtils
private com.android.keyguard.ViewMediatorCallback
mViewMediatorCallback
private PhoneStatusBar
mPhoneStatusBar
private ScrimController
mScrimController
private android.view.ViewGroup
mContainer
private StatusBarWindowManager
mStatusBarWindowManager
private boolean
mScreenOn
private KeyguardBouncer
mBouncer
private boolean
mShowing
private boolean
mOccluded
private boolean
mFirstUpdate
private boolean
mLastShowing
private boolean
mLastOccluded
private boolean
mLastBouncerShowing
private boolean
mLastBouncerDismissible
private com.android.keyguard.KeyguardHostView.OnDismissAction
mAfterKeyguardGoneAction
private Runnable
mMakeNavigationBarVisibleRunnable
Constructors Summary
public StatusBarKeyguardViewManager(android.content.Context context, com.android.keyguard.ViewMediatorCallback callback, com.android.internal.widget.LockPatternUtils lockPatternUtils)


        
              
        mContext = context;
        mViewMediatorCallback = callback;
        mLockPatternUtils = lockPatternUtils;
    
Methods Summary
private voidcallbackAfterDraw(com.android.internal.policy.IKeyguardShowCallback callback)

        mContainer.post(new Runnable() {
            @Override
            public void run() {
                try {
                    callback.onShown(mContainer.getWindowToken());
                } catch (RemoteException e) {
                    Slog.w(TAG, "Exception calling onShown():", e);
                }
            }
        });
    
public voiddismiss()
Dismisses the keyguard by going to the next screen or making it gone.

        if (mScreenOn) {
            showBouncer();
        }
    
public voiddismissWithAction(com.android.keyguard.KeyguardHostView.OnDismissAction r, boolean afterKeyguardGone)

        if (mShowing) {
            if (!afterKeyguardGone) {
                mBouncer.showWithDismissAction(r);
            } else {
                mBouncer.show(false /* resetSecuritySelection */);
                mAfterKeyguardGoneAction = r;
            }
        }
        updateStates();
    
private voidexecuteAfterKeyguardGoneAction()

        if (mAfterKeyguardGoneAction != null) {
            mAfterKeyguardGoneAction.onDismiss();
            mAfterKeyguardGoneAction = null;
        }
    
private longgetNavBarShowDelay()

        if (mPhoneStatusBar.isKeyguardFadingAway()) {
            return mPhoneStatusBar.getKeyguardFadingAwayDelay();
        } else {

            // Keyguard is not going away, thus we are showing the navigation bar because the
            // bouncer is appearing.
            return NAV_BAR_SHOW_DELAY_BOUNCER;
        }
    
public voidhide(long startTime, long fadeoutDuration)
Hides the keyguard view

        mShowing = false;

        long uptimeMillis = SystemClock.uptimeMillis();
        long delay = Math.max(0, startTime + HIDE_TIMING_CORRECTION_MS - uptimeMillis);

        if (mPhoneStatusBar.isInLaunchTransition() ) {
            mPhoneStatusBar.fadeKeyguardAfterLaunchTransition(new Runnable() {
                @Override
                public void run() {
                    mStatusBarWindowManager.setKeyguardShowing(false);
                    mStatusBarWindowManager.setKeyguardFadingAway(true);
                    mBouncer.hide(true /* destroyView */);
                    updateStates();
                    mScrimController.animateKeyguardFadingOut(
                            PhoneStatusBar.FADE_KEYGUARD_START_DELAY,
                            PhoneStatusBar.FADE_KEYGUARD_DURATION, null);
                }
            }, new Runnable() {
                @Override
                public void run() {
                    mPhoneStatusBar.hideKeyguard();
                    mStatusBarWindowManager.setKeyguardFadingAway(false);
                    mViewMediatorCallback.keyguardGone();
                    executeAfterKeyguardGoneAction();
                }
            });
        } else {
            mPhoneStatusBar.setKeyguardFadingAway(delay, fadeoutDuration);
            boolean staying = mPhoneStatusBar.hideKeyguard();
            if (!staying) {
                mStatusBarWindowManager.setKeyguardFadingAway(true);
                mScrimController.animateKeyguardFadingOut(delay, fadeoutDuration, new Runnable() {
                    @Override
                    public void run() {
                        mStatusBarWindowManager.setKeyguardFadingAway(false);
                        mPhoneStatusBar.finishKeyguardFadingAway();
                        WindowManagerGlobal.getInstance().trimMemory(
                                ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
                    }
                });
            } else {
                mScrimController.animateGoingToFullShade(delay, fadeoutDuration);
                mPhoneStatusBar.finishKeyguardFadingAway();
            }
            mStatusBarWindowManager.setKeyguardShowing(false);
            mBouncer.hide(true /* destroyView */);
            mViewMediatorCallback.keyguardGone();
            executeAfterKeyguardGoneAction();
            updateStates();
        }

    
public booleaninterceptMediaKey(android.view.KeyEvent event)

        return mBouncer.interceptMediaKey(event);
    
public booleanisBouncerShowing()

        return mBouncer.isShowing();
    
public booleanisGoingToNotificationShade()

        return mPhoneStatusBar.isGoingToNotificationShade();
    
public booleanisInputRestricted()

        return mViewMediatorCallback.isInputRestricted();
    
public booleanisOccluded()

        return mOccluded;
    
public booleanisSecure()
WARNING: This method might cause Binder calls.

        return mBouncer.isSecure();
    
public booleanisSecure(int userId)

        return mBouncer.isSecure() || mLockPatternUtils.isSecure(userId);
    
public booleanisShowing()

return
Whether the keyguard is showing

        return mShowing;
    
public voidonActivityDrawn()

        if (mPhoneStatusBar.isCollapsing()) {
            mPhoneStatusBar.addPostCollapseAction(new Runnable() {
                @Override
                public void run() {
                    mViewMediatorCallback.readyForKeyguardDone();
                }
            });
        } else {
            mViewMediatorCallback.readyForKeyguardDone();
        }
    
public booleanonBackPressed()
Notifies this manager that the back button has been pressed.

return
whether the back press has been handled

        if (mBouncer.isShowing()) {
            reset();
            return true;
        }
        return false;
    
public booleanonMenuPressed()

        return mBouncer.onMenuPressed();
    
public voidonScreenTurnedOff()

        mScreenOn = false;
        mPhoneStatusBar.onScreenTurnedOff();
        mBouncer.onScreenTurnedOff();
    
public voidonScreenTurnedOn(com.android.internal.policy.IKeyguardShowCallback callback)

        mScreenOn = true;
        mPhoneStatusBar.onScreenTurnedOn();
        if (callback != null) {
            callbackAfterDraw(callback);
        }
    
public voidregisterStatusBar(PhoneStatusBar phoneStatusBar, android.view.ViewGroup container, StatusBarWindowManager statusBarWindowManager, ScrimController scrimController)

        mPhoneStatusBar = phoneStatusBar;
        mContainer = container;
        mStatusBarWindowManager = statusBarWindowManager;
        mScrimController = scrimController;
        mBouncer = new KeyguardBouncer(mContext, mViewMediatorCallback, mLockPatternUtils,
                mStatusBarWindowManager, container);
    
public voidreset()
Reset the state of the view.

        if (mShowing) {
            if (mOccluded) {
                mPhoneStatusBar.hideKeyguard();
                mBouncer.hide(false /* destroyView */);
            } else {
                showBouncerOrKeyguard();
            }
            updateStates();
        }
    
public voidsetNeedsInput(boolean needsInput)

        mStatusBarWindowManager.setKeyguardNeedsInput(needsInput);
    
public voidsetOccluded(boolean occluded)

        if (occluded && !mOccluded && mShowing) {
            if (mPhoneStatusBar.isInLaunchTransition()) {
                mOccluded = true;
                mPhoneStatusBar.fadeKeyguardAfterLaunchTransition(null /* beforeFading */,
                        new Runnable() {
                            @Override
                            public void run() {
                                mStatusBarWindowManager.setKeyguardOccluded(mOccluded);
                                reset();
                            }
                        });
                return;
            }
        }
        mOccluded = occluded;
        mStatusBarWindowManager.setKeyguardOccluded(occluded);
        reset();
    
public booleanshouldDisableWindowAnimationsForUnlock()

        return mPhoneStatusBar.isInLaunchTransition();
    
public voidshow(android.os.Bundle options)
Show the keyguard. Will handle creating and attaching to the view manager lazily.

        mShowing = true;
        mStatusBarWindowManager.setKeyguardShowing(true);
        reset();
    
private voidshowBouncer()

        if (mShowing) {
            mBouncer.show(false /* resetSecuritySelection */);
        }
        updateStates();
    
private voidshowBouncerOrKeyguard()
Shows the notification keyguard or the bouncer depending on {@link KeyguardBouncer#needsFullscreenBouncer()}.

        if (mBouncer.needsFullscreenBouncer()) {

            // The keyguard might be showing (already). So we need to hide it.
            mPhoneStatusBar.hideKeyguard();
            mBouncer.show(true /* resetSecuritySelection */);
        } else {
            mPhoneStatusBar.showKeyguard();
            mBouncer.hide(false /* destroyView */);
            mBouncer.prepare();
        }
    
public voidstartPreHideAnimation(java.lang.Runnable finishRunnable)
Starts the animation before we dismiss Keyguard, i.e. an disappearing animation on the security view of the bouncer.

param
finishRunnable the runnable to be run after the animation finished, or {@code null} if no action should be run

        if (mBouncer.isShowing()) {
            mBouncer.startPreHideAnimation(finishRunnable);
        } else if (finishRunnable != null) {
            finishRunnable.run();
        }
    
private voidupdateStates()


       
        int vis = mContainer.getSystemUiVisibility();
        boolean showing = mShowing;
        boolean occluded = mOccluded;
        boolean bouncerShowing = mBouncer.isShowing();
        boolean bouncerDismissible = !mBouncer.isFullscreenBouncer();

        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 (!(showing && !occluded) || bouncerShowing) {
                    mContainer.postOnAnimationDelayed(mMakeNavigationBarVisibleRunnable,
                            getNavBarShowDelay());
                } else {
                    mContainer.removeCallbacks(mMakeNavigationBarVisibleRunnable);
                    mPhoneStatusBar.getNavigationBarView().setVisibility(View.GONE);
                }
            }
        }

        if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) {
            mStatusBarWindowManager.setBouncerShowing(bouncerShowing);
            mPhoneStatusBar.setBouncerShowing(bouncerShowing);
            mScrimController.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;

        mPhoneStatusBar.onKeyguardViewManagerStatesUpdated();
    
public voidupdateUserActivityTimeout()

        mStatusBarWindowManager.setKeyguardUserActivityTimeout(mBouncer.getUserActivityTimeout());
    
public voidverifyUnlock()

        dismiss();