KeyguardDisplayManagerpublic 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 void | hide()
if (mShowing) {
if (DEBUG) Slog.v(TAG, "hide");
mMediaRouter.removeCallback(mMediaRouterCallback);
updateDisplays(false);
}
mShowing = false;
| public void | show()
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 void | updateDisplays(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;
}
}
|
|