Added in API level 33

Session


abstract class Session : KeyEvent.Callback
kotlin.Any
   ↳ android.media.tv.interactive.TvInteractiveAppService.Session

Base class for derived classes to implement to provide a TV interactive app session.

A session is associated with a TvInteractiveAppView instance and handles corresponding communications. It also handles the communications with android.media.tv.TvInputService.Session if connected.

Summary

Public constructors
Session(context: Context)

Creates a new Session.

Public methods
open Boolean

Returns true if media view is enabled, false otherwise.

open Unit
layoutSurface(left: Int, top: Int, right: Int, bottom: Int)

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

open Unit

Notifies when the advertisement buffer is filled and ready to be read.

Unit
notifyBiInteractiveAppCreated(biIAppUri: Uri, biIAppId: String?)

Notifies the broadcast-independent(BI) interactive application has been created.

open Unit

Notifies when the session state is changed.

Unit

Notifies when the digital teletext app state is changed.

open Unit

Called when an advertisement buffer is consumed.

open Unit

Called when an advertisement response is received.

open Unit

Receives available playback speeds.

open Unit

Called when a broadcast info response is received.

open Unit
onCertificate(host: String, port: Int, cert: SslCertificate)

Receives the requested Certificate

open Unit

Called when content is allowed.

open Unit

Called when content is blocked.

open Unit

Creates broadcast-independent(BI) interactive application.

open View?

Called when the application requests to create an media view.

open Unit

Receives logical channel number (LCN) of current channel.

open Unit
onCurrentChannelUri(channelUri: Uri?)

Receives current channel URI.

open Unit

Receives current TV input ID.

open Unit

Receives current video bounds.

open Unit

Destroys broadcast-independent(BI) interactive application.

open Unit
onError(errMsg: String, params: Bundle)

Called when the application sends information of an error.

open Boolean

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

open Boolean
onKeyDown(keyCode: Int, event: KeyEvent)

Called when a key down event has occurred.

open Boolean
onKeyLongPress(keyCode: Int, event: KeyEvent)

Called when a long press has occurred.

open Boolean
onKeyMultiple(keyCode: Int, count: Int, event: KeyEvent)

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.

open Boolean
onKeyUp(keyCode: Int, event: KeyEvent)

Called when a key up event has occurred.

open Unit
onMediaViewSizeChanged(width: Int, height: Int)

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

open Unit
onRecordingConnectionFailed(recordingId: String, inputId: String)

This is called when an error occurred while establishing a connection to the recording session for the corresponding TV input.

open Unit
onRecordingDisconnected(recordingId: String, inputId: String)

This is called when the connection to the current recording session is lost.

open Unit
onRecordingError(recordingId: String, err: Int)

This is called when an issue has occurred.

open Unit
onRecordingScheduled(recordingId: String, requestId: String?)

This is called when the recording has been scheduled.

open Unit
onRecordingStarted(recordingId: String, requestId: String?)

This is called when a recording has been started.

open Unit
onRecordingStopped(recordingId: String)

This is called when the recording has been stopped.

open Unit
onRecordingTuned(recordingId: String, channelUri: Uri)

This is called when the recording session has been tuned to the given channel and is ready to start recording.

abstract Unit

Releases TvInteractiveAppService session.

open Unit

Resets TvInteractiveAppService session.

open Unit

Called when the TV App sends the selected track info as a response to requestSelectedTrackInfo().

abstract Boolean
onSetSurface(surface: Surface?)

Called when the application sets the surface.

open Unit

To toggle Digital Teletext Application if there is one in AIT app list.

open Unit
onSignalStrength(strength: Int)

Called when signal strength is changed.

open Unit
onSigningResult(signingId: String, result: ByteArray)

Receives signing result.

open Unit

Starts TvInteractiveAppService session.

open Unit

Stops TvInteractiveAppService session.

open Unit

Receives current stream volume.

open Unit
onSurfaceChanged(format: Int, width: Int, height: Int)

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

open Unit

Called when time shift current position is changed.

open Unit

Receives current time shift mode.

open Unit

Called when the time shift android.media.PlaybackParams is set or changed.

open Unit

Called when time shift start position is changed.

open Unit
onTimeShiftStatusChanged(inputId: String, status: Int)

Called when time shift status is changed.

open Boolean

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

open Unit

Receives track list.

open Unit
onTrackSelected(type: Int, trackId: String)

Called when the corresponding TV input selected to a track.

open Boolean

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

open Unit

Called when the tracks are changed.

open Unit
onTuned(channelUri: Uri)

Called when the corresponding TV input tuned to a channel.

open Unit
onTvMessage(type: Int, data: Bundle)

Called when a TV message is received

open Unit

Receives the requested android.media.tv.TvRecordingInfo.

open Unit

Receives requested recording info list.

open Unit

Called when video is available.

open Unit

Called when video becomes frozen or unfrozen.

open Unit

Called when video is unavailable.

open Unit

Remove broadcast information request from the related TV input.

open Unit
requestAd(request: AdRequest)

Sends an advertisement request to be processed by the related TV input.

open Unit

Requests available speeds for time shift.

open Unit

