Example usage for android.media.tv TvInputInfo TYPE_TUNER

List of usage examples for android.media.tv TvInputInfo TYPE_TUNER

Introduction

In this page you can find the example usage for android.media.tv TvInputInfo TYPE_TUNER.

Prototype

int TYPE_TUNER

To view the source code for android.media.tv TvInputInfo TYPE_TUNER.

Click Source Link

Document

TV input type: the TV input service is a tuner which provides channels.

Usage

From source file:com.android.tv.TvApplication.java

/**
 * Checks the input counts and enable/disable TvActivity. Also updates the input list in
 * {@link SetupUtils}./*w  w w . j  av  a  2s .c o  m*/
 *
 * @param calledByTunerServiceChanged true if it is called when UsbTunerTvInputService
 *        is enabled or disabled.
 * @param tunerServiceEnabled it's available only when calledByTunerServiceChanged is true.
 * @param dontKillApp when TvActivity is enabled or disabled by this method, the app restarts
 *        by default. But, if dontKillApp is true, the app won't restart.
 */
public void handleInputCountChanged(boolean calledByTunerServiceChanged, boolean tunerServiceEnabled,
        boolean dontKillApp) {
    TvInputManager inputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE);
    boolean enable = (calledByTunerServiceChanged && tunerServiceEnabled)
            || Features.UNHIDE.isEnabled(TvApplication.this);
    if (!enable) {
        List<TvInputInfo> inputs = inputManager.getTvInputList();
        boolean skipTunerInputCheck = false;
        // Enable the TvActivity only if there is at least one tuner type input.
        if (!skipTunerInputCheck) {
            for (TvInputInfo input : inputs) {
                if (calledByTunerServiceChanged && !tunerServiceEnabled
                        && UsbTunerTvInputService.getInputId(this).equals(input.getId())) {
                    continue;
                }
                if (input.getType() == TvInputInfo.TYPE_TUNER) {
                    enable = true;
                    break;
                }
            }
        }
        if (DEBUG)
            Log.d(TAG, "Enable MainActivity: " + enable);
    }
    PackageManager packageManager = getPackageManager();
    ComponentName name = new ComponentName(this, TvActivity.class);
    int newState = enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
            : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
    if (packageManager.getComponentEnabledSetting(name) != newState) {
        packageManager.setComponentEnabledSetting(name, newState,
                dontKillApp ? PackageManager.DONT_KILL_APP : 0);
    }
    SetupUtils.getInstance(TvApplication.this).onInputListUpdated(inputManager);
}