Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

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(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 TvInputService.Session.onTune(Uri) 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

TvInputService.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 TvInputService.HardwareSession.

Inherited methods

Public constructors

TvInputService.HardwareSession

added in API level 21
public TvInputService.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).

Parameters
reason int: The reason that the hardware TV input stopped the playback:

onSetSurface

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

This method will not be called in TvInputService.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.