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

KeyguardBouncer

public class KeyguardBouncer extends Object
A class which manages the bouncer on the lockscreen.

Fields Summary
private android.content.Context
mContext
private com.android.keyguard.ViewMediatorCallback
mCallback
private com.android.internal.widget.LockPatternUtils
mLockPatternUtils
private android.view.ViewGroup
mContainer
private StatusBarWindowManager
mWindowManager
private com.android.keyguard.KeyguardViewBase
mKeyguardView
private android.view.ViewGroup
mRoot
private boolean
mShowingSoon
private android.view.Choreographer
mChoreographer
private final Runnable
mShowRunnable
Constructors Summary
public KeyguardBouncer(android.content.Context context, com.android.keyguard.ViewMediatorCallback callback, com.android.internal.widget.LockPatternUtils lockPatternUtils, StatusBarWindowManager windowManager, android.view.ViewGroup container)


        
               
              
        mContext = context;
        mCallback = callback;
        mLockPatternUtils = lockPatternUtils;
        mContainer = container;
        mWindowManager = windowManager;
    
Methods Summary
private voidcancelShowRunnable()


       
        mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, mShowRunnable, null);
        mShowingSoon = false;
    
private voidensureView()

        if (mRoot == null) {
            inflateView();
        }
    
public longgetUserActivityTimeout()

        if (mKeyguardView != null) {
            long timeout = mKeyguardView.getUserActivityTimeout();
            if (timeout >= 0) {
                return timeout;
            }
        }
        return KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS;
    
public voidhide(boolean destroyView)

        cancelShowRunnable();
         if (mKeyguardView != null) {
            mKeyguardView.setOnDismissAction(null);
            mKeyguardView.cleanUp();
        }
        if (destroyView) {
            removeView();
        } else if (mRoot != null) {
            mRoot.setVisibility(View.INVISIBLE);
        }
    
private voidinflateView()

        removeView();
        mRoot = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.keyguard_bouncer, null);
        mKeyguardView = (KeyguardViewBase) mRoot.findViewById(R.id.keyguard_host_view);
        mKeyguardView.setLockPatternUtils(mLockPatternUtils);
        mKeyguardView.setViewMediatorCallback(mCallback);
        mContainer.addView(mRoot, mContainer.getChildCount());
        mRoot.setVisibility(View.INVISIBLE);
        mRoot.setSystemUiVisibility(View.STATUS_BAR_DISABLE_HOME);
    
public booleaninterceptMediaKey(android.view.KeyEvent event)

        ensureView();
        return mKeyguardView.interceptMediaKey(event);
    
public booleanisFullscreenBouncer()
Like {@link #needsFullscreenBouncer}, but uses the currently visible security method, which makes this method much faster.

        if (mKeyguardView != null) {
            SecurityMode mode = mKeyguardView.getCurrentSecurityMode();
            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
        }
        return false;
    
public booleanisSecure()
WARNING: This method might cause Binder calls.

        return mKeyguardView == null || mKeyguardView.getSecurityMode() != SecurityMode.None;
    
public booleanisShowing()

        return mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE);
    
public booleanneedsFullscreenBouncer()

return
True if and only if the security method should be shown before showing the notifications on Keyguard, like SIM PIN/PUK.

        if (mKeyguardView != null) {
            SecurityMode mode = mKeyguardView.getSecurityMode();
            return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
        }
        return false;
    
public booleanonBackPressed()

        return mKeyguardView != null && mKeyguardView.handleBackKey();
    
public booleanonMenuPressed()

        ensureView();
        if (mKeyguardView.handleMenuKey()) {

            // We need to show it in case it is secure. If not, it will get dismissed in any case.
            mRoot.setVisibility(View.VISIBLE);
            mKeyguardView.requestFocus();
            mKeyguardView.onResume();
            return true;
        } else {
            return false;
        }
    
public voidonScreenTurnedOff()

        if (mKeyguardView != null && mRoot != null && mRoot.getVisibility() == View.VISIBLE) {
            mKeyguardView.onPause();
        }
    
public voidprepare()

        boolean wasInitialized = mRoot != null;
        ensureView();
        if (wasInitialized) {
            mKeyguardView.showPrimarySecurityScreen();
        }
    
private voidremoveView()

        if (mRoot != null && mRoot.getParent() == mContainer) {
            mContainer.removeView(mRoot);
            mRoot = null;
        }
    
public voidreset()
Reset the state of the view.

        cancelShowRunnable();
        inflateView();
    
public voidshow(boolean resetSecuritySelection)

        ensureView();
        if (resetSecuritySelection) {
            // showPrimarySecurityScreen() updates the current security method. This is needed in
            // case we are already showing and the current security method changed.
            mKeyguardView.showPrimarySecurityScreen();
        }
        if (mRoot.getVisibility() == View.VISIBLE || mShowingSoon) {
            return;
        }

        // Try to dismiss the Keyguard. If no security pattern is set, this will dismiss the whole
        // Keyguard. If we need to authenticate, show the bouncer.
        if (!mKeyguardView.dismiss()) {
            mShowingSoon = true;

            // Split up the work over multiple frames.
            mChoreographer.postCallbackDelayed(Choreographer.CALLBACK_ANIMATION, mShowRunnable,
                    null, 16);
        }
    
public voidshowWithDismissAction(com.android.keyguard.KeyguardHostView.OnDismissAction r)

        ensureView();
        mKeyguardView.setOnDismissAction(r);
        show(false /* resetSecuritySelection */);
    
public voidstartPreHideAnimation(java.lang.Runnable runnable)
See {@link StatusBarKeyguardViewManager#startPreHideAnimation}.

        if (mKeyguardView != null) {
            mKeyguardView.startDisappearAnimation(runnable);
        } else if (runnable != null) {
            runnable.run();
        }