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

Commit 119160a6 authored by Jinsuk Kim's avatar Jinsuk Kim
Browse files

Add vendor-specific command API for HdmiControl

Vendor-specific commands are not handled by the service. This CL
opens an API for vendors to implement customized handling of
CEC commands specific to their needs.

Change-Id: I8bfa3b891bd7994a903b3b41d7c2b27464167afa
parent 2a46b902
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ LOCAL_SRC_FILES += \
	core/java/android/hardware/hdmi/IHdmiHotplugEventListener.aidl \
	core/java/android/hardware/hdmi/IHdmiInputChangeListener.aidl \
	core/java/android/hardware/hdmi/IHdmiSystemAudioModeChangeListener.aidl \
	core/java/android/hardware/hdmi/IHdmiVendorCommandListener.aidl \
	core/java/android/hardware/input/IInputManager.aidl \
	core/java/android/hardware/input/IInputDevicesChangedListener.aidl \
	core/java/android/hardware/location/IFusedLocationHardware.aidl \
+51 −0
Original line number Diff line number Diff line
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;

/**
 * Parent for classes of various HDMI-CEC device type used to access
 * {@link HdmiControlService}. Contains methods and data used in common.
 *
 * @hide
 */
public abstract class HdmiClient {
    private static final String TAG = "HdmiClient";

    protected final IHdmiControlService mService;

    protected abstract int getDeviceType();

    public HdmiClient(IHdmiControlService service) {
        mService = service;
    }

    public void sendVendorCommand(int targetAddress, byte[] params, boolean hasVendorId) {
        try {
            mService.sendVendorCommand(getDeviceType(), targetAddress, params, hasVendorId);
        } catch (RemoteException e) {
            Log.e(TAG, "failed to send vendor command: ", e);
        }
    }

    public void addVendorCommandListener(VendorCommandListener listener) {
        try {
            mService.addVendorCommandListener(getListenerWrapper(listener), getDeviceType());
        } catch (RemoteException e) {
            Log.e(TAG, "failed to add vendor command listener: ", e);
        }
    }

    private static IHdmiVendorCommandListener getListenerWrapper(
            final VendorCommandListener listener) {
        return new IHdmiVendorCommandListener.Stub() {
            @Override
            public void onReceived(int srcAddress, byte[] params, boolean hasVendorId) {
                listener.onReceived(srcAddress, params, hasVendorId);
            }
        };
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -129,6 +129,21 @@ public final class HdmiControlManager {
        void onReceived(HdmiHotplugEvent event);
    }

    /**
     * Listener used to get vendor-specific commands.
     */
    public interface VendorCommandListener {
        /**
         * Called when a vendor command is received.
         *
         * @param srcAddress source logical address
         * @param params vendor-specific parameters
         * @param hasVendorId {@code true} if the command is <Vendor Command
         *        With ID>. The first 3 bytes of params is vendor id.
         */
        void onReceived(int srcAddress, byte[] params, boolean hasVendorId);
    }

    /**
     * Adds a listener to get informed of {@link HdmiHotplugEvent}.
     *
+6 −5
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package android.hardware.hdmi;

import android.annotation.SystemApi;
import android.os.RemoteException;

import android.util.Log;

/**
@@ -30,11 +29,9 @@ import android.util.Log;
 * @hide
 */
@SystemApi
public final class HdmiPlaybackClient {
public final class HdmiPlaybackClient extends HdmiClient {
    private static final String TAG = "HdmiPlaybackClient";

    private final IHdmiControlService mService;

    /**
     * Listener used by the client to get the result of one touch play operation.
     */
@@ -66,7 +63,7 @@ public final class HdmiPlaybackClient {
    }

    HdmiPlaybackClient(IHdmiControlService service) {
        mService = service;
        super(service);
    }

    /**
@@ -85,6 +82,10 @@ public final class HdmiPlaybackClient {
        }
    }

    public int getDeviceType() {
        return HdmiCecDeviceInfo.DEVICE_PLAYBACK;
    }

    /**
     * Get the status of display device connected through HDMI bus.
     *
+8 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
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;

@@ -27,7 +29,7 @@ import android.util.Log;
 * @hide
 */
@SystemApi
public final class HdmiTvClient {
public final class HdmiTvClient extends HdmiClient {
    private static final String TAG = "HdmiTvClient";

    // Definitions used for setOption(). These should be in sync with the definition
@@ -79,10 +81,8 @@ public final class HdmiTvClient {
    public static final int DISABLED = 0;
    public static final int ENABLED = 1;

    private final IHdmiControlService mService;

    HdmiTvClient(IHdmiControlService service) {
        mService = service;
        super(service);
    }

    // Factory method for HdmiTvClient.
@@ -91,6 +91,10 @@ public final class HdmiTvClient {
        return new HdmiTvClient(service);
    }

    public int getDeviceType() {
        return HdmiCecDeviceInfo.DEVICE_TV;
    }

    /**
     * Callback interface used to get the result of {@link #deviceSelect}.
     */
Loading