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

Commit 6c65342c authored by Venkatarama NG. Avadhani's avatar Venkatarama NG. Avadhani
Browse files

CEC: Change vendor command handling

If a vendor command without vendor ID is received, the message is now
forwarded to all registered listeners, irrespective of the device type.

If a vendor command with ID is received, the message is forwarded to all
listeners registered with that vendor ID

Bug: 177061176
Test: atest com.android.server.hdmi.HdmiControlServiceTest#addVendorCommandListener_noCallback_VendorCmdDiffIdTest
  atest com.android.server.hdmi.HdmiControlServiceTest#addVendorCommandListener_receiveCallback_VendorCmdNoIdTest
  atest com.android.server.hdmi.HdmiControlServiceTest#addVendorCommandListener_receiveCallback_VendorCmdWithIdTest
Change-Id: I84e010ccbe58ff090348babba05db0c31add1136
parent d5bd8472
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3345,6 +3345,7 @@ package android.hardware.hdmi {
    method public void sendKeyEvent(int, boolean);
    method public void sendVendorCommand(int, byte[], boolean);
    method public void setVendorCommandListener(@NonNull android.hardware.hdmi.HdmiControlManager.VendorCommandListener);
    method public void setVendorCommandListener(@NonNull android.hardware.hdmi.HdmiControlManager.VendorCommandListener, int);
  }
  public final class HdmiControlManager {
+18 −2
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ import android.util.Log;
public abstract class HdmiClient {
    private static final String TAG = "HdmiClient";

    private static final int UNKNOWN_VENDOR_ID = 0xFFFFFF;

    /* package */ final IHdmiControlService mService;

    private IHdmiVendorCommandListener mIHdmiVendorCommandListener;
@@ -94,11 +96,25 @@ public abstract class HdmiClient {
    }

    /**
     * Sets a listener used to receive incoming vendor-specific command.
     * Sets a listener used to receive incoming vendor-specific command. This listener will only
     * receive {@code <Vendor Command>} but will not receive any {@code <Vendor Command with ID>}
     * messages.
     *
     * @param listener listener object
     */
    public void setVendorCommandListener(@NonNull VendorCommandListener listener) {
        // Set the vendor ID to INVALID_VENDOR_ID.
        setVendorCommandListener(listener, UNKNOWN_VENDOR_ID);
    }

    /**
     * Sets a listener used to receive incoming vendor-specific command.
     *
     * @param listener listener object
     * @param vendorId The listener is interested in {@code <Vendor Command with ID>} received with
     *     this vendorId and all {@code <Vendor Command>} messages.
     */
    public void setVendorCommandListener(@NonNull VendorCommandListener listener, int vendorId) {
        if (listener == null) {
            throw new IllegalArgumentException("listener cannot be null");
        }
@@ -107,7 +123,7 @@ public abstract class HdmiClient {
        }
        try {
            IHdmiVendorCommandListener wrappedListener = getListenerWrapper(listener);
            mService.addVendorCommandListener(wrappedListener, getDeviceType());
            mService.addVendorCommandListener(wrappedListener, vendorId);
            mIHdmiVendorCommandListener = wrappedListener;
        } catch (RemoteException e) {
            Log.e(TAG, "failed to set vendor command listener: ", e);
+3 −3
Original line number Diff line number Diff line
@@ -221,8 +221,8 @@ public final class HdmiControlServiceWrapper {
        }

        @Override
        public void addVendorCommandListener(IHdmiVendorCommandListener listener, int deviceType) {
            HdmiControlServiceWrapper.this.addVendorCommandListener(listener, deviceType);
        public void addVendorCommandListener(IHdmiVendorCommandListener listener, int vendorId) {
            HdmiControlServiceWrapper.this.addVendorCommandListener(listener, vendorId);
        }

        @Override
@@ -471,7 +471,7 @@ public final class HdmiControlServiceWrapper {
            boolean hasVendorId) {}

    /** @hide */
    public void addVendorCommandListener(IHdmiVendorCommandListener listener, int deviceType) {}
    public void addVendorCommandListener(IHdmiVendorCommandListener listener, int vendorId) {}

    /** @hide */
    public void sendStandby(int deviceType, int deviceId) {}
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ interface IHdmiControlService {
    void askRemoteDeviceToBecomeActiveSource(int physicalAddress);
    void sendVendorCommand(int deviceType, int targetAddress, in byte[] params,
            boolean hasVendorId);
    void addVendorCommandListener(IHdmiVendorCommandListener listener, int deviceType);
    void addVendorCommandListener(IHdmiVendorCommandListener listener, int vendorId);
    void sendStandby(int deviceType, int deviceId);
    void setHdmiRecordListener(IHdmiRecordListener callback);
    void startOneTouchRecord(int recorderAddress, in byte[] recordSource);
+2 −3
Original line number Diff line number Diff line
@@ -288,9 +288,8 @@ public class HdmiAudioSystemClientTest {
        }

        @Override
        public void addVendorCommandListener(final IHdmiVendorCommandListener listener,
                final int deviceType) {
        }
        public void addVendorCommandListener(
                final IHdmiVendorCommandListener listener, final int vendorId) {}

        @Override
        public void sendVendorCommand(final int deviceType, final int targetAddress,
Loading