Requests broadcast related information from the related TV input.

open Unit
requestCertificate(host: String, port: Int)

Requests a SSL certificate for client validation.

open Unit

Requests the logic channel number (LCN) of the current channel.

open Unit

Requests the URI of the current channel.

open Unit

Requests current TV input ID.

open Unit

Requests the bounds of the current video.

open Unit
requestScheduleRecording(requestId: String, inputId: String, channelUri: Uri, programUri: Uri, params: Bundle)

Requests scheduling of a recording.

open Unit
requestScheduleRecording(requestId: String, inputId: String, channelUri: Uri, startTime: Long, duration: Long, repeatDays: Int, params: Bundle)

Requests scheduling of a recording.

open Unit

Requests a list of the currently selected TvTrackInfo from the TV App.

open Unit
requestSigning(signingId: String, algorithm: String, alias: String, data: ByteArray)

Requests signing of the given data.

open Unit
requestSigning(signingId: String, algorithm: String, host: String, port: Int, data: ByteArray)

Requests signing of the given data.

open Unit
requestStartRecording(requestId: String, programUri: Uri?)

Requests starting of recording

open Unit

Requests the recording associated with the recordingId to stop.

open Unit

Requests stream volume.

open Unit

Requests time shift mode.

open Unit

Requests the list of TvTrackInfo.

open Unit

Gets the recording info for the specified recording
If you override this method you must call through to the superclass implementation.

open Unit

Gets a list of TvRecordingInfo for the specified recording type.

open Unit
sendPlaybackCommandRequest(cmdType: String, parameters: Bundle?)

Sends a specific playback command to be processed by the related TV input.

open Unit
sendTimeShiftCommandRequest(cmdType: String, parameters: Bundle?)

Sends a specific time shift command to be processed by the related TV input.

open Unit

Enables or disables the media view.

open Unit
setTvRecordingInfo(recordingId: String, recordingInfo: TvRecordingInfo)

Sets the recording info for the specified recording
If you override this method you must call through to the superclass implementation.

open Unit

Sets broadcast video bounds.

Public constructors

Session

Added in API level 33
Session(context: Context)

Creates a new Session.

Parameters
context Context: The context of the application This value cannot be null.

Public methods

isMediaViewEnabled

Added in API level 33
open fun isMediaViewEnabled(): Boolean

Returns true if media view is enabled, false otherwise.

layoutSurface

Added in API level 33
open fun layoutSurface(
    left: Int,
    top: Int,
    right: Int,
    bottom: Int
): Unit

Assigns a size and position to the surface passed in onSetSurface. The position is relative to the overlay view that sits on top of this surface.
If you override this method you must call through to the superclass implementation.

Parameters
left Int: Left position in pixels, relative to the overlay view.
top Int: Top position in pixels, relative to the overlay view.
right Int: Right position in pixels, relative to the overlay view.
bottom Int: Bottom position in pixels, relative to the overlay view.

notifyAdBufferReady

Added in API level 34
open fun notifyAdBufferReady(buffer: AdBuffer): Unit

Notifies when the advertisement buffer is filled and ready to be read.
If you override this method you must call through to the superclass implementation.

Parameters
buffer AdBuffer: The AdBuffer to be received This value cannot be null.

notifyBiInteractiveAppCreated

Added in API level 33
fun notifyBiInteractiveAppCreated(
    biIAppUri: Uri,
    biIAppId: String?
): Unit

Notifies the broadcast-independent(BI) interactive application has been created.
If you override this method you must call through to the superclass implementation.

Parameters
biIAppId String?: BI interactive app ID, which can be used to destroy the BI interactive app. null if it's not created successfully.
biIAppUri Uri: This value cannot be null.

notifyTeletextAppStateChanged

Added in API level 33
fun notifyTeletextAppStateChanged(state: Int): Unit

Notifies when the digital teletext app state is changed.
If you override this method you must call through to the superclass implementation.

Parameters
state Int: the current state. Value is android.media.tv.interactive.TvInteractiveAppManager#TELETEXT_APP_STATE_SHOW, android.media.tv.interactive.TvInteractiveAppManager#TELETEXT_APP_STATE_HIDE, or android.media.tv.interactive.TvInteractiveAppManager#TELETEXT_APP_STATE_ERROR

onAdBufferConsumed

Added in API level 34
open fun onAdBufferConsumed(buffer: AdBuffer): Unit

Called when an advertisement buffer is consumed.

Parameters
buffer AdBuffer: The AdBuffer that was consumed. This value cannot be null.

onAdResponse

Added in API level 33
open fun onAdResponse(response: AdResponse): Unit

Called when an advertisement response is received.

Parameters
response AdResponse: This value cannot be null.

onAvailableSpeeds

Added in API level 34
open fun onAvailableSpeeds(speeds: FloatArray): Unit

Receives available playback speeds.

Parameters
speeds FloatArray: An ordered array of playback speeds, expressed as values relative to the normal playback speed (1.0), at which the current content can be played as a time-shifted broadcast. This is an empty array if the supported playback speeds are unknown or the video/broadcast is not in time shift mode. If currently in time shift mode, this array will normally include at least the values 1.0 (normal speed) and 0.0 (paused). This value cannot be null.

