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

Commit f4e0589b authored by Nathalie Le Clair's avatar Nathalie Le Clair
Browse files

Add eARC info to HdmiPortInfo

Add a stub for the earcSupported parameter to HdmiCecController. The
HDMI HAL methods (such as getPortInfo, the method that reports this
parameter) currently enter the framework through HdmiCecController, but
may be moved out into a separate controller in the future.

Test: make
Bug: 240388203
Change-Id: I231cd4ed97490d6770c45b0fd5631274c421b672
parent fd133451
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4520,12 +4520,14 @@ package android.hardware.hdmi {
  public final class HdmiPortInfo implements android.os.Parcelable {
    ctor public HdmiPortInfo(int, int, int, boolean, boolean, boolean);
    ctor public HdmiPortInfo(int, int, int, boolean, boolean, boolean, boolean);
    method public int describeContents();
    method public int getAddress();
    method public int getId();
    method public int getType();
    method public boolean isArcSupported();
    method public boolean isCecSupported();
    method public boolean isEarcSupported();
    method public boolean isMhlSupported();
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.hdmi.HdmiPortInfo> CREATOR;
+35 −5
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.os.Parcelable;

/**
 * A class to encapsulate HDMI port information. Contains the capability of the ports such as
 * HDMI-CEC, MHL, ARC(Audio Return Channel), and physical address assigned to each port.
 * HDMI-CEC, MHL, ARC(Audio Return Channel), eARC and physical address assigned to each port.
 *
 * @hide
 */
@@ -40,6 +40,7 @@ public final class HdmiPortInfo implements Parcelable {
    private final int mAddress;
    private final boolean mCecSupported;
    private final boolean mArcSupported;
    private final boolean mEarcSupported;
    private final boolean mMhlSupported;

    /**
@@ -53,11 +54,28 @@ public final class HdmiPortInfo implements Parcelable {
     * @param arc {@code true} if audio return channel is supported on the port
     */
    public HdmiPortInfo(int id, int type, int address, boolean cec, boolean mhl, boolean arc) {
        this(id, type, address, cec, mhl, arc, false);
    }

    /**
     * Constructor.
     *
     * @param id identifier assigned to each port. 1 for HDMI port 1
     * @param type HDMI port input/output type
     * @param address physical address of the port
     * @param cec {@code true} if HDMI-CEC is supported on the port
     * @param mhl {@code true} if MHL is supported on the port
     * @param arc {@code true} if audio return channel is supported on the port
     * @param earc {@code true} if eARC is supported on the port
     */
    public HdmiPortInfo(int id, int type, int address,
            boolean cec, boolean mhl, boolean arc, boolean earc) {
        mId = id;
        mType = type;
        mAddress = address;
        mCecSupported = cec;
        mArcSupported = arc;
        mEarcSupported = earc;
        mMhlSupported = mhl;
    }

@@ -115,6 +133,15 @@ public final class HdmiPortInfo implements Parcelable {
        return mArcSupported;
    }

    /**
     * Returns {@code true} if the port supports eARC.
     *
     * @return {@code true} if the port supports eARC.
     */
    public boolean isEarcSupported() {
        return mEarcSupported;
    }

    /**
     * Describes the kinds of special objects contained in this Parcelable's
     * marshalled representation.
@@ -138,7 +165,8 @@ public final class HdmiPortInfo implements Parcelable {
                    boolean cec = (source.readInt() == 1);
                    boolean arc = (source.readInt() == 1);
                    boolean mhl = (source.readInt() == 1);
                    return new HdmiPortInfo(id, type, address, cec, mhl, arc);
                    boolean earc = (source.readInt() == 1);
                    return new HdmiPortInfo(id, type, address, cec, mhl, arc, earc);
                }

                @Override
@@ -164,6 +192,7 @@ public final class HdmiPortInfo implements Parcelable {
        dest.writeInt(mCecSupported ? 1 : 0);
        dest.writeInt(mArcSupported ? 1 : 0);
        dest.writeInt(mMhlSupported ? 1 : 0);
        dest.writeInt(mEarcSupported ? 1 : 0);
    }

    @NonNull
@@ -175,7 +204,8 @@ public final class HdmiPortInfo implements Parcelable {
        s.append("address: ").append(String.format("0x%04x", mAddress)).append(", ");
        s.append("cec: ").append(mCecSupported).append(", ");
        s.append("arc: ").append(mArcSupported).append(", ");
        s.append("mhl: ").append(mMhlSupported);
        s.append("mhl: ").append(mMhlSupported).append(", ");
        s.append("earc: ").append(mEarcSupported);
        return s.toString();
    }

@@ -187,12 +217,12 @@ public final class HdmiPortInfo implements Parcelable {
        final HdmiPortInfo other = (HdmiPortInfo) o;
        return mId == other.mId && mType == other.mType && mAddress == other.mAddress
                && mCecSupported == other.mCecSupported && mArcSupported == other.mArcSupported
                && mMhlSupported == other.mMhlSupported;
                && mMhlSupported == other.mMhlSupported && mEarcSupported == other.mEarcSupported;
    }

    @Override
    public int hashCode() {
        return java.util.Objects.hash(
                mId, mType, mAddress, mCecSupported, mArcSupported, mMhlSupported);
                mId, mType, mAddress, mCecSupported, mArcSupported, mMhlSupported, mEarcSupported);
    }
}
+20 −8
Original line number Diff line number Diff line
@@ -37,26 +37,38 @@ public class HdmiPortInfoTest {
        boolean isCec = true;
        boolean isMhl = false;
        boolean isArcSupported = false;
        boolean isEarcSupported = false;

        new EqualsTester()
                .addEqualityGroup(
                        new HdmiPortInfo(portId, portType, address, isCec, isMhl, isArcSupported),
                        new HdmiPortInfo(portId, portType, address, isCec, isMhl, isArcSupported))
                        new HdmiPortInfo(portId, portType, address, isCec, isMhl, isArcSupported,
                                isEarcSupported),
                        new HdmiPortInfo(portId, portType, address, isCec, isMhl, isArcSupported,
                                isEarcSupported))
                .addEqualityGroup(
                        new HdmiPortInfo(
                                portId + 1, portType, address, isCec, isMhl, isArcSupported))
                                portId + 1, portType, address, isCec, isMhl, isArcSupported,
                                isEarcSupported))
                .addEqualityGroup(
                        new HdmiPortInfo(
                                portId, portType + 1, address, isCec, isMhl, isArcSupported))
                                portId, portType + 1, address, isCec, isMhl, isArcSupported,
                                isEarcSupported))
                .addEqualityGroup(
                        new HdmiPortInfo(
                                portId, portType, address + 1, isCec, isMhl, isArcSupported))
                                portId, portType, address + 1, isCec, isMhl, isArcSupported,
                                isEarcSupported))
                .addEqualityGroup(
                        new HdmiPortInfo(portId, portType, address, !isCec, isMhl, isArcSupported))
                        new HdmiPortInfo(portId, portType, address, !isCec, isMhl, isArcSupported,
                                isEarcSupported))
                .addEqualityGroup(
                        new HdmiPortInfo(portId, portType, address, isCec, !isMhl, isArcSupported))
                        new HdmiPortInfo(portId, portType, address, isCec, !isMhl, isArcSupported,
                                isEarcSupported))
                .addEqualityGroup(
                        new HdmiPortInfo(portId, portType, address, isCec, isMhl, !isArcSupported))
                        new HdmiPortInfo(portId, portType, address, isCec, isMhl, !isArcSupported,
                                isEarcSupported))
                .addEqualityGroup(
                        new HdmiPortInfo(portId, portType, address, isCec, isMhl, isArcSupported,
                                !isEarcSupported))
                .testEquals();
    }
}
+12 −3
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@ import java.util.function.Predicate;
 * <p>It can be created only by {@link HdmiCecController#create}
 *
 * <p>Declared as package-private, accessed by {@link HdmiControlService} only.
 *
 * <p>Also manages HDMI HAL methods that are shared between CEC and eARC. To make eARC
 * fully independent of the presence of a CEC HAL, we should split this class into HdmiCecController
 * and HdmiController TODO(b/255751565).
 */
final class HdmiCecController {
    private static final String TAG = "HdmiCecController";
@@ -1066,6 +1070,8 @@ final class HdmiCecController {
                HdmiPortInfo[] hdmiPortInfo = new HdmiPortInfo[hdmiPortInfos.length];
                int i = 0;
                for (android.hardware.tv.hdmi.HdmiPortInfo portInfo : hdmiPortInfos) {
                    // TODO: the earc argument is stubbed for now.
                    // To be replaced by portInfo.earcSupported.
                    hdmiPortInfo[i] =
                            new HdmiPortInfo(
                                    portInfo.portId,
@@ -1073,7 +1079,8 @@ final class HdmiCecController {
                                    portInfo.physicalAddress,
                                    portInfo.cecSupported,
                                    false,
                                    portInfo.arcSupported);
                                    portInfo.arcSupported,
                                    false);
                    i++;
                }
                return hdmiPortInfo;
@@ -1234,7 +1241,8 @@ final class HdmiCecController {
                            portInfo.physicalAddress,
                            portInfo.cecSupported,
                            false,
                            portInfo.arcSupported);
                            portInfo.arcSupported,
                            false);
                    i++;
                }
                return hdmiPortInfo;
@@ -1415,7 +1423,8 @@ final class HdmiCecController {
                            portInfo.physicalAddress,
                            portInfo.cecSupported,
                            false,
                            portInfo.arcSupported);
                            portInfo.arcSupported,
                            false);
                    i++;
                }
                return hdmiPortInfo;
+2 −1
Original line number Diff line number Diff line
@@ -470,7 +470,8 @@ public class HdmiCecNetwork {
        for (HdmiPortInfo info : cecPortInfo) {
            if (mhlSupportedPorts.contains(info.getId())) {
                result.add(new HdmiPortInfo(info.getId(), info.getType(), info.getAddress(),
                        info.isCecSupported(), true, info.isArcSupported()));
                        info.isCecSupported(), true, info.isArcSupported(),
                        info.isEarcSupported()));
            } else {
                result.add(info);
            }