diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 8528c95101a75..dd8734668c9da 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -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 CREATOR; diff --git a/core/java/android/hardware/hdmi/HdmiPortInfo.java b/core/java/android/hardware/hdmi/HdmiPortInfo.java index 625a6a53d9ce4..5bb1f035f8487 100644 --- a/core/java/android/hardware/hdmi/HdmiPortInfo.java +++ b/core/java/android/hardware/hdmi/HdmiPortInfo.java @@ -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); } } diff --git a/core/tests/hdmitests/src/android/hardware/hdmi/HdmiPortInfoTest.java b/core/tests/hdmitests/src/android/hardware/hdmi/HdmiPortInfoTest.java index d8dc1eabe0456..64df3487bf530 100755 --- a/core/tests/hdmitests/src/android/hardware/hdmi/HdmiPortInfoTest.java +++ b/core/tests/hdmitests/src/android/hardware/hdmi/HdmiPortInfoTest.java @@ -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(); } } diff --git a/services/core/java/com/android/server/hdmi/HdmiCecController.java b/services/core/java/com/android/server/hdmi/HdmiCecController.java index 50edd0e8e0083..2bf7812e1c3de 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecController.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecController.java @@ -70,6 +70,10 @@ import java.util.function.Predicate; *

It can be created only by {@link HdmiCecController#create} * *

Declared as package-private, accessed by {@link HdmiControlService} only. + * + *

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; diff --git a/services/core/java/com/android/server/hdmi/HdmiCecNetwork.java b/services/core/java/com/android/server/hdmi/HdmiCecNetwork.java index f7089417a5800..a57292af70286 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecNetwork.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecNetwork.java @@ -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); }