onBroadcastInfoResponse

Added in API level 33
open fun onBroadcastInfoResponse(response: BroadcastInfoResponse): Unit

Called when a broadcast info response is received.

Parameters
response BroadcastInfoResponse: This value cannot be null.

onCertificate

open fun onCertificate(
    host: String,
    port: Int,
    cert: SslCertificate
): Unit

Receives the requested Certificate

Parameters
host String: the host name of the SSL authentication server. This value cannot be null.
port Int: the port of the SSL authentication server. E.g., 443
cert SslCertificate: the SSL certificate received. This value cannot be null.

onContentAllowed

Added in API level 33
open fun onContentAllowed(): Unit

Called when content is allowed.

onContentBlocked

Added in API level 33
open fun onContentBlocked(rating: TvContentRating): Unit

Called when content is blocked.

Parameters
rating TvContentRating: This value cannot be null.

onCreateBiInteractiveAppRequest

Added in API level 33
open fun onCreateBiInteractiveAppRequest(
    biIAppUri: Uri,
    params: Bundle?
): Unit

Creates broadcast-independent(BI) interactive application.

The implementation should call notifyBiInteractiveAppCreated(android.net.Uri,java.lang.String), no matter if it's created successfully or not.

Parameters
biIAppUri Uri: This value cannot be null.
params Bundle?: This value may be null.

onCreateMediaView

Added in API level 33
open fun onCreateMediaView(): View?

Called when the application requests to create an media view. Each session implementation can override this method and return its own view.

Return
View? a view attached to the media window This value may be null.

onCurrentChannelLcn

Added in API level 33
open fun onCurrentChannelLcn(lcn: Int): Unit

Receives logical channel number (LCN) of current channel.

onCurrentChannelUri

Added in API level 33
open fun onCurrentChannelUri(channelUri: Uri?): Unit

Receives current channel URI.

Parameters
channelUri Uri?: This value may be null.

onCurrentTvInputId

Added in API level 33
open fun onCurrentTvInputId(inputId: String?): Unit

Receives current TV input ID.

Parameters
inputId String?: This value may be null.

onCurrentVideoBounds

Added in API level 34
open fun onCurrentVideoBounds(bounds: Rect): Unit

Receives current video bounds.

Parameters
bounds Rect: the rectangle area for rendering the current video. This value cannot be null.

onDestroyBiInteractiveAppRequest

Added in API level 33
open fun onDestroyBiInteractiveAppRequest(biIAppId: String): Unit

Destroys broadcast-independent(BI) interactive application.

Parameters
biIAppId String: the BI interactive app ID from onCreateBiInteractiveAppRequest(android.net.Uri,android.os.Bundle) This value cannot be null.

onError

Added in API level 33
open fun onError(
    errMsg: String,
    params: Bundle
): Unit

Called when the application sends information of an error.

Parameters
errMsg String: the message of the error. This value cannot be null.
params Bundle: additional parameters of the error. For example, the signingId of android.media.tv.interactive.TvInteractiveAppView.TvInteractiveAppCallback#onRequestSigning(java.lang.String,java.lang.String,java.lang.String,java.lang.String,byte[]) can be included to identify the related signing request, and the method name "onRequestSigning" can also be added to the params. This value cannot be null.

onGenericMotionEvent

Added in API level 33
open fun onGenericMotionEvent(event: MotionEvent): Boolean

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

Parameters
event MotionEvent: The motion event being received. This value cannot be null.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyDown

Added in API level 33
open fun onKeyDown(
    keyCode: Int,
    event: KeyEvent
): Boolean

Called when a key down event has occurred. If you return true, you can first call KeyEvent.startTracking() to have the framework track the event through its onKeyUp(int,android.view.KeyEvent) and also call your onKeyLongPress(int,android.view.KeyEvent) if it occurs.

Parameters
keyCode Int: The value in event.getKeyCode().
event KeyEvent: This value cannot be null.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyLongPress

Added in API level 33
open fun onKeyLongPress(
    keyCode: Int,
    event: KeyEvent
): Boolean

Called when a long press has occurred. If you return true, the final key up will have KeyEvent.FLAG_CANCELED and KeyEvent.FLAG_CANCELED_LONG_PRESS set. Note that in order to receive this callback, someone in the event change must return true from onKeyDown and call KeyEvent.startTracking() on the event.

Parameters
keyCode Int: The value in event.getKeyCode().
event KeyEvent: This value cannot be null.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyMultiple

Added in API level 33
open fun onKeyMultiple(
    keyCode: Int,
    count: Int,
    event: KeyEvent
): Boolean

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.

Parameters
keyCode Int: The value in event.getKeyCode().
count Int: Number of pairs as returned by event.getRepeatCount().
event KeyEvent: This value cannot be null.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyUp

Added in API level 33
open fun onKeyUp(
    keyCode: Int,
    event: KeyEvent
): Boolean

Called when a key up event has occurred.

Parameters
keyCode Int: The value in event.getKeyCode().
event KeyEvent: This value cannot be null.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onMediaViewSizeChanged

