# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# 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.

See also:

- `TvInputService.onCreateSession(String)`

## 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
From class `android.media.tv.TvInputService.Session`
`void` | `layoutSurface(int left, int top, int right, int bottom)` Assigns a size and position to the surface passed in `onSetSurface(Surface)`.
`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` | `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` | `notifyVideoAvailable()` Informs the application that the video is now available for watching.
`void` | `notifyVideoUnavailable(int reason)` Informs the application that the video became unavailable for some reason.
`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.
`boolean` | `onSelectTrack(int type, String trackId)` Selects a given track.
`abstract void` | `onSetCaptionEnabled(boolean enabled)` Enables or disables the caption.
`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` | `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` | `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` | `onUnblockContent(TvContentRating unblockedRating)` Requests to unblock the content according to the given rating.
`void` | `setOverlayViewEnabled(boolean enable)` Enables or disables the overlay view.
From class `java.lang.Object`
`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 timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `android.view.KeyEvent.Callback`
`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

    public HardwareSession (Context context)

Creates a new HardwareSession.

Parameters
`context` | `Context`: The context of the application

## Public methods

### getHardwareInputId

    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

    public void onHardwareVideoAvailable ()

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

### onHardwareVideoUnavailable

    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: `TvInputManager#VIDEO_UNAVAILABLE_REASON_UNKNOWN` `TvInputManager#VIDEO_UNAVAILABLE_REASON_TUNING` `TvInputManager#VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL` `TvInputManager#VIDEO_UNAVAILABLE_REASON_BUFFERING` `TvInputManager#VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY`

### onSetSurface

    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`. This value may be `null`.

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

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*