FileDocCategorySizeDatePackage
KeyguardDisplayManager.javaAPI DocAndroid 5.1 API6502Thu Mar 12 22:22:42 GMT 2015com.android.keyguard

KeyguardDisplayManager

public class KeyguardDisplayManager extends Object

Fields Summary
protected static final String
TAG
private static boolean
DEBUG
android.app.Presentation
mPresentation
private android.media.MediaRouter
mMediaRouter
private android.content.Context
mContext
private boolean
mShowing
private final MediaRouter.SimpleCallback
mMediaRouterCallback
private android.content.DialogInterface.OnDismissListener
mOnDismissListener
Constructors Summary
public KeyguardDisplayManager(android.content.Context context)


       
        mContext = context;
        mMediaRouter = (MediaRouter) mContext.getSystemService(Context.MEDIA_ROUTER_SERVICE);
    
Methods Summary
public voidhide()

        if (mShowing) {
            if (DEBUG) Slog.v(TAG, "hide");
            mMediaRouter.removeCallback(mMediaRouterCallback);
            updateDisplays(false);
        }
        mShowing = false;
    
public voidshow()

        if (!mShowing) {
            if (DEBUG) Slog.v(TAG, "show");
            mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY,
                    mMediaRouterCallback, MediaRouter.CALLBACK_FLAG_PASSIVE_DISCOVERY);
            updateDisplays(true);
        }
        mShowing = true;
    
protected voidupdateDisplays(boolean showing)


        
        if (showing) {
            MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(
                    MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY);
            boolean useDisplay = route != null
                    && route.getPlaybackType() == MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE;
            Display presentationDisplay = useDisplay ? route.getPresentationDisplay() : null;

            if (mPresentation != null && mPresentation.getDisplay() != presentationDisplay) {
                if (DEBUG) Slog.v(TAG, "Display gone: " + mPresentation.getDisplay());
                mPresentation.dismiss();
                mPresentation = null;
            }

            if (mPresentation == null && presentationDisplay != null) {
                if (DEBUG) Slog.i(TAG, "Keyguard enabled on display: " + presentationDisplay);
                mPresentation = new KeyguardPresentation(mContext, presentationDisplay);
                mPresentation.setOnDismissListener(mOnDismissListener);
                try {
                    mPresentation.show();
                } catch (WindowManager.InvalidDisplayException ex) {
                    Slog.w(TAG, "Invalid display:", ex);
                    mPresentation = null;
                }
            }
        } else {
            if (mPresentation != null) {
                mPresentation.dismiss();
                mPresentation = null;
            }
        }