summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Amy Zhang <amyjojo@google.com> 2019-04-15 17:46:49 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-04-15 17:46:49 +0000
commit64b51f91ff5a7d2cb11b91f541edba6307176784 (patch)
tree9266b85114f1ce4ca2a6b1816eae18c53145f6ff
parentad6195dc4086e72e640f1f1aadb0fb983dc7cbe4 (diff)
parentd23043a255627baa875ab36147e23cd788bffb1a (diff)
Merge "Resolve CEC related API requests from API Council" into qt-dev
-rw-r--r--api/system-current.txt8
-rw-r--r--api/system-removed.txt12
-rw-r--r--core/java/android/hardware/hdmi/HdmiControlManager.java111
3 files changed, 118 insertions, 13 deletions
diff --git a/api/system-current.txt b/api/system-current.txt
index 5d0c1d9cf291..ae27daf53ede 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -2002,15 +2002,15 @@ package android.hardware.hdmi {
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 162f212a787e..5d74e17de756 100644
--- a/api/system-removed.txt
+++ b/api/system-removed.txt
@@ -60,6 +60,18 @@ package android.content {
}
+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 aff385dc23e1..d05ba799205c 100644
--- a/core/java/android/hardware/hdmi/HdmiControlManager.java
+++ b/core/java/android/hardware/hdmi/HdmiControlManager.java
@@ -428,17 +428,33 @@ public final class HdmiControlManager {
}
/**
- * 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
+ public List<HdmiDeviceInfo> getConnectedDevices() {
+ try {
+ return mService.getDeviceList();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * @removed
+ * @hide
+ * @deprecated Please use {@link #getConnectedDevices()} instead.
+ */
+ @Deprecated
@SystemApi
- @Nullable
public List<HdmiDeviceInfo> getConnectedDevicesList() {
try {
return mService.getDeviceList();
@@ -448,7 +464,8 @@ public final class HdmiControlManager {
}
/**
- * 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 @@ public final class HdmiControlManager {
* @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 @@ public final class HdmiControlManager {
}
/**
- * 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 @@ public final class HdmiControlManager {
*
* @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 @@ public final class HdmiControlManager {
}
/**
- * 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 @@ public final class HdmiControlManager {
}
/**
- * 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 @@ public final class HdmiControlManager {
* @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();