Added in API level 33
open fun onMediaViewSizeChanged(
    width: Int,
    height: Int
): Unit

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

This is always called at least once when the session is created regardless of whether the media view is enabled or not. The media view container size is the same as the containing TvInteractiveAppView. Note that the size of the underlying surface can be different if the surface was changed by calling layoutSurface.

Parameters
width Int: The width of the media view, in pixels. The units of this value are pixels.
height Int: The height of the media view, in pixels. The units of this value are pixels.

onRecordingConnectionFailed

Added in API level 34
open fun onRecordingConnectionFailed(
    recordingId: String,
    inputId: String
): Unit

This is called when an error occurred while establishing a connection to the recording session for the corresponding TV input.

Parameters
recordingId String: The ID of the related recording which is sent via TvInteractiveAppView.notifyRecordingStarted(String, String) This value cannot be null.
inputId String: The ID of the TV input bound to the current TvRecordingClient. This value cannot be null.

onRecordingDisconnected

Added in API level 34
open fun onRecordingDisconnected(
    recordingId: String,
    inputId: String
): Unit

This is called when the connection to the current recording session is lost.

Parameters
recordingId String: The ID of the related recording which is sent via TvInteractiveAppView.notifyRecordingStarted(String, String) This value cannot be null.
inputId String: The ID of the TV input bound to the current TvRecordingClient. This value cannot be null.

onRecordingError

Added in API level 34
open fun onRecordingError(
    recordingId: String,
    err: Int
): Unit

This is called when an issue has occurred. It may be called at any time after the current recording session is created until it is released.

Parameters
recordingId String: The ID of the related recording which is sent via TvInteractiveAppView.notifyRecordingStarted(String, String) This value cannot be null.
err Int: The error code. Should be one of the following. Value is android.media.tv.TvInputManager#RECORDING_ERROR_UNKNOWN, android.media.tv.TvInputManager#RECORDING_ERROR_INSUFFICIENT_SPACE, or android.media.tv.TvInputManager#RECORDING_ERROR_RESOURCE_BUSY

onRecordingScheduled

Added in API level 34
open fun onRecordingScheduled(
    recordingId: String,
    requestId: String?
): Unit

This is called when the recording has been scheduled.

Parameters
recordingId String: The ID assigned to this recording by the app. It can be used to send recording related requests such as requestStopRecording(java.lang.String). This value cannot be null.
requestId String?: The ID of the request when #requestScheduleRecording is called. null if the recording is not triggered by a request. This ID should be created by the TvInteractiveAppService and can be any string.

onRecordingStarted

Added in API level 34
open fun onRecordingStarted(
    recordingId: String,
    requestId: String?
): Unit

This is called when a recording has been started.

When a scheduled recording is started, this is also called, and the request ID in this case is null.

Parameters
recordingId String: The ID of the recording started. The TV app should provide and maintain this ID to identify the recording in the future. This value cannot be null.
requestId String?: The ID of the request when requestStartRecording(java.lang.String,android.net.Uri) is called. null if the recording is not triggered by a requestStartRecording(java.lang.String,android.net.Uri) request. This ID should be created by the TvInteractiveAppService and can be any string.

onRecordingStopped

Added in API level 34
open fun onRecordingStopped(recordingId: String): Unit

This is called when the recording has been stopped.

Parameters
recordingId String: The ID of the recording stopped. This ID is created and maintained by the TV app when the recording was started. This value cannot be null.

onRecordingTuned

Added in API level 34
open fun onRecordingTuned(
    recordingId: String,
    channelUri: Uri
): Unit

This is called when the recording session has been tuned to the given channel and is ready to start recording.

Parameters
recordingId String: The ID of the related recording which is sent via TvInteractiveAppView.notifyRecordingStarted(String, String) This value cannot be null.
channelUri Uri: The URI of the tuned channel. This value cannot be null.

onRelease

Added in API level 33
abstract fun onRelease(): Unit

Releases TvInteractiveAppService session.

onResetInteractiveApp

Added in API level 33
open fun onResetInteractiveApp(): Unit

Resets TvInteractiveAppService session.

onSelectedTrackInfo

open fun onSelectedTrackInfo(tracks: MutableList<TvTrackInfo!>): Unit

Called when the TV App sends the selected track info as a response to requestSelectedTrackInfo().

When a selected track changes as a result of a new selection, onTrackSelected(int,java.lang.String) should be used instead to communicate the specific track selection.

Parameters
tracks MutableList<TvTrackInfo!>: A list of TvTrackInfo that are currently selected This value cannot be null.

onSetSurface

Added in API level 33
abstract fun onSetSurface(surface: Surface?): Boolean

Called when the application sets the surface.

The TV Interactive App service should render interactive app UI onto the given surface. When called with null, the Interactive App service should immediately free any references to the currently set surface and stop using it.

Parameters
surface Surface?: The surface to be used for interactive app UI rendering. Can be null.
Return
Boolean true if the surface was set successfully, false otherwise.

onSetTeletextAppEnabled

Added in API level 33
open fun onSetTeletextAppEnabled(enable: Boolean): Unit

