TvInputService.HardwareSession


public static abstract class TvInputService.HardwareSession
extends TvInputService.Session

java.lang.Object
   ↳ android.media.tv.TvInputService.Session
     ↳ android.media.tv.TvInputService.HardwareSession


Base class for a TV input session which represents an external device connected to a hardware TV input.

This class is for an input which provides channels for the external set-top box to the application. Once a TV input returns an implementation of this class on TvInputService.onCreateSession(java.lang.String), the framework will create a separate session for a hardware TV Input (e.g. HDMI 1) and forward the application's surface to the session so that the user can see the screen of the hardware TV Input when she tunes to a channel from this TV input. The implementation of this class is expected to change the channel of the external set-top box via a proprietary protocol when HardwareSession.onTune is requested by the application.

Note that this class is not for inputs for internal hardware like built-in tuner and HDMI 1.

Summary

Public constructors

HardwareSession(Context context)

Creates a new HardwareSession.

Public methods

abstract String getHardwareInputId()

Returns the hardware TV input ID the external device is connected to.

void onHardwareVideoAvailable()

Called when the underlying hardware TV input session calls TvInputService.Session.notifyVideoAvailable().

void onHardwareVideoUnavailable(int reason)

Called when the underlying hardware TV input session calls TvInputService.Session.notifyVideoUnavailable(int).

final boolean onSetSurface(Surface surface)

This method will not be called in HardwareSession.

Inherited methods

void layoutSurface(int left, int top, int right, int bottom)

Assigns a size and position to the surface passed in onSetSurface(Surface).

void notifyAdBufferConsumed(AdBuffer buffer)

Notifies the advertisement buffer is consumed.

void notifyAdResponse(AdResponse response)

Notifies response for advertisement.

void notifyAitInfoUpdated(AitInfo aitInfo)

Informs the app that the AIT (Application Information Table) is updated.

void notifyAudioPresentationChanged(List<AudioPresentation> audioPresentations)

Sends an updated list of all audio presentations available from a Next Generation Audio service.

void notifyAudioPresentationSelected(int presentationId, int programId)

Sends the presentation and program IDs of the selected audio presentation.

void notifyAvailableSpeeds(float[] speeds)

Informs the app available speeds for time-shifting.

void notifyBroadcastInfoResponse(BroadcastInfoResponse response)

Notifies response for broadcast info.

void notifyChannelRetuned(Uri channelUri)

Informs the application that the current channel is re-tuned for some reason and the session now displays the content from a new channel.

void notifyContentAllowed()

Informs the application that the user is allowed to watch the current program content.

void notifyContentBlocked(TvContentRating rating)

Informs the application that the current program content is blocked by parent controls.

void notifyCueingMessageAvailability(boolean available)

Informs the application that cueing message is available or unavailable.

void notifySignalStrength(int strength)

Notifies signal strength.

void notifyTimeShiftMode(int mode)

Informs the app that the time shift mode is set or updated.

void notifyTimeShiftStatusChanged(int status)

Informs the application that the time shift status is changed.

void notifyTrackSelected(int type, String trackId)

Sends the type and ID of a selected track.

void notifyTracksChanged(List<TvTrackInfo> tracks)

Sends the list of all audio/video/subtitle tracks.

void notifyTuned(Uri channelUri)

Informs the application that this session has been tuned to the given channel.

void notifyTvMessage(int type, Bundle data)

Sends the raw data from the received TV message as well as the type of message received.

void notifyVideoAvailable()

Informs the application that the video is now available for watching.

void notifyVideoFreezeUpdated(boolean isFrozen)

Informs the application that the video freeze state has been updated.

void notifyVideoUnavailable(int reason)

Informs the application that the video became unavailable for some reason.

void onAdBufferReady(AdBuffer buffer)

Called when an advertisement buffer is ready for playback.

void onAppPrivateCommand(String action, Bundle data)

Processes a private command sent from the application to the TV input.

View onCreateOverlayView()

Called when the application requests to create an overlay view.

boolean onGenericMotionEvent(MotionEvent event)

Implement this method to handle generic motion events on the current input session.

