From 35cc37299c4fd5d2b58b322fbb02d625fb599ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Col=C8=9Ba?= Date: Wed, 11 Aug 2021 15:53:54 +0000 Subject: [PATCH] HDMICEC: Deprecate HdmiTvClient#getDeviceList Move the implementation of the getDeviceList method from HdmiTvClient and HdmiSwitchClient to the HdmiClient abstract class in order to avoid duplicate code and to make it visible for HdmiPlaybackClient. Add unit test for HdmiCecNetwork#getSafeCecDevicesLocked method which is called by HdmiControlService#getDeviceList. Bug: 196043550 Test: make && atest HdmiCecNetworkTest Change-Id: If4727d582348022a0317d9fce6459d56a7affa5a --- core/api/system-current.txt | 2 +- core/java/android/hardware/hdmi/HdmiSwitchClient.java | 2 ++ core/java/android/hardware/hdmi/HdmiTvClient.java | 2 ++ .../src/com/android/server/hdmi/HdmiCecNetworkTest.java | 9 +++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 86d67b04085f6..c39328304a26c 100755 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -3638,7 +3638,7 @@ package android.hardware.hdmi { public final class HdmiTvClient extends android.hardware.hdmi.HdmiClient { method public void clearTimerRecording(int, int, android.hardware.hdmi.HdmiTimerRecordSources.TimerRecordSource); method public void deviceSelect(int, @NonNull android.hardware.hdmi.HdmiTvClient.SelectCallback); - method public java.util.List getDeviceList(); + method @Deprecated public java.util.List getDeviceList(); method public int getDeviceType(); method public void portSelect(int, @NonNull android.hardware.hdmi.HdmiTvClient.SelectCallback); method public void sendMhlVendorCommand(int, int, int, byte[]); diff --git a/core/java/android/hardware/hdmi/HdmiSwitchClient.java b/core/java/android/hardware/hdmi/HdmiSwitchClient.java index cbfbe3940e473..79846cd70784e 100644 --- a/core/java/android/hardware/hdmi/HdmiSwitchClient.java +++ b/core/java/android/hardware/hdmi/HdmiSwitchClient.java @@ -165,7 +165,9 @@ public class HdmiSwitchClient extends HdmiClient { * there is none. * * @hide + * @deprecated Please use {@link HdmiControlManager#getConnectedDevices()} instead. */ + @Deprecated public List getDeviceList() { try { return mService.getDeviceList(); diff --git a/core/java/android/hardware/hdmi/HdmiTvClient.java b/core/java/android/hardware/hdmi/HdmiTvClient.java index f33a1370b3c19..e1ed3eaff1e17 100644 --- a/core/java/android/hardware/hdmi/HdmiTvClient.java +++ b/core/java/android/hardware/hdmi/HdmiTvClient.java @@ -158,7 +158,9 @@ public final class HdmiTvClient extends HdmiClient { * * @return list of {@link HdmiDeviceInfo} for connected CEC devices. * Empty list is returned if there is none. + * @deprecated Please use {@link HdmiControlManager#getConnectedDevices()} instead. */ + @Deprecated public List getDeviceList() { try { return mService.getDeviceList(); diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecNetworkTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecNetworkTest.java index e7d1b957bce7f..1048eb5acd1a4 100644 --- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecNetworkTest.java +++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecNetworkTest.java @@ -542,4 +542,13 @@ public class HdmiCecNetworkTest { assertThat(cecDeviceInfo.getLogicalAddress()).isEqualTo(logicalAddress); assertThat(cecDeviceInfo.getCecVersion()).isEqualTo(cecVersion); } + + @Test + public void getSafeCecDevicesLocked_addDevice_sizeOne() { + HdmiDeviceInfo cecDeviceInfo = new HdmiDeviceInfo(); + + mHdmiCecNetwork.addCecDevice(cecDeviceInfo); + + assertThat(mHdmiCecNetwork.getSafeCecDevicesLocked()).hasSize(1); + } }