To toggle Digital Teletext Application if there is one in AIT app list.

Parameters
enable Boolean: true to enable teletext app; false otherwise.

onSignalStrength

Added in API level 33
open fun onSignalStrength(strength: Int): Unit

Called when signal strength is changed.

Parameters
strength Int: Value is android.media.tv.TvInputManager#SIGNAL_STRENGTH_LOST, android.media.tv.TvInputManager#SIGNAL_STRENGTH_WEAK, or android.media.tv.TvInputManager#SIGNAL_STRENGTH_STRONG

onSigningResult

Added in API level 33
open fun onSigningResult(
    signingId: String,
    result: ByteArray
): Unit

Receives signing result.

Parameters
signingId String: the ID to identify the request. It's the same as the corresponding ID in Session.requestSigning(String, String, String, byte[]) This value cannot be null.
result ByteArray: the signed result. This value cannot be null.

onStartInteractiveApp

Added in API level 33
open fun onStartInteractiveApp(): Unit

Starts TvInteractiveAppService session.

onStopInteractiveApp

Added in API level 33
open fun onStopInteractiveApp(): Unit

Stops TvInteractiveAppService session.

onStreamVolume

Added in API level 33
open fun onStreamVolume(volume: Float): Unit

Receives current stream volume.

Parameters
volume Float: a volume value between 0.0f and 1.0f, inclusive.

onSurfaceChanged

Added in API level 33
open fun onSurfaceChanged(
    format: Int,
    width: Int,
    height: Int
): Unit

Called after any structural changes (format or size) have been made to the surface passed in onSetSurface. This method is always called at least once, after onSetSurface is called with non-null surface.

Parameters
format Int: The new PixelFormat of the surface. Value is android.graphics.PixelFormat#RGBA_8888, android.graphics.PixelFormat#RGBX_8888, android.graphics.PixelFormat#RGBA_F16, android.graphics.PixelFormat#RGBA_1010102, android.graphics.PixelFormat#RGB_888, android.graphics.PixelFormat#RGB_565, or android.graphics.PixelFormat.R_8
width Int: The new width of the surface.
height Int: The new height of the surface.

onTimeShiftCurrentPositionChanged

Added in API level 34
open fun onTimeShiftCurrentPositionChanged(
    inputId: String,
    timeMs: Long
): Unit

Called when time shift current position is changed.

Parameters
inputId String: The ID of the input for which the time shift current position has changed. This value cannot be null.
timeMs Long: The current position for time shifting, in milliseconds since the epoch.

onTimeShiftPlaybackParams

Added in API level 34
open fun onTimeShiftPlaybackParams(params: PlaybackParams): Unit

Called when the time shift android.media.PlaybackParams is set or changed.

Parameters
params PlaybackParams: The new PlaybackParams that was set or changed. This value cannot be null.

onTimeShiftStartPositionChanged

Added in API level 34
open fun onTimeShiftStartPositionChanged(
    inputId: String,
    timeMs: Long
): Unit

Called when time shift start position is changed.

Parameters
inputId String: The ID of the input for which the time shift start position has changed. This value cannot be null.
timeMs Long: The start position for time shifting, in milliseconds since the epoch.

onTouchEvent

Added in API level 33
open fun onTouchEvent(event: MotionEvent): Boolean

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

Parameters
event MotionEvent: The motion event being received. This value cannot be null.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onTrackInfoList

Added in API level 33
open fun onTrackInfoList(tracks: MutableList<TvTrackInfo!>): Unit

Receives track list.

Parameters
tracks MutableList<TvTrackInfo!>: This value cannot be null.

onTrackSelected

Added in API level 33
open fun onTrackSelected(
    type: Int,
    trackId: String
): Unit

Called when the corresponding TV input selected to a track. If the track is deselected and no track is currently selected, trackId is an empty string.

Parameters
type Int: Value is android.media.tv.TvTrackInfo#TYPE_AUDIO, android.media.tv.TvTrackInfo#TYPE_VIDEO, or android.media.tv.TvTrackInfo#TYPE_SUBTITLE
trackId String: This value cannot be null.

onTrackballEvent

Added in API level 33
open fun onTrackballEvent(event: MotionEvent): Boolean

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

Parameters
event MotionEvent: The motion event being received. This value cannot be null.
Return
Boolean If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onTracksChanged

Added in API level 33
open fun onTracksChanged(tracks: MutableList<TvTrackInfo!>): Unit

Called when the tracks are changed.

Parameters
tracks MutableList<TvTrackInfo!>: This value cannot be null.

onTuned

Added in API level 33
open fun onTuned(channelUri: Uri): Unit

Called when the corresponding TV input tuned to a channel.

Parameters
channelUri Uri: The tuned channel URI. This value cannot be null.

onTvMessage

Added in API level 34
open fun onTvMessage(
    type: Int,
    data: Bundle
): Unit

Called when a TV message is received

