FileDocCategorySizeDatePackage
TvInputService.javaAPI DocAndroid 5.1 API63663Thu Mar 12 22:22:30 GMT 2015android.media.tv

TvInputService

public abstract class TvInputService extends android.app.Service
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 {@link TvView}. Those implementing TV input services should normally do so by deriving from this class and providing their own session implementation based on {@link TvInputService.Session}. All TV input services must require that clients hold the {@link android.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.

Fields Summary
private static final boolean
DEBUG
private static final String
TAG
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 {@link android.Manifest.permission#BIND_TV_INPUT} permission so that other applications cannot abuse it.
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 <{@link android.R.styleable#TvInputService tv-input}> tag.
private final android.os.Handler
mServiceHandler
Handler instance to handle request from TV Input Manager Service. Should be run in the main looper to be synchronously run with {@code Session.mHandler}.
private final android.os.RemoteCallbackList
mCallbacks
private TvInputManager
mTvInputManager
Constructors Summary
Methods Summary
public static booleanisNavigationKey(int keyCode)

hide

        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_DPAD_RIGHT:
            case KeyEvent.KEYCODE_DPAD_UP:
            case KeyEvent.KEYCODE_DPAD_DOWN:
            case KeyEvent.KEYCODE_DPAD_CENTER:
            case KeyEvent.KEYCODE_PAGE_UP:
            case KeyEvent.KEYCODE_PAGE_DOWN:
            case KeyEvent.KEYCODE_MOVE_HOME:
            case KeyEvent.KEYCODE_MOVE_END:
            case KeyEvent.KEYCODE_TAB:
            case KeyEvent.KEYCODE_SPACE:
            case KeyEvent.KEYCODE_ENTER:
                return true;
        }
        return false;
    
private booleanisPassthroughInput(java.lang.String inputId)

        if (mTvInputManager == null) {
            mTvInputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE);
        }
        TvInputInfo info = mTvInputManager.getTvInputInfo(inputId);
        if (info != null && info.isPassthroughInput()) {
            return true;
        }
        return false;
    
public final android.os.IBinderonBind(android.content.Intent intent)


    
         
        return new ITvInputService.Stub() {
            @Override
            public void registerCallback(ITvInputServiceCallback cb) {
                if (cb != null) {
                    mCallbacks.register(cb);
                }
            }

            @Override
            public void unregisterCallback(ITvInputServiceCallback cb) {
                if (cb != null) {
                    mCallbacks.unregister(cb);
                }
            }

            @Override
            public void createSession(InputChannel channel, ITvInputSessionCallback cb,
                    String inputId) {
                if (channel == null) {
                    Log.w(TAG, "Creating session without input channel");
                }
                if (cb == null) {
                    return;
                }
                SomeArgs args = SomeArgs.obtain();
                args.arg1 = channel;
                args.arg2 = cb;
                args.arg3 = inputId;
                mServiceHandler.obtainMessage(ServiceHandler.DO_CREATE_SESSION, args).sendToTarget();
            }

            @Override
            public void notifyHardwareAdded(TvInputHardwareInfo hardwareInfo) {
                mServiceHandler.obtainMessage(ServiceHandler.DO_ADD_HARDWARE_TV_INPUT,
                        hardwareInfo).sendToTarget();
            }

            @Override
            public void notifyHardwareRemoved(TvInputHardwareInfo hardwareInfo) {
                mServiceHandler.obtainMessage(ServiceHandler.DO_REMOVE_HARDWARE_TV_INPUT,
                        hardwareInfo).sendToTarget();
            }

            @Override
            public void notifyHdmiDeviceAdded(HdmiDeviceInfo deviceInfo) {
                mServiceHandler.obtainMessage(ServiceHandler.DO_ADD_HDMI_TV_INPUT,
                        deviceInfo).sendToTarget();
            }

            @Override
            public void notifyHdmiDeviceRemoved(HdmiDeviceInfo deviceInfo) {
                mServiceHandler.obtainMessage(ServiceHandler.DO_REMOVE_HDMI_TV_INPUT,
                        deviceInfo).sendToTarget();
            }
        };
    
public abstract android.media.tv.TvInputService$SessiononCreateSession(java.lang.String inputId)
Returns a concrete implementation of {@link Session}.

May return {@code 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, {@link HardwareSession} should be returned.

param
inputId The ID of the TV input associated with the session.

public TvInputInfoonHardwareAdded(TvInputHardwareInfo hardwareInfo)
Returns a new {@link TvInputInfo} object if this service is responsible for {@code hardwareInfo}; otherwise, return {@code null}. Override to modify default behavior of ignoring all hardware input.

param
hardwareInfo {@link TvInputHardwareInfo} object just added.
hide

        return null;
    
public java.lang.StringonHardwareRemoved(TvInputHardwareInfo hardwareInfo)
Returns the input ID for {@code deviceId} if it is handled by this service; otherwise, return {@code null}. Override to modify default behavior of ignoring all hardware input.

param
hardwareInfo {@link TvInputHardwareInfo} object just removed.
hide

        return null;
    
public TvInputInfoonHdmiDeviceAdded(android.hardware.hdmi.HdmiDeviceInfo deviceInfo)
Returns a new {@link TvInputInfo} object if this service is responsible for {@code deviceInfo}; otherwise, return {@code null}. Override to modify default behavior of ignoring all HDMI logical input device.

param
deviceInfo {@link HdmiDeviceInfo} object just added.
hide

        return null;
    
public java.lang.StringonHdmiDeviceRemoved(android.hardware.hdmi.HdmiDeviceInfo deviceInfo)
Returns the input ID for {@code deviceInfo} if it is handled by this service; otherwise, return {@code null}. Override to modify default behavior of ignoring all HDMI logical input device.

param
deviceInfo {@link HdmiDeviceInfo} object just removed.
hide

        return null;