From beab1f68e80294ee00a30047903fe0652e0d39e4 Mon Sep 17 00:00:00 2001 From: Hongguang Date: Wed, 2 Feb 2022 15:52:24 -0800 Subject: [PATCH] Return a collection in getAllAtsc3PlpInfo() Bug: 216529056 Fix: 216529056 Test: atest android.media.tv.tuner.cts Change-Id: I9b5314069000fff54c301bf3209b3d6ae7c3428f --- core/api/system-current.txt | 2 +- .../tv/tuner/frontend/FrontendStatus.java | 29 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 1cba58c391dc1..d33c6908b12af 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -7952,7 +7952,7 @@ package android.media.tv.tuner.frontend { public class FrontendStatus { method public int getAgc(); - method @NonNull public android.media.tv.tuner.frontend.Atsc3PlpInfo[] getAllAtsc3PlpInfo(); + method @NonNull public java.util.List getAllAtsc3PlpInfo(); method @NonNull public android.media.tv.tuner.frontend.FrontendStatus.Atsc3PlpTuningInfo[] getAtsc3PlpTuningInfo(); method public int getBandwidth(); method public int getBer(); diff --git a/media/java/android/media/tv/tuner/frontend/FrontendStatus.java b/media/java/android/media/tv/tuner/frontend/FrontendStatus.java index c1e9b38a13b00..9fbea724f491d 100644 --- a/media/java/android/media/tv/tuner/frontend/FrontendStatus.java +++ b/media/java/android/media/tv/tuner/frontend/FrontendStatus.java @@ -25,6 +25,9 @@ import android.media.tv.tuner.Lnb; import android.media.tv.tuner.TunerVersionChecker; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; /** * A Frontend Status class that contains the metrics of the active frontend. @@ -1086,22 +1089,26 @@ public class FrontendStatus { } /** - * Gets an array of all PLPs information of ATSC3 frontend, which includes both tuned and not + * Gets a list of all PLPs information of ATSC3 frontend, which includes both tuned and not * tuned PLPs for currently watching service. * - *

This query is only supported by Tuner HAL 2.0 or higher. Unsupported version or if HAL - * doesn't return all PLPs information will throw IllegalStateException. Use - * {@link TunerVersionChecker#getTunerVersion()} to check the version. + *

This query is only supported by Tuner HAL 2.0 or higher. Unsupported version will throw + * UnsupportedOperationException. Use {@link TunerVersionChecker#getTunerVersion()} to check + * the version. + * + * @return a list of all PLPs information. It is empty if HAL doesn't return all PLPs + * information status. */ - @SuppressLint("ArrayReturn") @NonNull - public Atsc3PlpInfo[] getAllAtsc3PlpInfo() { - TunerVersionChecker.checkHigherOrEqualVersionTo( - TunerVersionChecker.TUNER_VERSION_2_0, "Atsc3PlpInfo all status"); - if (mAllPlpInfo == null) { - throw new IllegalStateException("Atsc3PlpInfo all status is empty"); + public List getAllAtsc3PlpInfo() { + if (!TunerVersionChecker.checkHigherOrEqualVersionTo( + TunerVersionChecker.TUNER_VERSION_2_0, "Atsc3PlpInfo all status")) { + throw new UnsupportedOperationException("Atsc3PlpInfo all status is empty"); } - return mAllPlpInfo; + if (mAllPlpInfo == null) { + return Collections.EMPTY_LIST; + } + return Arrays.asList(mAllPlpInfo); } /**