Resolve CEC related API requests from API Council
Test: manual
Bug: 128427908
Change-Id: I1c8cd3ed843c91ecb94076160fd1bd93295c619b
diff --git a/api/system-current.txt b/api/system-current.txt
index 282f6f7..a4ea137 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -2003,15 +2003,15 @@
public final class HdmiControlManager {
method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void addHotplugEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener);
method @Nullable public android.hardware.hdmi.HdmiClient getClient(int);
- method @Nullable public java.util.List<android.hardware.hdmi.HdmiDeviceInfo> getConnectedDevicesList();
+ method @NonNull public java.util.List<android.hardware.hdmi.HdmiDeviceInfo> getConnectedDevices();
method public int getPhysicalAddress();
method @Nullable public android.hardware.hdmi.HdmiPlaybackClient getPlaybackClient();
method @Nullable public android.hardware.hdmi.HdmiSwitchClient getSwitchClient();
method @Nullable public android.hardware.hdmi.HdmiTvClient getTvClient();
- method public boolean isRemoteDeviceConnected(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
- method public void powerOffRemoteDevice(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
+ method public boolean isDeviceConnected(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
+ method public void powerOffDevice(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void removeHotplugEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener);
- method public void requestRemoteDeviceToBecomeActiveSource(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
+ method public void setActiveSource(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
method @RequiresPermission(android.Manifest.permission.HDMI_CEC) public void setStandbyMode(boolean);
field public static final String ACTION_OSD_MESSAGE = "android.hardware.hdmi.action.OSD_MESSAGE";
field public static final int AVR_VOLUME_MUTED = 101; // 0x65
diff --git a/api/system-removed.txt b/api/system-removed.txt
index 162f212..5d74e17 100644
--- a/api/system-removed.txt
+++ b/api/system-removed.txt
@@ -60,6 +60,18 @@
}
+package android.hardware.hdmi {
+
+ public final class HdmiControlManager {
+ method @Deprecated public java.util.List<android.hardware.hdmi.HdmiDeviceInfo> getConnectedDevicesList();
+ method @Deprecated public boolean isRemoteDeviceConnected(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
+ method @Deprecated public void powerOffRemoteDevice(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
+ method @Deprecated public void powerOnRemoteDevice(android.hardware.hdmi.HdmiDeviceInfo);
+ method @Deprecated public void requestRemoteDeviceToBecomeActiveSource(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
+ }
+
+}
+
package android.location {
public class LocationManager {
diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java
index aff385d..d05ba79 100644
--- a/core/java/android/hardware/hdmi/HdmiControlManager.java
+++ b/core/java/android/hardware/hdmi/HdmiControlManager.java
@@ -428,17 +428,33 @@
}
/**
- * Get a snapshot of the real-time status of the remote devices.
+ * Get a snapshot of the real-time status of the devices on the CEC bus.
*
- * <p>This only applies to devices with multiple HDMI inputs.
+ * <p>This only applies to devices with switch functionality, which are devices with one
+ * or more than one HDMI inputs.
*
- * @return a list of {@link HdmiDeviceInfo} of the connected CEC devices. An empty
- * list will be returned if there is none.
+ * @return a list of {@link HdmiDeviceInfo} of the connected CEC devices on the CEC bus. An
+ * empty list will be returned if there is none.
*
* @hide
*/
+ @NonNull
@SystemApi
- @Nullable
+ public List<HdmiDeviceInfo> getConnectedDevices() {
+ try {
+ return mService.getDeviceList();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * @removed
+ * @hide
+ * @deprecated Please use {@link #getConnectedDevices()} instead.
+ */
+ @Deprecated
+ @SystemApi
public List<HdmiDeviceInfo> getConnectedDevicesList() {
try {
return mService.getDeviceList();
@@ -448,7 +464,8 @@
}
/**
- * Power off the target device by sending CEC commands.
+ * Power off the target device by sending CEC commands. Note that this device can't be the
+ * current device itself.
*
* <p>The target device info can be obtained by calling {@link #getConnectedDevicesList()}.
*
@@ -457,6 +474,23 @@
* @hide
*/
@SystemApi
+ public void powerOffDevice(@NonNull HdmiDeviceInfo deviceInfo) {
+ Preconditions.checkNotNull(deviceInfo);
+ try {
+ mService.powerOffRemoteDevice(
+ deviceInfo.getLogicalAddress(), deviceInfo.getDevicePowerStatus());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * @removed
+ * @hide
+ * @deprecated Please use {@link #powerOffDevice(deviceInfo)} instead.
+ */
+ @Deprecated
+ @SystemApi
public void powerOffRemoteDevice(@NonNull HdmiDeviceInfo deviceInfo) {
Preconditions.checkNotNull(deviceInfo);
try {
@@ -468,7 +502,8 @@
}
/**
- * Power on the target device by sending CEC commands.
+ * Power on the target device by sending CEC commands. Note that this device can't be the
+ * current device itself.
*
* <p>The target device info can be obtained by calling {@link #getConnectedDevicesList()}.
*
@@ -476,6 +511,23 @@
*
* @hide
*/
+ public void powerOnDevice(HdmiDeviceInfo deviceInfo) {
+ Preconditions.checkNotNull(deviceInfo);
+ try {
+ mService.powerOnRemoteDevice(
+ deviceInfo.getLogicalAddress(), deviceInfo.getDevicePowerStatus());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * @removed
+ * @hide
+ * @deprecated Please use {@link #powerOnDevice(deviceInfo)} instead.
+ */
+ @Deprecated
+ @SystemApi
public void powerOnRemoteDevice(HdmiDeviceInfo deviceInfo) {
Preconditions.checkNotNull(deviceInfo);
try {
@@ -487,15 +539,35 @@
}
/**
- * Request the target device to be the new Active Source by sending CEC commands.
+ * Request the target device to be the new Active Source by sending CEC commands. Note that
+ * this device can't be the current device itself.
*
* <p>The target device info can be obtained by calling {@link #getConnectedDevicesList()}.
*
+ * <p>If the target device responds to the command, the users should see the target device
+ * streaming on their TVs.
+ *
* @param deviceInfo HdmiDeviceInfo of the target device
*
* @hide
*/
@SystemApi
+ public void setActiveSource(@NonNull HdmiDeviceInfo deviceInfo) {
+ Preconditions.checkNotNull(deviceInfo);
+ try {
+ mService.askRemoteDeviceToBecomeActiveSource(deviceInfo.getPhysicalAddress());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * @removed
+ * @hide
+ * @deprecated Please use {@link #setActiveSource(deviceInfo)} instead.
+ */
+ @Deprecated
+ @SystemApi
public void requestRemoteDeviceToBecomeActiveSource(@NonNull HdmiDeviceInfo deviceInfo) {
Preconditions.checkNotNull(deviceInfo);
try {
@@ -556,7 +628,7 @@
}
/**
- * Check if the target remote device is connected to the current device.
+ * Check if the target device is connected to the current device.
*
* <p>The API also returns true if the current device is the target.
*
@@ -567,6 +639,27 @@
* @hide
*/
@SystemApi
+ public boolean isDeviceConnected(@NonNull HdmiDeviceInfo targetDevice) {
+ Preconditions.checkNotNull(targetDevice);
+ mPhysicalAddress = getPhysicalAddress();
+ if (mPhysicalAddress == INVALID_PHYSICAL_ADDRESS) {
+ return false;
+ }
+ int targetPhysicalAddress = targetDevice.getPhysicalAddress();
+ if (targetPhysicalAddress == INVALID_PHYSICAL_ADDRESS) {
+ return false;
+ }
+ return HdmiUtils.getLocalPortFromPhysicalAddress(targetPhysicalAddress, mPhysicalAddress)
+ != HdmiUtils.TARGET_NOT_UNDER_LOCAL_DEVICE;
+ }
+
+ /**
+ * @removed
+ * @hide
+ * @deprecated Please use {@link #isDeviceConnected(targetDevice)} instead.
+ */
+ @Deprecated
+ @SystemApi
public boolean isRemoteDeviceConnected(@NonNull HdmiDeviceInfo targetDevice) {
Preconditions.checkNotNull(targetDevice);
mPhysicalAddress = getPhysicalAddress();