Parameters
type Int: The type of message received, such as TvInputManager.TV_MESSAGE_TYPE_WATERMARK Value is android.media.tv.TvInputManager#TV_MESSAGE_TYPE_WATERMARK, android.media.tv.TvInputManager#TV_MESSAGE_TYPE_CLOSED_CAPTION, or android.media.tv.TvInputManager#TV_MESSAGE_TYPE_OTHER
data Bundle: The raw data of the message. The bundle keys are: TvInputManager.TV_MESSAGE_KEY_STREAM_ID, TvInputManager.TV_MESSAGE_KEY_GROUP_ID, TvInputManager.TV_MESSAGE_KEY_SUBTYPE, TvInputManager.TV_MESSAGE_KEY_RAW_DATA. See TvInputManager.TV_MESSAGE_KEY_SUBTYPE for more information on how to parse this data. This value cannot be null.

onTvRecordingInfo

Added in API level 34
open fun onTvRecordingInfo(recordingInfo: TvRecordingInfo?): Unit

Receives the requested android.media.tv.TvRecordingInfo.

Parameters
recordingInfo TvRecordingInfo?: The requested recording info. null if no recording found.

onTvRecordingInfoList

Added in API level 34
open fun onTvRecordingInfoList(recordingInfoList: MutableList<TvRecordingInfo!>): Unit

Receives requested recording info list.

Parameters
recordingInfoList MutableList<TvRecordingInfo!>: The list of recording info requested. Returns an empty list if no matching recording info found. This value cannot be null.

onVideoAvailable

Added in API level 33
open fun onVideoAvailable(): Unit

Called when video is available.

onVideoFreezeUpdated

open fun onVideoFreezeUpdated(isFrozen: Boolean): Unit

Called when video becomes frozen or unfrozen. Audio playback will continue while video will be frozen to the last frame if true.

Parameters
isFrozen Boolean: Whether or not the video is frozen.

onVideoUnavailable

Added in API level 33
open fun onVideoUnavailable(reason: Int): Unit

Called when video is unavailable.

Parameters
reason Int: Value is android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_UNKNOWN, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_TUNING, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_BUFFERING, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_NOT_CONNECTED, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_INSUFFICIENT_RESOURCE, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_INSUFFICIENT_OUTPUT_PROTECTION, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_PVR_RECORDING_NOT_ALLOWED, android.media.tv.TvInputManager.VIDEO_UNAVAILABLE_REASON_CAS_NO_LICENSE, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_LICENSE_EXPIRED, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NEED_ACTIVATION, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NEED_PAIRING, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_NO_CARD, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_CARD_MUTE, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_CARD_INVALID, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_BLACKOUT, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_REBOOTING, android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_CAS_UNKNOWN, or android.media.tv.TvInputManager#VIDEO_UNAVAILABLE_REASON_STOPPED

removeBroadcastInfo

Added in API level 33
open fun removeBroadcastInfo(requestId: Int): Unit

Remove broadcast information request from the related TV input.
If you override this method you must call through to the superclass implementation.

Parameters
requestId Int: the ID of the request

requestAd

Added in API level 33
open fun requestAd(request: AdRequest): Unit

Sends an advertisement request to be processed by the related TV input.
If you override this method you must call through to the superclass implementation.

Parameters
request AdRequest: The advertisement request This value cannot be null.

requestAvailableSpeeds

Added in API level 34
open fun requestAvailableSpeeds(): Unit

Requests available speeds for time shift.
If you override this method you must call through to the superclass implementation.

requestBroadcastInfo

Added in API level 33
open fun requestBroadcastInfo(request: BroadcastInfoRequest): Unit

Requests broadcast related information from the related TV input.
If you override this method you must call through to the superclass implementation.

Parameters
request BroadcastInfoRequest: the request for broadcast info This value cannot be null.

requestCertificate

open fun requestCertificate(
    host: String,
    port: Int
): Unit

Requests a SSL certificate for client validation.
If you override this method you must call through to the superclass implementation.

Parameters
host String: the host name of the SSL authentication server. This value cannot be null.
port Int: the port of the SSL authentication server. E.g., 443

requestCurrentChannelLcn

Added in API level 33
open fun requestCurrentChannelLcn(): Unit

Requests the logic channel number (LCN) of the current channel.
If you override this method you must call through to the superclass implementation.

requestCurrentChannelUri

Added in API level 33
open fun requestCurrentChannelUri(): Unit

Requests the URI of the current channel.
If you override this method you must call through to the superclass implementation.

requestCurrentTvInputId

Added in API level 33
open fun requestCurrentTvInputId(): Unit

Requests current TV input ID.
If you override this method you must call through to the superclass implementation.

requestCurrentVideoBounds

Added in API level 34
open fun requestCurrentVideoBounds(): Unit

Requests the bounds of the current video.
If you override this method you must call through to the superclass implementation.

requestScheduleRecording

Added in API level 34
open fun requestScheduleRecording(
    requestId: String,
    inputId: String,
    channelUri: Uri,
    programUri: Uri,
    params: Bundle
): Unit

Requests scheduling of a recording.
If you override this method you must call through to the superclass implementation.

