Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6591b8e authored by Jungshik Jang's avatar Jungshik Jang
Browse files

Implement OneTouchRecordAction and stop one touch record.

In addition to it, add api for clearTimerRecording as well.
Separately, I will replace logic for notifying message with callback
interface.

Bug: 16160962

Change-Id: I2368f7c697eb44ed4542c0ec4412c63a6ae41a5c
parent 35efc633
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
@@ -69,6 +69,76 @@ public final class HdmiControlManager {
    public static final int RESULT_INCORRECT_MODE = 6;
    public static final int RESULT_COMMUNICATION_FAILED = 7;

    // -- Message ids for display osd.

    /** Place holder for recording status message. Indicates the status of a recording. */
    public static final int MESSAGE_RECORDING_STATUS_MESSAGE_START = 0x100;
    /** Recording currently selected source. Indicates the status of a recording. */
    public static final int MESSAGE_RECORDING_CURRENTLY_SELECTED_SOURCE = 0x101;
    /** Recording Digital Service. Indicates the status of a recording. */
    public static final int MESSAGE_RECORDING_DIGITAL_SERVICE = 0x102;
    /** Recording Analogue Service. Indicates the status of a recording. */
    public static final int MESSAGE_RECORDING_ANALOGUE_SERVICE = 0x103;
    /** Recording External input. Indicates the status of a recording. */
    public static final int MESSAGE_RECORDING_EXTERNAL_INPUT = 0x104;
    /** No recording – unable to record Digital Service. No suitable tuner. */
    public static final int MESSAGE_NO_RECORDNIG_UNABLE_DIGITAL_SERVICE = 0x105;
    /** No recording – unable to record Analogue Service. No suitable tuner. */
    public static final int MESSAGE_NO_RECORDNIG_UNABLE_ANALOGUE_SERVICE = 0x106;
    /**
     * No recording – unable to select required service. as suitable tuner, but the requested
     * parameters are invalid or out of range for that tuner.
     */
    public static final int MESSAGE_NO_RECORDNIG_UNABLE_SELECTED_SERVICE = 0x107;
    /** No recording – invalid External plug number */
    public static final int MESSAGE_NO_RECORDNIG_INVALID_EXTERNAL_PLUG_NUMBER = 0x109;
    /** No recording – invalid External Physical Address */
    public static final int MESSAGE_NO_RECORDNIG_INVALID_EXTERNAL_PHYSICAL_ADDRESS = 0x10A;
    /** No recording – CA system not supported */
    public static final int MESSAGE_NO_RECORDNIG_UNSUPPORTED_CA = 0x10B;
    /** No Recording – No or Insufficient CA Entitlements” */
    public static final int MESSAGE_NO_RECORDNIG_NO_OR_INSUFFICIENT_CA_ENTITLEMENTS = 0x10C;
    /** No recording – Not allowed to copy source. Source is “copy never”. */
    public static final int MESSAGE_NO_RECORDNIG_DISALLOW_TO_COPY = 0x10D;
    /** No recording – No further copies allowed */
    public static final int MESSAGE_NO_RECORDNIG_DISALLOW_TO_FUTHER_COPIES = 0x10E;
    /** No recording – No media */
    public static final int MESSAGE_NO_RECORDNIG_NO_MEDIA = 0x110;
    /** No recording – playing */
    public static final int MESSAGE_NO_RECORDNIG_PLAYING = 0x111;
    /** No recording – already recording */
    public static final int MESSAGE_NO_RECORDNIG_ALREADY_RECORDING = 0x112;
    /** No recording – media protected */
    public static final int MESSAGE_NO_RECORDNIG_MEDIA_PROTECTED = 0x113;
    /** No recording – no source signal */
    public static final int MESSAGE_NO_RECORDNIG_NO_SOURCE_SIGNAL = 0x114;
    /** No recording – media problem */
    public static final int MESSAGE_NO_RECORDNIG_MEDIA_PROBLEM = 0x115;
    /** No recording – not enough space available */
    public static final int MESSAGE_NO_RECORDNIG_NOT_ENOUGH_SPACE = 0x116;
    /** No recording – Parental Lock On */
    public static final int MESSAGE_NO_RECORDNIG_PARENT_LOCK_ON = 0x117;
    /** Recording terminated normally */
    public static final int MESSAGE_RECORDING_TERMINATED_NORMALLY = 0x11A;
    /** Recording has already terminated */
    public static final int MESSAGE_RECORDING_ALREADY_TERMINATED = 0x11B;
    /** No recording – other reason */
    public static final int MESSAGE_NO_RECORDNIG_OTHER_REASON = 0x11F;
    // From here extra message for recording that is not mentioned in CEC spec
    /** No recording. Previous recording request in progress. */
    public static final int MESSAGE_NO_RECORDING_PREVIOUS_RECORDING_IN_PROGRESS = 0x130;
    /** No recording. Please check recorder and connection. */
    public static final int MESSAGE_NO_RECORDING_CHECK_RECORDER_CONNECTION = 0x131;
    /** Cannot record currently displayed source. */
    public static final int MESSAGE_NO_RECORDING_FAIL_TO_RECORD_DISPLAYED_SCREEN = 0x132;

    /** Timer recording type for digital service source. */
    public static final int TIMER_RECORDING_TYPE_DIGITAL = 1;
    /** Timer recording type for analogue service source. */
    public static final int TIMER_RECORDING_TYPE_ANALOGUE = 2;
    /** Timer recording type for external source. */
    public static final int TIMER_RECORDING_TYPE_EXTERNAL = 3;

    // True if we have a logical device of type playback hosted in the system.
    private final boolean mHasPlaybackDevice;
    // True if we have a logical device of type TV hosted in the system.
+27 −2
Original line number Diff line number Diff line
@@ -103,8 +103,10 @@ public final class HdmiRecordSources {
     */
    @SystemApi
    public static final class OwnSource extends RecordSource {
        protected OwnSource() {
            super(RECORD_SOURCE_TYPE_OWN_SOURCE, 0);
        private static final int EXTRA_DATA_SIZE = 0;

        private OwnSource() {
            super(RECORD_SOURCE_TYPE_OWN_SOURCE, EXTRA_DATA_SIZE);
        }

        @Override
@@ -744,4 +746,27 @@ public final class HdmiRecordSources {
        byteArray[index + 1] = (byte) (value & 0xFF);
        return 2;
    }

    /**
     * Check the byte array of record source.
     * @hide
     */
    public static boolean checkRecordSource(byte[] recordSource) {
        int recordSourceType = recordSource[0];
        int extraDataSize = recordSource.length - 1;
        switch (recordSourceType) {
            case RECORD_SOURCE_TYPE_OWN_SOURCE:
                return extraDataSize == OwnSource.EXTRA_DATA_SIZE;
            case RECORD_SOURCE_TYPE_DIGITAL_SERVICE:
                return extraDataSize == DigitalServiceSource.EXTRA_DATA_SIZE;
            case RECORD_SOURCE_TYPE_ANALOGUE_SERVICE:
                return extraDataSize == AnalogueServiceSource.EXTRA_DATA_SIZE;
            case RECORD_SOURCE_TYPE_EXTERNAL_PLUG:
                return extraDataSize == ExternalPlugData.EXTRA_DATA_SIZE;
            case RECORD_SOURCE_TYPE_EXTERNAL_PHYSICAL_ADDRESS:
                return extraDataSize == ExternalPhysicalAddress.EXTRA_DATA_SIZE;
            default:
                return false;
        }
    }
}
+55 −5
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@
 */
package android.hardware.hdmi;

import static android.hardware.hdmi.HdmiRecordSources.RecordSource;
import static android.hardware.hdmi.HdmiTimerRecordSources.TimerRecordSource;

import android.annotation.SystemApi;
import android.os.RemoteException;
import android.util.Log;
@@ -162,7 +165,7 @@ public final class HdmiTvClient extends HdmiClient {
         *
         * @return {@link HdmiRecordSources} to be used to set recording info
         */
        HdmiRecordSources.RecordSource onRecordRequestReceived(int recorderAddress);
        RecordSource onRecordRequestReceived(int recorderAddress);
    }

    /**
@@ -187,7 +190,7 @@ public final class HdmiTvClient extends HdmiClient {
     * tvClient.startOneTouchRecord(recorderAddress, ownSource);
     * </pre>
     */
    public void startOneTouchRecord(int recorderAddress, HdmiRecordSources.RecordSource source) {
    public void startOneTouchRecord(int recorderAddress, RecordSource source) {
        try {
            byte[] data = new byte[source.getDataSize(true)];
            source.toByteArray(true, data, 0);
@@ -197,6 +200,19 @@ public final class HdmiTvClient extends HdmiClient {
        }
    }

    /**
     * Stop one touch record.
     *
     * @param recorderAddress recorder address where recoding will be stopped
     */
    public void stopOneTouchRecord(int recorderAddress) {
        try {
            mService.stopOneTouchRecord(recorderAddress);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to stop record: ", e);
        }
    }

    /**
     * Start timer recording with the given recoder address and recorder source.
     * <p>
@@ -211,13 +227,47 @@ public final class HdmiTvClient extends HdmiClient {
     * TimerRecordSource source = HdmiTimerRecourdSources.ofDigitalSource(timerInfo, recordSource);
     * tvClient.startTimerRecording(recorderAddress, source);
     * </pre>
     *
     * @param recorderAddress target recorder address
     * @param sourceType type of record source. It should be one of
     *          {@link HdmiControlManager#TIMER_RECORDING_TYPE_DIGITAL},
     *          {@link HdmiControlManager#TIMER_RECORDING_TYPE_ANALOGUE},
     *          {@link HdmiControlManager#TIMER_RECORDING_TYPE_EXTERNAL}.
     * @param source record source to be used
     */
    public void startTimerRecording(int recorderAddress, int sourceType, TimerRecordSource source) {
        checkTimerRecordingSourceType(sourceType);

        try {
            byte[] data = new byte[source.getDataSize()];
            source.toByteArray(data, 0);
            mService.startTimerRecording(recorderAddress, sourceType, data);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to start record: ", e);
        }
    }

    private void checkTimerRecordingSourceType(int sourceType) {
        switch (sourceType) {
            case HdmiControlManager.TIMER_RECORDING_TYPE_DIGITAL:
            case HdmiControlManager.TIMER_RECORDING_TYPE_ANALOGUE:
            case HdmiControlManager.TIMER_RECORDING_TYPE_EXTERNAL:
                break;
            default:
                throw new IllegalArgumentException("Invalid source type:" + sourceType);
        }
    }

    /**
     * Clear timer recording with the given recorder address and recording source.
     * For more details, please refer {@link #startTimerRecording(int, int, TimerRecordSource)}.
     */
    public void startTimerRecording(int recorderAddress,
            HdmiTimerRecordSources.TimerRecordSource source) {
    public void clearTimerRecording(int recorderAddress, int sourceType, TimerRecordSource source) {
        checkTimerRecordingSourceType(sourceType);
        try {
            byte[] data = new byte[source.getDataSize()];
            source.toByteArray(data, 0);
            mService.startTimerRecording(recorderAddress, data);
            mService.clearTimerRecording(recorderAddress, sourceType, data);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to start record: ", e);
        }
+3 −1
Original line number Diff line number Diff line
@@ -64,5 +64,7 @@ interface IHdmiControlService {
    void addVendorCommandListener(IHdmiVendorCommandListener listener, int deviceType);
    void setOneTouchRecordRequestListener(IHdmiRecordRequestListener listener);
    void startOneTouchRecord(int recorderAddress, in byte[] recordSource);
    void startTimerRecording(int recorderAddress, in byte[] recordSource);
    void stopOneTouchRecord(int recorderAddress);
    void startTimerRecording(int recorderAddress, int sourceType, in byte[] recordSource);
    void clearTimerRecording(int recorderAddress, int sourceType, in byte[] recordSource);
}
+9 −0
Original line number Diff line number Diff line
@@ -200,6 +200,8 @@ abstract class HdmiCecLocalDevice {
                return handleVendorCommandWithId(message);
            case Constants.MESSAGE_SET_OSD_NAME:
                return handleSetOsdName(message);
            case Constants.MESSAGE_RECORD_TV_SCREEN:
                return handleRecordTvScreen(message);
            default:
                return false;
        }
@@ -403,6 +405,13 @@ abstract class HdmiCecLocalDevice {
        return true;
    }

    protected boolean handleRecordTvScreen(HdmiCecMessage message) {
        // The default behavior of <Record TV Screen> is replying <Feature Abort> with "Refused".
        mService.sendCecCommand(HdmiCecMessageBuilder.buildFeatureAbortCommand(mAddress,
                message.getSource(), message.getOpcode(), Constants.ABORT_REFUSED));
        return true;
    }

    @ServiceThreadOnly
    final void handleAddressAllocated(int logicalAddress, boolean fromBootup) {
        assertRunOnServiceThread();
Loading