FileDocCategorySizeDatePackage
KeyguardViewManager.javaAPI DocAndroid 1.5 API7832Wed May 06 22:42:06 BST 2009com.android.internal.policy.impl

KeyguardViewManager

public class KeyguardViewManager extends Object implements KeyguardWindowController
Manages creating, showing, hiding and resetting the keyguard. Calls back via {@link com.android.internal.policy.impl.KeyguardViewCallback} to poke the wake lock and report that the keyguard is done, which is in turn, reported to this class by the current {@link KeyguardViewBase}.

Fields Summary
private static final boolean
DEBUG
private static String
TAG
private final android.content.Context
mContext
private final android.view.ViewManager
mViewManager
private final KeyguardViewCallback
mCallback
private final KeyguardViewProperties
mKeyguardViewProperties
private final KeyguardUpdateMonitor
mUpdateMonitor
private WindowManager.LayoutParams
mWindowLayoutParams
private boolean
mNeedsInput
private android.widget.FrameLayout
mKeyguardHost
private KeyguardViewBase
mKeyguardView
private boolean
mScreenOn
Constructors Summary
public KeyguardViewManager(android.content.Context context, android.view.ViewManager viewManager, KeyguardViewCallback callback, KeyguardViewProperties keyguardViewProperties, KeyguardUpdateMonitor updateMonitor)

param
context Used to create views.
param
viewManager Keyguard will be attached to this.
param
callback Used to notify of changes.


                              
        
                  
        mContext = context;
        mViewManager = viewManager;
        mCallback = callback;
        mKeyguardViewProperties = keyguardViewProperties;

        mUpdateMonitor = updateMonitor;
    
Methods Summary
public synchronized voidhide()
Hides the keyguard view

        if (DEBUG) Log.d(TAG, "hide()");
        if (mKeyguardHost != null) {
            mKeyguardHost.setVisibility(View.GONE);
            if (mKeyguardView != null) {
                mKeyguardHost.removeView(mKeyguardView);
                mKeyguardView.cleanUp();
                mKeyguardView = null;
            }
        }
    
public synchronized booleanisShowing()

return
Whether the keyguard is showing

        return (mKeyguardHost != null && mKeyguardHost.getVisibility() == View.VISIBLE);
    
public synchronized voidonScreenTurnedOff()

        if (DEBUG) Log.d(TAG, "onScreenTurnedOff()");
        mScreenOn = false;
        if (mKeyguardView != null) {
            mKeyguardView.onScreenTurnedOff();
        }
    
public synchronized voidonScreenTurnedOn()

        if (DEBUG) Log.d(TAG, "onScreenTurnedOn()");
        mScreenOn = true;
        if (mKeyguardView != null) {
            mKeyguardView.onScreenTurnedOn();
        }
    
public synchronized voidreset()
Reset the state of the view.

        if (DEBUG) Log.d(TAG, "reset()");
        if (mKeyguardView != null) {
            mKeyguardView.reset();
        }
    
public voidsetNeedsInput(boolean needsInput)

        mNeedsInput = needsInput;
        if (mWindowLayoutParams != null) {
            if (needsInput) {
                mWindowLayoutParams.flags &=
                    ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
            } else {
                mWindowLayoutParams.flags |=
                    WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
            }
            mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);
        }
    
public synchronized voidshow()
Show the keyguard. Will handle creating and attaching to the view manager lazily.

        if (DEBUG) Log.d(TAG, "show()");

        if (mKeyguardHost == null) {
            if (DEBUG) Log.d(TAG, "keyguard host is null, creating it...");

            mKeyguardHost = new KeyguardViewHost(mContext, mCallback);

            final int stretch = ViewGroup.LayoutParams.FILL_PARENT;
            int flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
                    /*| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR*/ ;
            if (!mNeedsInput) {
                flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
            }
            WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                    stretch, stretch, WindowManager.LayoutParams.TYPE_KEYGUARD,
                    flags, PixelFormat.OPAQUE);
            lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;
            lp.windowAnimations = com.android.internal.R.style.Animation_LockScreen;
            lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
            lp.setTitle("Keyguard");
            mWindowLayoutParams = lp;

            mViewManager.addView(mKeyguardHost, lp);
        }

        if (mKeyguardView == null) {
            if (DEBUG) Log.d(TAG, "keyguard view is null, creating it...");
            mKeyguardView = mKeyguardViewProperties.createKeyguardView(mContext, mUpdateMonitor, this);
            mKeyguardView.setId(R.id.lock_screen);
            mKeyguardView.setCallback(mCallback);

            final ViewGroup.LayoutParams lp = new FrameLayout.LayoutParams(
                    ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.FILL_PARENT);

            mKeyguardHost.addView(mKeyguardView, lp);

            if (mScreenOn) {
                mKeyguardView.onScreenTurnedOn();
            }
        }

        mKeyguardHost.setVisibility(View.VISIBLE);
        mKeyguardView.requestFocus();
    
public synchronized voidverifyUnlock()

        if (DEBUG) Log.d(TAG, "verifyUnlock()");
        show();
        mKeyguardView.verifyUnlock();
    
public voidwakeWhenReadyTq(int keyCode)
A key has woken the device. We use this to potentially adjust the state of the lock screen based on the key. The 'Tq' suffix is per the documentation in {@link android.view.WindowManagerPolicy}. Be sure not to take any action that takes a long time; any significant action should be posted to a handler.

param
keyCode The wake key.

        if (DEBUG) Log.d(TAG, "wakeWhenReady(" + keyCode + ")");
        if (mKeyguardView != null) {
            mKeyguardView.wakeWhenReadyTq(keyCode);
        }