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

Commit 096fe0b1 authored by Paul Colța's avatar Paul Colța
Browse files

HDMICEC: Implement client side of deviceSelect API for Playback devices

Deprecate methods deviceSelect and getCallbackWrapper from HdmiTvClient and move their implementation to HdmiClient.
Implement SelectCallback interface in HdmiClient.

Bug: 196043550
Test: make
Change-Id: I3a5b04495d21cc2714205621102f094f9f87c587
parent fe17e6df
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -3301,6 +3301,7 @@ package android.hardware.display {
package android.hardware.hdmi {
package android.hardware.hdmi {
  public abstract class HdmiClient {
  public abstract class HdmiClient {
    method public void deviceSelect(int, @NonNull android.hardware.hdmi.HdmiTvClient.SelectCallback);
    method public android.hardware.hdmi.HdmiDeviceInfo getActiveSource();
    method public android.hardware.hdmi.HdmiDeviceInfo getActiveSource();
    method public void sendKeyEvent(int, boolean);
    method public void sendKeyEvent(int, boolean);
    method public void sendVendorCommand(int, byte[], boolean);
    method public void sendVendorCommand(int, byte[], boolean);
@@ -3644,7 +3645,7 @@ package android.hardware.hdmi {
  public final class HdmiTvClient extends android.hardware.hdmi.HdmiClient {
  public final class HdmiTvClient extends android.hardware.hdmi.HdmiClient {
    method public void clearTimerRecording(int, int, android.hardware.hdmi.HdmiTimerRecordSources.TimerRecordSource);
    method public void clearTimerRecording(int, int, android.hardware.hdmi.HdmiTimerRecordSources.TimerRecordSource);
    method public void deviceSelect(int, @NonNull android.hardware.hdmi.HdmiTvClient.SelectCallback);
    method @Deprecated public void deviceSelect(int, @NonNull android.hardware.hdmi.HdmiTvClient.SelectCallback);
    method @Deprecated public java.util.List<android.hardware.hdmi.HdmiDeviceInfo> getDeviceList();
    method @Deprecated public java.util.List<android.hardware.hdmi.HdmiDeviceInfo> getDeviceList();
    method public int getDeviceType();
    method public int getDeviceType();
    method public void portSelect(int, @NonNull android.hardware.hdmi.HdmiTvClient.SelectCallback);
    method public void portSelect(int, @NonNull android.hardware.hdmi.HdmiTvClient.SelectCallback);
+31 −0
Original line number Original line Diff line number Diff line
@@ -4,6 +4,7 @@ import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.hardware.hdmi.HdmiControlManager.VendorCommandListener;
import android.hardware.hdmi.HdmiControlManager.VendorCommandListener;
import android.hardware.hdmi.HdmiTvClient.SelectCallback;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Log;
import android.util.Log;


@@ -27,6 +28,36 @@ public abstract class HdmiClient {
        mService = service;
        mService = service;
    }
    }


    /**
     * Selects a CEC logical device to be a new active source.
     *
     * @param logicalAddress logical address of the device to select
     * @param callback callback to get the result with
     * @throws {@link IllegalArgumentException} if the {@code callback} is null
     */
    public void deviceSelect(int logicalAddress, @NonNull SelectCallback callback) {
        if (callback == null) {
            throw new IllegalArgumentException("callback must not be null.");
        }
        try {
            mService.deviceSelect(logicalAddress, getCallbackWrapper(callback));
        } catch (RemoteException e) {
            Log.e(TAG, "failed to select device: ", e);
        }
    }

    /**
     * @hide
     */
    private static IHdmiControlCallback getCallbackWrapper(final SelectCallback callback) {
        return new IHdmiControlCallback.Stub() {
            @Override
            public void onComplete(int result) {
                callback.onComplete(result);
            }
        };
    }

    /**
    /**
     * Returns the active source information.
     * Returns the active source information.
     *
     *
+6 −0
Original line number Original line Diff line number Diff line
@@ -77,7 +77,9 @@ public final class HdmiTvClient extends HdmiClient {
     * @param logicalAddress logical address of the device to select
     * @param logicalAddress logical address of the device to select
     * @param callback callback to get the result with
     * @param callback callback to get the result with
     * @throws {@link IllegalArgumentException} if the {@code callback} is null
     * @throws {@link IllegalArgumentException} if the {@code callback} is null
     * @deprecated Please use {@link HdmiClient#deviceSelect()} instead.
     */
     */
    @Deprecated
    public void deviceSelect(int logicalAddress, @NonNull SelectCallback callback) {
    public void deviceSelect(int logicalAddress, @NonNull SelectCallback callback) {
        if (callback == null) {
        if (callback == null) {
            throw new IllegalArgumentException("callback must not be null.");
            throw new IllegalArgumentException("callback must not be null.");
@@ -89,6 +91,10 @@ public final class HdmiTvClient extends HdmiClient {
        }
        }
    }
    }


    /**
     * @deprecated Please use {@link HdmiClient#getCallbackWrapper()} instead.
     */
    @Deprecated
    private static IHdmiControlCallback getCallbackWrapper(final SelectCallback callback) {
    private static IHdmiControlCallback getCallbackWrapper(final SelectCallback callback) {
        return new IHdmiControlCallback.Stub() {
        return new IHdmiControlCallback.Stub() {
            @Override
            @Override