Example usage for android.media.tv TvInputInfo equals

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

Introduction

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

Prototype

@Override
    public boolean equals(Object o) 

Source Link

Usage

From source file:com.android.tv.ui.TunableTvView.java

/**
 * Plays a recording.//  w  w  w  .  j a  va2  s . com
 */
public boolean playRecording(Uri recordingUri, OnTuneListener listener) {
    if (!mStarted) {
        throw new IllegalStateException("TvView isn't started");
    }
    if (!CommonFeatures.DVR.isEnabled(getContext()) || !BuildCompat.isAtLeastN()) {
        return false;
    }
    if (DEBUG)
        Log.d(TAG, "playRecording " + recordingUri);
    long recordingId = ContentUris.parseId(recordingUri);
    mRecordedProgram = mDvrDataManager.getRecordedProgram(recordingId);
    if (mRecordedProgram == null) {
        Log.w(TAG, "No recorded program (Uri=" + recordingUri + ")");
        return false;
    }
    String inputId = mRecordedProgram.getInputId();
    TvInputInfo inputInfo = mInputManagerHelper.getTvInputInfo(inputId);
    if (inputInfo == null) {
        return false;
    }
    mOnTuneListener = listener;
    // mCurrentChannel can be null.
    mCurrentChannel = mChannelDataManager.getChannel(mRecordedProgram.getChannelId());
    // For recording playback, input event should not be sent.
    mCanReceiveInputEvent = false;
    boolean needSurfaceSizeUpdate = false;
    if (!inputInfo.equals(mInputInfo)) {
        mInputInfo = inputInfo;
        if (DEBUG) {
            Log.d(TAG,
                    "Input \'" + mInputInfo.getId() + "\' can receive input event: " + mCanReceiveInputEvent);
        }
        needSurfaceSizeUpdate = true;
    }
    mChannelViewTimer.start();
    mVideoWidth = 0;
    mVideoHeight = 0;
    mVideoFormat = StreamInfo.VIDEO_DEFINITION_LEVEL_UNKNOWN;
    mVideoFrameRate = 0f;
    mVideoDisplayAspectRatio = 0f;
    mAudioChannelCount = StreamInfo.AUDIO_CHANNEL_COUNT_UNKNOWN;
    mHasClosedCaption = false;
    mTvView.setCallback(mCallback);
    mTimeShiftCurrentPositionMs = INVALID_TIME;
    mTvView.setTimeShiftPositionCallback(null);
    setTimeShiftAvailable(false);
    mTvView.timeShiftPlay(inputId, recordingUri);
    if (needSurfaceSizeUpdate && mFixedSurfaceWidth > 0 && mFixedSurfaceHeight > 0) {
        // When the input is changed, TvView recreates its SurfaceView internally.
        // So we need to call SurfaceHolder.setFixedSize for the new SurfaceView.
        getSurfaceView().getHolder().setFixedSize(mFixedSurfaceWidth, mFixedSurfaceHeight);
    }
    hideScreenByVideoAvailability(TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING);
    unblockScreenByContentRating();
    if (mParentControlEnabled) {
        mBlockScreenForTuneView.setVisibility(View.VISIBLE);
    }
    if (mOnTuneListener != null) {
        mOnTuneListener.onStreamInfoChanged(this);
    }
    return true;
}

From source file:com.android.tv.ui.TunableTvView.java

/**
 * Tunes to a channel with the {@code channelId}.
 *
 * @param params extra data to send it to TIS and store the data in TIMS.
 * @return false, if the TV input is not a proper state to tune to a channel. For example,
 *         if the state is disconnected or channelId doesn't exist, it returns false.
 *//* w  ww .j  ava2s  . co m*/
public boolean tuneTo(Channel channel, Bundle params, OnTuneListener listener) {
    if (!mStarted) {
        throw new IllegalStateException("TvView isn't started");
    }
    if (DEBUG)
        Log.d(TAG, "tuneTo " + channel);
    TvInputInfo inputInfo = mInputManagerHelper.getTvInputInfo(channel.getInputId());
    if (inputInfo == null) {
        return false;
    }
    if (mCurrentChannel != null) {
        long duration = mChannelViewTimer.reset();
        mTracker.sendChannelViewStop(mCurrentChannel, duration);
        if (mWatchedHistoryManager != null && !mCurrentChannel.isPassthrough()) {
            mWatchedHistoryManager.logChannelViewStop(mCurrentChannel, System.currentTimeMillis(), duration);
        }
    }
    mOnTuneListener = listener;
    mCurrentChannel = channel;
    mRecordedProgram = null;
    boolean tunedByRecommendation = params != null
            && params.getString(NotificationService.TUNE_PARAMS_RECOMMENDATION_TYPE) != null;
    boolean needSurfaceSizeUpdate = false;
    if (!inputInfo.equals(mInputInfo)) {
        mInputInfo = inputInfo;
        mCanReceiveInputEvent = getContext().getPackageManager().checkPermission(PERMISSION_RECEIVE_INPUT_EVENT,
                mInputInfo.getServiceInfo().packageName) == PackageManager.PERMISSION_GRANTED;
        if (DEBUG) {
            Log.d(TAG,
                    "Input \'" + mInputInfo.getId() + "\' can receive input event: " + mCanReceiveInputEvent);
        }
        needSurfaceSizeUpdate = true;
    }
    mTracker.sendChannelViewStart(mCurrentChannel, tunedByRecommendation);
    mChannelViewTimer.start();
    mVideoWidth = 0;
    mVideoHeight = 0;
    mVideoFormat = StreamInfo.VIDEO_DEFINITION_LEVEL_UNKNOWN;
    mVideoFrameRate = 0f;
    mVideoDisplayAspectRatio = 0f;
    mAudioChannelCount = StreamInfo.AUDIO_CHANNEL_COUNT_UNKNOWN;
    mHasClosedCaption = false;
    mTvView.setCallback(mCallback);
    mTimeShiftCurrentPositionMs = INVALID_TIME;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        // To reduce the IPCs, unregister the callback here and register it when necessary.
        mTvView.setTimeShiftPositionCallback(null);
    }
    setTimeShiftAvailable(false);
    mTvView.tune(mInputInfo.getId(), mCurrentChannel.getUri(), params);
    if (needSurfaceSizeUpdate && mFixedSurfaceWidth > 0 && mFixedSurfaceHeight > 0) {
        // When the input is changed, TvView recreates its SurfaceView internally.
        // So we need to call SurfaceHolder.setFixedSize for the new SurfaceView.
        getSurfaceView().getHolder().setFixedSize(mFixedSurfaceWidth, mFixedSurfaceHeight);
    }
    hideScreenByVideoAvailability(TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING);
    unblockScreenByContentRating();
    if (channel.isPassthrough()) {
        mBlockScreenForTuneView.setVisibility(View.GONE);
    } else if (mParentControlEnabled) {
        mBlockScreenForTuneView.setVisibility(View.VISIBLE);
    }
    if (mOnTuneListener != null) {
        mOnTuneListener.onStreamInfoChanged(this);
    }
    return true;
}