boolean onKeyDown(int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyDown(): always returns false (doesn't handle the event).

boolean onKeyLongPress(int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyLongPress(): always returns false (doesn't handle the event).

boolean onKeyMultiple(int keyCode, int count, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).

boolean onKeyUp(int keyCode, KeyEvent event)

Default implementation of KeyEvent.Callback.onKeyUp(): always returns false (doesn't handle the event).

void onOverlayViewSizeChanged(int width, int height)

Called when the size of the overlay view is changed by the application.

abstract void onRelease()

Called when the session is released.

void onRemoveBroadcastInfo(int requestId)

Called when broadcast info is removed.

void onRequestAd(AdRequest request)

Called when advertisement request is received.

void onRequestBroadcastInfo(BroadcastInfoRequest request)

Called when broadcast info is requested.

void onResumePlayback()

Resumes playback of the Audio, Video, and CC streams.

boolean onSelectAudioPresentation(int presentationId, int programId)

Selects an audio presentation.

boolean onSelectTrack(int type, String trackId)

Selects a given track.

abstract void onSetCaptionEnabled(boolean enabled)

Enables or disables the caption.

void onSetInteractiveAppNotificationEnabled(boolean enabled)

Enables or disables interactive app notification.

abstract void onSetStreamVolume(float volume)

Sets the relative stream volume of the current TV input session.

abstract boolean onSetSurface(Surface surface)

Called when the application sets the surface.

void onSetTvMessageEnabled(int type, boolean enabled)

Called when the application enables or disables the detection of the specified message type.

void onStopPlayback(int mode)

Called when the application requests playback of the Audio, Video, and CC streams to be stopped, but the metadata should continue to be filtered.

void onSurfaceChanged(int format, int width, int height)

Called after any structural changes (format or size) have been made to the surface passed in onSetSurface(Surface).

long onTimeShiftGetCurrentPosition()

Returns the current position for time shifting, in milliseconds since the epoch.

long onTimeShiftGetStartPosition()

Returns the start position for time shifting, in milliseconds since the epoch.

void onTimeShiftPause()

Called when the application requests to pause playback.

void onTimeShiftPlay(Uri recordedProgramUri)

Called when the application requests to play a given recorded TV program.

void onTimeShiftResume()

Called when the application requests to resume playback.

void onTimeShiftSeekTo(long timeMs)

Called when the application requests to seek to a specified time position.

void onTimeShiftSetMode(int mode)

Called when the application sets time shift mode.

void onTimeShiftSetPlaybackParams(PlaybackParams params)

Called when the application sets playback parameters containing the speed and audio mode.

boolean onTouchEvent(MotionEvent event)

Implement this method to handle touch screen motion events on the current input session.

boolean onTrackballEvent(MotionEvent event)

Implement this method to handle trackball events on the current input session.

boolean onTune(Uri channelUri, Bundle params)

Tunes to a given channel.

abstract boolean onTune(Uri channelUri)

Tunes to a given channel.

void onTvAdSessionData(String type, Bundle data)

Called when data from the linked TvAdService is received.

void onTvMessage(int type, Bundle data)

Called when a TV message is received

void onUnblockContent(TvContentRating unblockedRating)

Requests to unblock the content according to the given rating.

void sendTvInputSessionData(String type, Bundle data)

Sends data related to this session to corresponding linked TvAdService object via TvAdView.

void setOverlayViewEnabled(boolean enable)

Enables or disables the overlay view.

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

abstract boolean onKeyDown(int keyCode, KeyEvent event)

Called when a key down event has occurred.

abstract boolean onKeyLongPress(int keyCode, KeyEvent event)

Called when a long press has occurred.

abstract boolean onKeyMultiple(int keyCode, int count, KeyEvent event)

Called when a user's interaction with an analog control, such as flinging a trackball, generates simulated down/up events for the same key multiple times in quick succession.

abstract boolean onKeyUp(int keyCode, KeyEvent event)

Called when a key up event has occurred.

Public constructors

HardwareSession

Added in API level 21
public HardwareSession (Context context)

Creates a new HardwareSession.

Parameters
context Context: The context of the application

Public methods

getHardwareInputId

Added in API level 21
public abstract String getHardwareInputId ()

Returns the hardware TV input ID the external device is connected to.

TV input is expected to provide R.attr.setupActivity so that the application can launch it before using this TV input. The setup activity may let the user select the hardware TV input to which the external device is connected. The ID of the selected one should be stored in the TV input so that it can be returned here.

Returns
String

onHardwareVideoAvailable

Added in API level 21
public void onHardwareVideoAvailable ()

Called when the underlying hardware TV input session calls TvInputService.Session.notifyVideoAvailable().

onHardwareVideoUnavailable

Added in API level 21
public void onHardwareVideoUnavailable (int reason)

Called when the underlying hardware TV input session calls TvInputService.Session.notifyVideoUnavailable(int).

onSetSurface

Added in API level 21
public final boolean onSetSurface (Surface surface)

This method will not be called in HardwareSession. Framework will forward the application's surface to the hardware TV input.

Parameters
surface Surface: The surface to be used for video rendering. Can be null.

Returns
boolean true if the surface was set successfully, false otherwise.