Parameters
requestId String: The ID of this request which is used to match the corresponding response. The request ID in onRecordingScheduled(java.lang.String,java.lang.String) for this request is the same as the ID sent here. This should be defined by the TvInteractiveAppService and can be any string. Should this API be called with the same requestId twice, both requests should be handled regardless by the TV application. This value cannot be null.
inputId String: The ID of the TV input for the given channel. This value cannot be null.
channelUri Uri: The URI of a channel to be recorded. This value cannot be null.
programUri Uri: The URI of the TV program to be recorded. This value cannot be null.
params Bundle: Domain-specific data for this tune request. Keys must be a scoped name, i.e. prefixed with a package name you own, so that different developers will not create conflicting keys. This value cannot be null.

requestScheduleRecording

Added in API level 34
open fun requestScheduleRecording(
    requestId: String,
    inputId: String,
    channelUri: Uri,
    startTime: Long,
    duration: Long,
    repeatDays: Int,
    params: Bundle
): Unit

Requests scheduling of a recording.
If you override this method you must call through to the superclass implementation.

Parameters
requestId String: The ID of this request which is used to match the corresponding response. The request ID in onRecordingScheduled(java.lang.String,java.lang.String) for this request is the same as the ID sent here. This should be defined by the TvInteractiveAppService and can be any string. Should this API be called with the same requestId twice, both requests should be handled regardless by the TV application. This value cannot be null.
inputId String: The ID of the TV input for the given channel. This value cannot be null.
channelUri Uri: The URI of a channel to be recorded. This value cannot be null.
startTime Long: The start time of the recording in milliseconds since epoch.
duration Long: The duration of the recording in milliseconds.
repeatDays Int: The repeated days. 0 if not repeated.
params Bundle: Domain-specific data for this tune request. Keys must be a scoped name, i.e. prefixed with a package name you own, so that different developers will not create conflicting keys. This value cannot be null.

requestSelectedTrackInfo

open fun requestSelectedTrackInfo(): Unit

Requests a list of the currently selected TvTrackInfo from the TV App.

Normally, track info cannot be synchronized until the channel has been changed. This is used when the session of the TvInteractiveAppService is newly created and the normal synchronization has not happened yet.

The track info will be returned in onSelectedTrackInfo(java.util.List)
If you override this method you must call through to the superclass implementation.

requestSigning

Added in API level 33
open fun requestSigning(
    signingId: String,
    algorithm: String,
    alias: String,
    data: ByteArray
): Unit

Requests signing of the given data.

This is used when the corresponding server of the broadcast-independent interactive app requires signing during handshaking, and the interactive app service doesn't have the built-in private key. The private key is provided by the content providers and pre-built in the related app, such as TV app.
If you override this method you must call through to the superclass implementation.

Parameters
signingId String: the ID to identify the request. When a result is received, this ID can be used to correlate the result with the request. This value cannot be null.
algorithm String: the standard name of the signature algorithm requested, such as MD5withRSA, SHA256withDSA, etc. The name is from standards like FIPS PUB 186-4 and PKCS #1. This value cannot be null.
alias String: the alias of the corresponding java.security.KeyStore. This value cannot be null.
data ByteArray: the original bytes to be signed. This value cannot be null.

requestSigning

open fun requestSigning(
    signingId: String,
    algorithm: String,
    host: String,
    port: Int,
    data: ByteArray
): Unit

Requests signing of the given data.

This is used when the corresponding server of the broadcast-independent interactive app requires signing during handshaking, and the interactive app service doesn't have the built-in private key. The private key is provided by the content providers and pre-built in the related app, such as TV app.
If you override this method you must call through to the superclass implementation.

Parameters
signingId String: the ID to identify the request. When a result is received, this ID can be used to correlate the result with the request. This value cannot be null.
algorithm String: the standard name of the signature algorithm requested, such as MD5withRSA, SHA256withDSA, etc. The name is from standards like FIPS PUB 186-4 and PKCS #1. This value cannot be null.
host String: the host of the SSL client authentication server. This value cannot be null.
port Int: the port of the SSL client authentication server.
data ByteArray: the original bytes to be signed. This value cannot be null.

requestStartRecording

Added in API level 34
open fun requestStartRecording(
    requestId: String,
    programUri: Uri?
): Unit

Requests starting of recording

This is used to request the active android.media.tv.TvRecordingClient to call android.media.tv.TvRecordingClient#startRecording(Uri) with the provided programUri. A non-null programUri implies the started recording should be of that specific program, whereas null programUri does not impose such a requirement and the recording can span across multiple TV programs.
If you override this method you must call through to the superclass implementation.

Parameters
requestId String: The ID of this request which is used to match the corresponding response. The request ID in onRecordingStarted(java.lang.String,java.lang.String) for this request is the same as the ID sent here. This should be defined by the TvInteractiveAppService and can be any string. Should this API be called with the same requestId twice, both requests should be handled regardless by the TV application. This value cannot be null.
programUri Uri?: The URI for the TV program to record, built by TvContract.buildProgramUri(long). Can be null.

requestStopRecording

Added in API level 34
open fun requestStopRecording(recordingId: String): Unit

Requests the recording associated with the recordingId to stop.

This is used to request the associated android.media.tv.TvRecordingClient to call android.media.tv.TvRecordingClient#stopRecording().
If you override this method you must call through to the superclass implementation.

