FileDocCategorySizeDatePackage
OneTouchRecordAction.javaAPI DocAndroid 5.1 API4986Thu Mar 12 22:22:42 GMT 2015com.android.server.hdmi

OneTouchRecordAction

public class OneTouchRecordAction extends HdmiCecFeatureAction
Feature action that performs one touch record.

Fields Summary
private static final String
TAG
private static final int
RECORD_STATUS_TIMEOUT_MS
private static final int
STATE_WAITING_FOR_RECORD_STATUS
private static final int
STATE_RECORDING_IN_PROGRESS
private final int
mRecorderAddress
private final byte[]
mRecordSource
Constructors Summary
OneTouchRecordAction(HdmiCecLocalDevice source, int recorderAddress, byte[] recordSource)


          
        super(source);
        mRecorderAddress = recorderAddress;
        mRecordSource = recordSource;
    
Methods Summary
intgetRecorderAddress()

        return mRecorderAddress;
    
private booleanhandleRecordStatus(HdmiCecMessage cmd)

        // Only handle message coming from original recorder.
        if (cmd.getSource() != mRecorderAddress) {
            return false;
        }

        int recordStatus = cmd.getParams()[0];
        tv().announceOneTouchRecordResult(mRecorderAddress, recordStatus);
        Slog.i(TAG, "Got record status:" + recordStatus + " from " + cmd.getSource());

        // If recording started successfully, change state and keep this action until <Record Off>
        // received. Otherwise, finish action.
        switch (recordStatus) {
            case ONE_TOUCH_RECORD_RECORDING_CURRENTLY_SELECTED_SOURCE:
            case ONE_TOUCH_RECORD_RECORDING_DIGITAL_SERVICE:
            case ONE_TOUCH_RECORD_RECORDING_ANALOGUE_SERVICE:
            case ONE_TOUCH_RECORD_RECORDING_EXTERNAL_INPUT:
                mState = STATE_RECORDING_IN_PROGRESS;
                mActionTimer.clearTimerMessage();
                break;
            default:
                finish();
                break;
        }
        return true;
    
voidhandleTimerEvent(int state)

        if (mState != state) {
            Slog.w(TAG, "Timeout in invalid state:[Expected:" + mState + ", Actual:" + state + "]");
            return;
        }

        tv().announceOneTouchRecordResult(mRecorderAddress,
                ONE_TOUCH_RECORD_CHECK_RECORDER_CONNECTION);
        finish();
    
booleanprocessCommand(HdmiCecMessage cmd)

        if (mState != STATE_WAITING_FOR_RECORD_STATUS || mRecorderAddress != cmd.getSource()) {
            return false;
        }

        switch (cmd.getOpcode()) {
            case Constants.MESSAGE_RECORD_STATUS:
                return handleRecordStatus(cmd);
        }
        return false;
    
private voidsendRecordOn()

        sendCommand(HdmiCecMessageBuilder.buildRecordOn(getSourceAddress(), mRecorderAddress,
                mRecordSource),
                new SendMessageCallback() {
                @Override
                    public void onSendCompleted(int error) {
                        // if failed to send <Record On>, display error message and finish action.
                        if (error != Constants.SEND_RESULT_SUCCESS) {
                            tv().announceOneTouchRecordResult(
                                    mRecorderAddress,
                                    ONE_TOUCH_RECORD_CHECK_RECORDER_CONNECTION);
                            finish();
                            return;
                        }
                    }
                });
        mState = STATE_WAITING_FOR_RECORD_STATUS;
        addTimer(mState, RECORD_STATUS_TIMEOUT_MS);
    
booleanstart()

        sendRecordOn();
        return true;