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

Commit b10d25fc authored by Yuncheol Heo's avatar Yuncheol Heo Committed by Android Git Automerger
Browse files

am ddb863f4: am 5b062e07: Merge "CEC: Fix apilint errors." into lmp-mr1-dev

* commit 'ddb863f4':
  CEC: Fix apilint errors.
parents a021e922 ddb863f4
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@ import android.util.Log;
public abstract class HdmiClient {
    private static final String TAG = "HdmiClient";

    protected final IHdmiControlService mService;
    /* package */ final IHdmiControlService mService;

    protected abstract int getDeviceType();
    private IHdmiVendorCommandListener mIHdmiVendorCommandListener;

    public HdmiClient(IHdmiControlService service) {
    /* package */ abstract int getDeviceType();

    /* package */ HdmiClient(IHdmiControlService service) {
        mService = service;
    }

@@ -40,7 +42,7 @@ public abstract class HdmiClient {
    }

    /**
     * Send a key event to other logical device.
     * Sends a key event to other logical device.
     *
     * @param keyCode key code to send. Defined in {@link android.view.KeyEvent}.
     * @param isPressed true if this is key press event
@@ -54,7 +56,7 @@ public abstract class HdmiClient {
    }

    /**
     * Send vendor-specific command.
     * Sends vendor-specific command.
     *
     * @param targetAddress address of the target device
     * @param params vendor-specific parameter. For <Vendor Command With ID> do not
@@ -71,18 +73,23 @@ public abstract class HdmiClient {
    }

    /**
     * Add a listener used to receive incoming vendor-specific command.
     * Sets a listener used to receive incoming vendor-specific command.
     *
     * @param listener listener object
     */
    public void addVendorCommandListener(@NonNull VendorCommandListener listener) {
    public void setVendorCommandListener(@NonNull VendorCommandListener listener) {
        if (listener == null) {
            throw new IllegalArgumentException("listener cannot be null");
        }
        if (mIHdmiVendorCommandListener != null) {
            throw new IllegalStateException("listener was already set");
        }
        try {
            mService.addVendorCommandListener(getListenerWrapper(listener), getDeviceType());
            IHdmiVendorCommandListener wrappedListener = getListenerWrapper(listener);
            mService.addVendorCommandListener(wrappedListener, getDeviceType());
            mIHdmiVendorCommandListener = wrappedListener;
        } catch (RemoteException e) {
            Log.e(TAG, "failed to add vendor command listener: ", e);
            Log.e(TAG, "failed to set vendor command listener: ", e);
        }
    }

+29 −10
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.Log;

/**
 * The {@link HdmiControlManager} class is used to send HDMI control messages
@@ -36,6 +38,8 @@ import android.os.RemoteException;
 */
@SystemApi
public final class HdmiControlManager {
    private static final String TAG = "HdmiControlManager";

    @Nullable private final IHdmiControlService mService;

    /**
@@ -56,7 +60,7 @@ public final class HdmiControlManager {

    /**
     * Message used by TV to receive volume status from Audio Receiver. It should check volume value
     * that is retrieved from extra value with the key {@link #EXTRA_MESSAGE_EXTRAM_PARAM1}. If the
     * that is retrieved from extra value with the key {@link #EXTRA_MESSAGE_EXTRA_PARAM1}. If the
     * value is in range of [0,100], it is current volume of Audio Receiver. And there is another
     * value, {@link #AVR_VOLUME_MUTED}, which is used to inform volume mute.
     */
@@ -71,7 +75,7 @@ public final class HdmiControlManager {
     * Used as an extra field in the intent {@link #ACTION_OSD_MESSAGE}. Contains the extra value
     * of the message.
     */
    public static final String EXTRA_MESSAGE_EXTRAM_PARAM1 =
    public static final String EXTRA_MESSAGE_EXTRA_PARAM1 =
            "android.hardware.hdmi.extra.MESSAGE_EXTRA_PARAM1";

    /**
@@ -251,10 +255,9 @@ public final class HdmiControlManager {
    private final boolean mHasTvDevice;

    /**
     * @hide - hide this constructor because it has a parameter of type
     * IHdmiControlService, which is a system private class. The right way
     * to create an instance of this class is using the factory
     * Context.getSystemService.
     * {@hide} - hide this constructor because it has a parameter of type IHdmiControlService,
     * which is a system private class. The right way to create an instance of this class is
     * using the factory Context.getSystemService.
     */
    public HdmiControlManager(IHdmiControlService service) {
        mService = service;
@@ -340,6 +343,9 @@ public final class HdmiControlManager {
        void onReceived(HdmiHotplugEvent event);
    }

    private final ArrayMap<HotplugEventListener, IHdmiHotplugEventListener>
            mHotplugEventListeners = new ArrayMap<>();

    /**
     * Listener used to get vendor-specific commands.
     */
@@ -384,12 +390,19 @@ public final class HdmiControlManager {
     */
    public void addHotplugEventListener(HotplugEventListener listener) {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            return;
        }
        if (mHotplugEventListeners.containsKey(listener)) {
            Log.e(TAG, "listener is already registered");
            return;
        }
        IHdmiHotplugEventListener wrappedListener = getHotplugEventListenerWrapper(listener);
        mHotplugEventListeners.put(listener, wrappedListener);
        try {
            mService.addHotplugEventListener(getHotplugEventListenerWrapper(listener));
            mService.addHotplugEventListener(wrappedListener);
        } catch (RemoteException e) {
            // Do nothing.
            Log.e(TAG, "failed to add hotplug event listener: ", e);
        }
    }

@@ -400,12 +413,18 @@ public final class HdmiControlManager {
     */
    public void removeHotplugEventListener(HotplugEventListener listener) {
        if (mService == null) {
            Log.e(TAG, "HdmiControlService is not available");
            return;
        }
        IHdmiHotplugEventListener wrappedListener = mHotplugEventListeners.remove(listener);
        if (wrappedListener == null) {
            Log.e(TAG, "tried to remove not-registered listener");
            return;
        }
        try {
            mService.removeHotplugEventListener(getHotplugEventListenerWrapper(listener));
            mService.removeHotplugEventListener(wrappedListener);
        } catch (RemoteException e) {
            // Do nothing.
            Log.e(TAG, "failed to remove hotplug event listener: ", e);
        }
    }

+18 −18
Original line number Diff line number Diff line
@@ -237,14 +237,14 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return the id of the device.
     * Returns the id of the device.
     */
    public int getId() {
        return mId;
    }

    /**
     * Return the id to be used for CEC device.
     * Returns the id to be used for CEC device.
     *
     * @param address logical address of CEC device
     * @return id for CEC device
@@ -255,7 +255,7 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return the id to be used for MHL device.
     * Returns the id to be used for MHL device.
     *
     * @param portId port which the MHL device is connected to
     * @return id for MHL device
@@ -266,7 +266,7 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return the id to be used for hardware port.
     * Returns the id to be used for hardware port.
     *
     * @param portId port id
     * @return id for hardware port
@@ -276,28 +276,28 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return the CEC logical address of the device.
     * Returns the CEC logical address of the device.
     */
    public int getLogicalAddress() {
        return mLogicalAddress;
    }

    /**
     * Return the physical address of the device.
     * Returns the physical address of the device.
     */
    public int getPhysicalAddress() {
        return mPhysicalAddress;
    }

    /**
     * Return the port ID.
     * Returns the port ID.
     */
    public int getPortId() {
        return mPortId;
    }

    /**
     * Return CEC type of the device. For more details, refer constants between {@link #DEVICE_TV}
     * Returns CEC type of the device. For more details, refer constants between {@link #DEVICE_TV}
     * and {@link #DEVICE_INACTIVE}.
     */
    public int getDeviceType() {
@@ -305,7 +305,7 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return device's power status. It should be one of the following values.
     * Returns device's power status. It should be one of the following values.
     * <ul>
     * <li>{@link HdmiControlManager#POWER_STATUS_ON}
     * <li>{@link HdmiControlManager#POWER_STATUS_STANDBY}
@@ -319,21 +319,21 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return MHL device id. Return -1 for non-MHL device.
     * Returns MHL device id. Return -1 for non-MHL device.
     */
    public int getDeviceId() {
        return mDeviceId;
    }

    /**
     * Return MHL adopter id. Return -1 for non-MHL device.
     * Returns MHL adopter id. Return -1 for non-MHL device.
     */
    public int getAdopterId() {
        return mAdopterId;
    }

    /**
     * Return {@code true} if the device is of a type that can be an input source.
     * Returns {@code true} if the device is of a type that can be an input source.
     */
    public boolean isSourceType() {
        return mDeviceType == DEVICE_PLAYBACK
@@ -342,7 +342,7 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return {@code true} if the device represents an HDMI-CEC device. {@code false} if the device
     * Returns {@code true} if the device represents an HDMI-CEC device. {@code false} if the device
     * is either MHL or other device.
     */
    public boolean isCecDevice() {
@@ -350,7 +350,7 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return {@code true} if the device represents an MHL device. {@code false} if the device is
     * Returns {@code true} if the device represents an MHL device. {@code false} if the device is
     * either CEC or other device.
     */
    public boolean isMhlDevice() {
@@ -358,14 +358,14 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Return display (OSD) name of the device.
     * Returns display (OSD) name of the device.
     */
    public String getDisplayName() {
        return mDisplayName;
    }

    /**
     * Return vendor id of the device. Vendor id is used to distinguish devices built by other
     * Returns vendor id of the device. Vendor id is used to distinguish devices built by other
     * manufactures. This is required for vendor-specific command on CEC standard.
     */
    public int getVendorId() {
@@ -373,7 +373,7 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Describe the kinds of special objects contained in this Parcelable's marshalled
     * Describes the kinds of special objects contained in this Parcelable's marshalled
     * representation.
     */
    @Override
@@ -382,7 +382,7 @@ public class HdmiDeviceInfo implements Parcelable {
    }

    /**
     * Serialize this object into a {@link Parcel}.
     * Serializes this object into a {@link Parcel}.
     *
     * @param dest The Parcel in which the object should be written.
     * @param flags Additional flags about how the object should be written. May be 0 or
+7 −5
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public final class HdmiHotplugEvent implements Parcelable {
    }

    /**
     * Return the port number for which the event occurred.
     * Returns the port number for which the event occurred.
     *
     * @return port number
     */
@@ -53,7 +53,7 @@ public final class HdmiHotplugEvent implements Parcelable {
    }

    /**
     * Return the connection status associated with this event
     * Returns the connection status associated with this event
     *
     * @return true if the device gets connected; otherwise false
     */
@@ -62,7 +62,7 @@ public final class HdmiHotplugEvent implements Parcelable {
    }

    /**
     * Describe the kinds of special objects contained in this Parcelable's
     * Describes the kinds of special objects contained in this Parcelable's
     * marshalled representation.
     */
    @Override
@@ -71,7 +71,7 @@ public final class HdmiHotplugEvent implements Parcelable {
    }

    /**
     * Flatten this object in to a Parcel.
     * Flattens this object in to a Parcel.
     *
     * @param dest The Parcel in which the object should be written.
     * @param flags Additional flags about how the object should be written.
@@ -86,17 +86,19 @@ public final class HdmiHotplugEvent implements Parcelable {
    public static final Parcelable.Creator<HdmiHotplugEvent> CREATOR
            = new Parcelable.Creator<HdmiHotplugEvent>() {
        /**
         * Rebuild a {@link HdmiHotplugEvent} previously stored with
         * Rebuilds a {@link HdmiHotplugEvent} previously stored with
         * {@link Parcelable#writeToParcel(Parcel, int)}.
         *
         * @param p {@link HdmiHotplugEvent} object to read the Rating from
         * @return a new {@link HdmiHotplugEvent} created from the data in the parcel
         */
        @Override
        public HdmiHotplugEvent createFromParcel(Parcel p) {
            int port = p.readInt();
            boolean connected = p.readByte() == 1;
            return new HdmiHotplugEvent(port, connected);
        }
        @Override
        public HdmiHotplugEvent[] newArray(int size) {
            return new HdmiHotplugEvent[size];
        }
+3 −3
Original line number Diff line number Diff line
@@ -64,12 +64,12 @@ public final class HdmiPlaybackClient extends HdmiClient {
        public void onComplete(int status);
    }

    HdmiPlaybackClient(IHdmiControlService service) {
    /* package */ HdmiPlaybackClient(IHdmiControlService service) {
        super(service);
    }

    /**
     * Perform the feature 'one touch play' from playback device to turn on display
     * Performs the feature 'one touch play' from playback device to turn on display
     * and switch the input.
     *
     * @param callback {@link OneTouchPlayCallback} object to get informed
@@ -90,7 +90,7 @@ public final class HdmiPlaybackClient extends HdmiClient {
    }

    /**
     * Get the status of display device connected through HDMI bus.
     * Gets the status of display device connected through HDMI bus.
     *
     * @param callback {@link DisplayStatusCallback} object to get informed
     *         of the result
Loading