ITvInputSessionWrapperpublic class ITvInputSessionWrapper extends ITvInputSession.Stub implements HandlerCaller.CallbackImplements the internal ITvInputSession interface to convert incoming calls on to it back to
calls on the public TvInputSession interface, scheduling them on the main thread of the process. |
Fields Summary |
---|
private static final String | TAG | private static final int | MESSAGE_HANDLING_DURATION_THRESHOLD_MILLIS | private static final int | MESSAGE_TUNE_DURATION_THRESHOLD_MILLIS | private static final int | DO_RELEASE | private static final int | DO_SET_MAIN | private static final int | DO_SET_SURFACE | private static final int | DO_DISPATCH_SURFACE_CHANGED | private static final int | DO_SET_STREAM_VOLUME | private static final int | DO_TUNE | private static final int | DO_SET_CAPTION_ENABLED | private static final int | DO_SELECT_TRACK | private static final int | DO_APP_PRIVATE_COMMAND | private static final int | DO_CREATE_OVERLAY_VIEW | private static final int | DO_RELAYOUT_OVERLAY_VIEW | private static final int | DO_REMOVE_OVERLAY_VIEW | private static final int | DO_REQUEST_UNBLOCK_CONTENT | private final com.android.internal.os.HandlerCaller | mCaller | private TvInputService.Session | mTvInputSessionImpl | private android.view.InputChannel | mChannel | private TvInputEventReceiver | mReceiver |
Constructors Summary |
---|
public ITvInputSessionWrapper(android.content.Context context, TvInputService.Session sessionImpl, android.view.InputChannel channel)
mCaller = new HandlerCaller(context, null, this, true /* asyncHandler */);
mTvInputSessionImpl = sessionImpl;
mChannel = channel;
if (channel != null) {
mReceiver = new TvInputEventReceiver(channel, context.getMainLooper());
}
|
Methods Summary |
---|
public void | appPrivateCommand(java.lang.String action, android.os.Bundle data)
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_APP_PRIVATE_COMMAND, action,
data));
| public void | createOverlayView(android.os.IBinder windowToken, android.graphics.Rect frame)
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_CREATE_OVERLAY_VIEW, windowToken,
frame));
| public void | dispatchSurfaceChanged(int format, int width, int height)
mCaller.executeOrSendMessage(mCaller.obtainMessageIIII(DO_DISPATCH_SURFACE_CHANGED,
format, width, height, 0));
| public void | executeMessage(android.os.Message msg)
if (mTvInputSessionImpl == null) {
return;
}
long startTime = System.currentTimeMillis();
switch (msg.what) {
case DO_RELEASE: {
mTvInputSessionImpl.release();
mTvInputSessionImpl = null;
if (mReceiver != null) {
mReceiver.dispose();
mReceiver = null;
}
if (mChannel != null) {
mChannel.dispose();
mChannel = null;
}
break;
}
case DO_SET_MAIN: {
mTvInputSessionImpl.setMain((Boolean) msg.obj);
break;
}
case DO_SET_SURFACE: {
mTvInputSessionImpl.setSurface((Surface) msg.obj);
break;
}
case DO_DISPATCH_SURFACE_CHANGED: {
SomeArgs args = (SomeArgs) msg.obj;
mTvInputSessionImpl.dispatchSurfaceChanged(args.argi1, args.argi2, args.argi3);
args.recycle();
break;
}
case DO_SET_STREAM_VOLUME: {
mTvInputSessionImpl.setStreamVolume((Float) msg.obj);
break;
}
case DO_TUNE: {
SomeArgs args = (SomeArgs) msg.obj;
mTvInputSessionImpl.tune((Uri) args.arg1, (Bundle) args.arg2);
args.recycle();
break;
}
case DO_SET_CAPTION_ENABLED: {
mTvInputSessionImpl.setCaptionEnabled((Boolean) msg.obj);
break;
}
case DO_SELECT_TRACK: {
SomeArgs args = (SomeArgs) msg.obj;
mTvInputSessionImpl.selectTrack((Integer) args.arg1, (String) args.arg2);
args.recycle();
break;
}
case DO_APP_PRIVATE_COMMAND: {
SomeArgs args = (SomeArgs) msg.obj;
mTvInputSessionImpl.appPrivateCommand((String) args.arg1, (Bundle) args.arg2);
args.recycle();
break;
}
case DO_CREATE_OVERLAY_VIEW: {
SomeArgs args = (SomeArgs) msg.obj;
mTvInputSessionImpl.createOverlayView((IBinder) args.arg1, (Rect) args.arg2);
args.recycle();
break;
}
case DO_RELAYOUT_OVERLAY_VIEW: {
mTvInputSessionImpl.relayoutOverlayView((Rect) msg.obj);
break;
}
case DO_REMOVE_OVERLAY_VIEW: {
mTvInputSessionImpl.removeOverlayView(true);
break;
}
case DO_REQUEST_UNBLOCK_CONTENT: {
mTvInputSessionImpl.unblockContent((String) msg.obj);
break;
}
default: {
Log.w(TAG, "Unhandled message code: " + msg.what);
break;
}
}
long duration = System.currentTimeMillis() - startTime;
if (duration > MESSAGE_HANDLING_DURATION_THRESHOLD_MILLIS) {
Log.w(TAG, "Handling message (" + msg.what + ") took too long time (duration="
+ duration + "ms)");
if (msg.what == DO_TUNE && duration > MESSAGE_TUNE_DURATION_THRESHOLD_MILLIS) {
throw new RuntimeException("Too much time to handle tune request. (" + duration
+ "ms > " + MESSAGE_TUNE_DURATION_THRESHOLD_MILLIS + "ms) "
+ "Consider handling the tune request in a separate thread.");
}
}
| public void | relayoutOverlayView(android.graphics.Rect frame)
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_RELAYOUT_OVERLAY_VIEW, frame));
| public void | release()
mTvInputSessionImpl.scheduleOverlayViewCleanup();
mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_RELEASE));
| public void | removeOverlayView()
mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_REMOVE_OVERLAY_VIEW));
| public void | requestUnblockContent(java.lang.String unblockedRating)
mCaller.executeOrSendMessage(mCaller.obtainMessageO(
DO_REQUEST_UNBLOCK_CONTENT, unblockedRating));
| public void | selectTrack(int type, java.lang.String trackId)
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_SELECT_TRACK, type, trackId));
| public void | setCaptionEnabled(boolean enabled)
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_CAPTION_ENABLED, enabled));
| public void | setMain(boolean isMain)
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_MAIN, isMain));
| public void | setSurface(android.view.Surface surface)
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_SURFACE, surface));
| public final void | setVolume(float volume)
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_STREAM_VOLUME, volume));
| public void | tune(android.net.Uri channelUri, android.os.Bundle params)
// Clear the pending tune requests.
mCaller.removeMessages(DO_TUNE);
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_TUNE, channelUri, params));
|
|