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

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

Add two apis for one touch record.

This change introduces new two apis for one touch record.
1. setRecordRequestListener
 It's used to get notified when a recorder device initiates
 "one touch record". As return of callback, client should
 generate "record source" and return it.
2. startRecord
 It's used to initiate "one touch record" from Tv.

Along with this, add HdmiRecordSources which is a helper
class assisting buidling byte array form from the given
record source information.

Bug: 16160962

Change-Id: I403d37b752c9b7f799c6d8188a071ef420fe8ac2
parent f2951104
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ LOCAL_SRC_FILES += \
	core/java/android/hardware/hdmi/IHdmiDeviceEventListener.aidl \
	core/java/android/hardware/hdmi/IHdmiHotplugEventListener.aidl \
	core/java/android/hardware/hdmi/IHdmiInputChangeListener.aidl \
	core/java/android/hardware/hdmi/IHdmiRecordRequestListener.aidl \
	core/java/android/hardware/hdmi/IHdmiSystemAudioModeChangeListener.aidl \
	core/java/android/hardware/hdmi/IHdmiVendorCommandListener.aidl \
	core/java/android/hardware/input/IInputManager.aidl \
+743 −0

File added.

Preview size limit exceeded, changes collapsed.

+65 −2
Original line number Diff line number Diff line
@@ -16,11 +16,11 @@
package android.hardware.hdmi;

import android.annotation.SystemApi;
import android.hardware.hdmi.HdmiControlManager.VendorCommandListener;
import android.hardware.hdmi.IHdmiVendorCommandListener;
import android.os.RemoteException;
import android.util.Log;

import libcore.util.EmptyArray;

/**
 * HdmiTvClient represents HDMI-CEC logical device of type TV in the Android system
 * which acts as TV/Display. It provides with methods that manage, interact with other
@@ -91,6 +91,7 @@ public final class HdmiTvClient extends HdmiClient {
        return new HdmiTvClient(service);
    }

    @Override
    public int getDeviceType() {
        return HdmiCecDeviceInfo.DEVICE_TV;
    }
@@ -150,6 +151,51 @@ public final class HdmiTvClient extends HdmiClient {
        }
    }

    /**
     * Callback interface to used to get notified when a record request from recorder device.
     */
    public interface RecordRequestListener {
        /**
         * Called when tv receives request request from recorder device. When it's called,
         * it should return record source in byte array so that hdmi control service
         * can start recording with the given source info.
         *
         * @return {@link HdmiRecordSources} to be used to set recording info
         */
        HdmiRecordSources.RecordSource onRecordRequestReceived(int recorderAddress);
    }

    /**
     * Set {@link RecordRequestListener} to hdmi control service.
     */
    public void setRecordRequestListener(RecordRequestListener listener) {
        try {
            mService.setRecordRequestListener(getCallbackWrapper(listener));
        } catch (RemoteException e) {
            Log.e(TAG, "failed to set record request listener: ", e);
        }
    }

    /**
     * Start recording with the given recorder address and recorder source.
     * <p>Usage
     * <pre>
     * HdmiTvClient tvClient = ....;
     * // for own source.
     * OwnSource ownSource = ownHdmiRecordSources.ownSource();
     * tvClient.startRecord(recorderAddress, ownSource);
     * </pre>
     */
    public void startRecord(int recorderAddress, HdmiRecordSources.RecordSource source) {
        try {
            byte[] data = new byte[source.getDataSize(true)];
            source.toByteArray(true, data, 0);
            mService.startRecord(recorderAddress, data);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to start record: ", e);
        }
    }

    private static IHdmiControlCallback getCallbackWrapper(final SelectCallback callback) {
        return new IHdmiControlCallback.Stub() {
            @Override
@@ -158,4 +204,21 @@ public final class HdmiTvClient extends HdmiClient {
            }
        };
    }

    private static IHdmiRecordRequestListener getCallbackWrapper(
            final RecordRequestListener listener) {
        return new IHdmiRecordRequestListener.Stub() {
            @Override
            public byte[] onRecordRequestReceived(int recorderAddress) throws RemoteException {
                HdmiRecordSources.RecordSource source =
                        listener.onRecordRequestReceived(recorderAddress);
                if (source == null) {
                    return EmptyArray.BYTE;
                }
                byte[] data = new byte[source.getDataSize(true)];
                source.toByteArray(true, data, 0);
                return data;
            }
        };
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.hardware.hdmi.IHdmiControlCallback;
import android.hardware.hdmi.IHdmiDeviceEventListener;
import android.hardware.hdmi.IHdmiHotplugEventListener;
import android.hardware.hdmi.IHdmiInputChangeListener;
import android.hardware.hdmi.IHdmiRecordRequestListener;
import android.hardware.hdmi.IHdmiSystemAudioModeChangeListener;
import android.hardware.hdmi.IHdmiVendorCommandListener;

@@ -61,4 +62,6 @@ interface IHdmiControlService {
    void sendVendorCommand(int deviceType, int targetAddress, in byte[] params,
            boolean hasVendorId);
    void addVendorCommandListener(IHdmiVendorCommandListener listener, int deviceType);
    void setRecordRequestListener(IHdmiRecordRequestListener listener);
    void startRecord(int recorderAddress, in byte[] recordSource);
}
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.hdmi;

/**
 * Callback interface definition for HDMI client to fill record source info
 * when it gets record start request.
 *
 * @hide
 */
interface IHdmiRecordRequestListener {
    byte[] onRecordRequestReceived(int recorderAddress);
}
 No newline at end of file
Loading