Parameters
recordingId String: The ID of the recording to stop. This is provided by the TV app in TvInteractiveAppView.notifyRecordingStarted(String, String) This value cannot be null.

requestStreamVolume

Added in API level 33
open fun requestStreamVolume(): Unit

Requests stream volume.
If you override this method you must call through to the superclass implementation.

requestTimeShiftMode

Added in API level 34
open fun requestTimeShiftMode(): Unit

Requests time shift mode.
If you override this method you must call through to the superclass implementation.

requestTrackInfoList

Added in API level 33
open fun requestTrackInfoList(): Unit

Requests the list of TvTrackInfo.
If you override this method you must call through to the superclass implementation.

requestTvRecordingInfo

Added in API level 34
open fun requestTvRecordingInfo(recordingId: String): Unit

Gets the recording info for the specified recording
If you override this method you must call through to the superclass implementation.

Parameters
recordingId String: The ID of the recording to set the info for. This is provided by the TV app in TvInteractiveAppView.notifyRecordingStarted(String, String) This value cannot be null.

requestTvRecordingInfoList

Added in API level 34
open fun requestTvRecordingInfoList(type: Int): Unit

Gets a list of TvRecordingInfo for the specified recording type.
If you override this method you must call through to the superclass implementation.

Parameters
type Int: The type of recording to retrieve. Value is android.media.tv.TvRecordingInfo#RECORDING_SCHEDULED, android.media.tv.TvRecordingInfo#RECORDING_IN_PROGRESS, or android.media.tv.TvRecordingInfo#RECORDING_ALL

sendPlaybackCommandRequest

Added in API level 33
open fun sendPlaybackCommandRequest(
    cmdType: String,
    parameters: Bundle?
): Unit

Sends a specific playback command to be processed by the related TV input.
If you override this method you must call through to the superclass implementation.

Parameters
cmdType String: type of the specific command Value is android.media.tv.interactive.TvInteractiveAppService#PLAYBACK_COMMAND_TYPE_TUNE, android.media.tv.interactive.TvInteractiveAppService#PLAYBACK_COMMAND_TYPE_TUNE_NEXT, android.media.tv.interactive.TvInteractiveAppService#PLAYBACK_COMMAND_TYPE_TUNE_PREV, android.media.tv.interactive.TvInteractiveAppService#PLAYBACK_COMMAND_TYPE_STOP, android.media.tv.interactive.TvInteractiveAppService#PLAYBACK_COMMAND_TYPE_SET_STREAM_VOLUME, android.media.tv.interactive.TvInteractiveAppService#PLAYBACK_COMMAND_TYPE_SELECT_TRACK, or android.media.tv.interactive.TvInteractiveAppService.PLAYBACK_COMMAND_TYPE_FREEZE This value cannot be null.
parameters Bundle?: parameters of the specific command This value may be null.

sendTimeShiftCommandRequest

Added in API level 34
open fun sendTimeShiftCommandRequest(
    cmdType: String,
    parameters: Bundle?
): Unit

Sends a specific time shift command to be processed by the related TV input.
If you override this method you must call through to the superclass implementation.

Parameters
cmdType String: type of the specific command Value is android.media.tv.interactive.TvInteractiveAppService#TIME_SHIFT_COMMAND_TYPE_PLAY, android.media.tv.interactive.TvInteractiveAppService#TIME_SHIFT_COMMAND_TYPE_PAUSE, android.media.tv.interactive.TvInteractiveAppService#TIME_SHIFT_COMMAND_TYPE_RESUME, android.media.tv.interactive.TvInteractiveAppService#TIME_SHIFT_COMMAND_TYPE_SEEK_TO, android.media.tv.interactive.TvInteractiveAppService#TIME_SHIFT_COMMAND_TYPE_SET_PLAYBACK_PARAMS, or android.media.tv.interactive.TvInteractiveAppService#TIME_SHIFT_COMMAND_TYPE_SET_MODE This value cannot be null.
parameters Bundle?: parameters of the specific command This value may be null.

setMediaViewEnabled

Added in API level 33
open fun setMediaViewEnabled(enable: Boolean): Unit

Enables or disables the media view.

By default, the media view is disabled. Must be called explicitly after the session is created to enable the media view.

The TV Interactive App service can disable its media view when needed.
If you override this method you must call through to the superclass implementation.

Parameters
enable Boolean: true if you want to enable the media view. false otherwise.

setTvRecordingInfo

Added in API level 34
open fun setTvRecordingInfo(
    recordingId: String,
    recordingInfo: TvRecordingInfo
): Unit

Sets the recording info for the specified recording
If you override this method you must call through to the superclass implementation.

Parameters
recordingId String: The ID of the recording to set the info for. This is provided by the TV app in TvInteractiveAppView.notifyRecordingStarted(String, String) This value cannot be null.
recordingInfo TvRecordingInfo: The TvRecordingInfo to set to the recording. This value cannot be null.

setVideoBounds

Added in API level 33
open fun setVideoBounds(rect: Rect): Unit

Sets broadcast video bounds.
If you override this method you must call through to the superclass implementation.

Parameters
rect Rect: This value cannot be null.