TvInputService

public abstract class TvInputService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.media.tv.TvInputService


The TvInputService class represents a TV input or source such as HDMI or built-in tuner which provides pass-through video or broadcast TV programs.

Applications will not normally use this service themselves, instead relying on the standard interaction provided by TvView. Those implementing TV input services should normally do so by deriving from this class and providing their own session implementation based on TvInputService.Session. All TV input services must require that clients hold the Manifest.permission.BIND_TV_INPUT in order to interact with the service; if this permission is not specified in the manifest, the system will refuse to bind to that TV input service.

Summary

Nested classes

class TvInputService.HardwareSession

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

class TvInputService.RecordingSession

Base class for derived classes to implement to provide a TV input recording session. 

class TvInputService.Session

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

Constants

int PRIORITY_HINT_USE_CASE_TYPE_BACKGROUND

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Background.

int PRIORITY_HINT_USE_CASE_TYPE_LIVE

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Live.

int PRIORITY_HINT_USE_CASE_TYPE_PLAYBACK

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Playback.

int PRIORITY_HINT_USE_CASE_TYPE_RECORD

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Record.

int PRIORITY_HINT_USE_CASE_TYPE_SCAN

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Scan.

String SERVICE_INTERFACE

This is the interface name that a service implementing a TV input should say that it support -- that is, this is the action it uses for its intent filter.

String SERVICE_META_DATA

Name under which a TvInputService component publishes information about itself.

Inherited constants

Public constructors

TvInputService()

Public methods

final IBinder onBind(Intent intent)

Return the communication channel to the service.

TvInputService.RecordingSession onCreateRecordingSession(String inputId, String sessionId)

Returns a concrete implementation of RecordingSession.

TvInputService.RecordingSession onCreateRecordingSession(String inputId)

Returns a concrete implementation of RecordingSession.

TvInputService.Session onCreateSession(String inputId, String sessionId, AttributionSource tvAppAttributionSource)

Returns a concrete implementation of Session.

abstract TvInputService.Session onCreateSession(String inputId)

Returns a concrete implementation of Session.

TvInputService.Session onCreateSession(String inputId, String sessionId)

Returns a concrete implementation of Session.

Inherited methods

Constants

PRIORITY_HINT_USE_CASE_TYPE_BACKGROUND

Added in API level 30
public static final int PRIORITY_HINT_USE_CASE_TYPE_BACKGROUND

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Background. TODO Link: Tuner#Tuner(Context, string, int).

Constant Value: 100 (0x00000064)

PRIORITY_HINT_USE_CASE_TYPE_LIVE

Added in API level 30
public static final int PRIORITY_HINT_USE_CASE_TYPE_LIVE

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Live. TODO Link: Tuner#Tuner(Context, string, int).

Constant Value: 400 (0x00000190)

PRIORITY_HINT_USE_CASE_TYPE_PLAYBACK

Added in API level 30
public static final int PRIORITY_HINT_USE_CASE_TYPE_PLAYBACK

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Playback. TODO Link: Tuner#Tuner(Context, string, int).

Constant Value: 300 (0x0000012c)

PRIORITY_HINT_USE_CASE_TYPE_RECORD

Added in API level 30
public static final int PRIORITY_HINT_USE_CASE_TYPE_RECORD

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Record. TODO Link: Tuner#Tuner(Context, string, int).

Constant Value: 500 (0x000001f4)

PRIORITY_HINT_USE_CASE_TYPE_SCAN

Added in API level 30
public static final int PRIORITY_HINT_USE_CASE_TYPE_SCAN

Use case of priority hint for MediaCas.MediaCas(Context, int, String, int): Scan. TODO Link: Tuner#Tuner(Context, string, int).

Constant Value: 200 (0x000000c8)

SERVICE_INTERFACE

Added in API level 21
public static final String SERVICE_INTERFACE

This is the interface name that a service implementing a TV input should say that it support -- that is, this is the action it uses for its intent filter. To be supported, the service must also require the Manifest.permission.BIND_TV_INPUT permission so that other applications cannot abuse it.

Constant Value: "android.media.tv.TvInputService"

SERVICE_META_DATA

Added in API level 21
public static final String SERVICE_META_DATA

Name under which a TvInputService component publishes information about itself. This meta-data must reference an XML resource containing an <tv-input> tag.

Constant Value: "android.media.tv.input"

Public constructors

TvInputService

public TvInputService ()

Public methods

onBind

Added in API level 21
public final IBinder onBind (Intent intent)

Return the communication channel to the service. May return null if clients can not bind to the service. The returned IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.

Returns
IBinder Return an IBinder through which clients can call on to the service.

onCreateRecordingSession

Added in API level 30
public TvInputService.RecordingSession onCreateRecordingSession (String inputId, 
                String sessionId)

Returns a concrete implementation of RecordingSession.

For any apps that needs sessionId to request tuner resources from TunerResourceManager, it needs to override this method to get the sessionId passed. When no overriding, this method calls onCreateRecordingSession(java.lang.String) defaultly.

Parameters
inputId String: The ID of the TV input associated with the recording session. This value cannot be null.

sessionId String: the unique sessionId created by TIF when session is created. This value cannot be null.

Returns
TvInputService.RecordingSession This value may be null.

onCreateRecordingSession

Added in API level 24
public TvInputService.RecordingSession onCreateRecordingSession (String inputId)

Returns a concrete implementation of RecordingSession.

May return null if this TV input service fails to create a recording session for some reason.

Parameters
inputId String: The ID of the TV input associated with the recording session. This value cannot be null.

Returns
TvInputService.RecordingSession

onCreateSession

Added in API level 34
public TvInputService.Session onCreateSession (String inputId, 
                String sessionId, 
                AttributionSource tvAppAttributionSource)

Returns a concrete implementation of Session.

For any apps that needs sessionId to request tuner resources from TunerResourceManager and needs to specify custom AttributionSource to AudioTrack, it needs to override this method to get the sessionId and AttrubutionSource passed. When no overriding, this method calls onCreateSession(java.lang.String, java.lang.String) defaultly.

Parameters
inputId String: The ID of the TV input associated with the session. This value cannot be null.

sessionId String: the unique sessionId created by TIF when session is created. This value cannot be null.

tvAppAttributionSource AttributionSource: The Attribution Source of the TV App. This value cannot be null.

Returns
TvInputService.Session This value may be null.

onCreateSession

Added in API level 21
public abstract TvInputService.Session onCreateSession (String inputId)

Returns a concrete implementation of Session.

May return null if this TV input service fails to create a session for some reason. If TV input represents an external device connected to a hardware TV input, HardwareSession should be returned.

Parameters
inputId String: The ID of the TV input associated with the session. This value cannot be null.

Returns
TvInputService.Session

onCreateSession

Added in API level 30
public TvInputService.Session onCreateSession (String inputId, 
                String sessionId)

Returns a concrete implementation of Session.

For any apps that needs sessionId to request tuner resources from TunerResourceManager, it needs to override this method to get the sessionId passed. When no overriding, this method calls onCreateSession(java.lang.String) defaultly.

Parameters
inputId String: The ID of the TV input associated with the session. This value cannot be null.

sessionId String: the unique sessionId created by TIF when session is created. This value cannot be null.

Returns
TvInputService.Session This value may be null.