diff --git a/core/api/system-current.txt b/core/api/system-current.txt index ce2feac315f3b..b34517d9fe3c5 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -6795,6 +6795,7 @@ package android.media.tv.tuner { method @Nullable public android.media.tv.tuner.DemuxCapabilities getDemuxCapabilities(); method @Nullable public android.media.tv.tuner.frontend.FrontendInfo getFrontendInfo(); method @Nullable public android.media.tv.tuner.frontend.FrontendStatus getFrontendStatus(@NonNull int[]); + method @Nullable public android.media.tv.tuner.frontend.FrontendStatusReadiness[] getFrontendStatusReadiness(@NonNull int[]); method @IntRange(from=0xffffffff) public int getMaxNumberOfFrontends(int); method @RequiresPermission("android.permission.TUNER_RESOURCE_ACCESS") public boolean hasUnusedFrontend(int); method public boolean isLowestPriority(int); @@ -8039,6 +8040,16 @@ package android.media.tv.tuner.frontend { method public boolean isLocked(); } + public class FrontendStatusReadiness { + method public int getStatusReadiness(); + method public int getStatusType(); + field public static final int FRONTEND_STATUS_READINESS_STABLE = 3; // 0x3 + field public static final int FRONTEND_STATUS_READINESS_UNAVAILABLE = 1; // 0x1 + field public static final int FRONTEND_STATUS_READINESS_UNDEFINED = 0; // 0x0 + field public static final int FRONTEND_STATUS_READINESS_UNSTABLE = 2; // 0x2 + field public static final int FRONTEND_STATUS_READINESS_UNSUPPORTED = 4; // 0x4 + } + public class Isdbs3FrontendCapabilities extends android.media.tv.tuner.frontend.FrontendCapabilities { method public int getCodeRateCapability(); method public int getModulationCapability(); diff --git a/media/java/android/media/tv/tuner/Tuner.java b/media/java/android/media/tv/tuner/Tuner.java index 315737572c19a..be114d4eb80c7 100644 --- a/media/java/android/media/tv/tuner/Tuner.java +++ b/media/java/android/media/tv/tuner/Tuner.java @@ -47,6 +47,7 @@ import android.media.tv.tuner.frontend.FrontendInfo; import android.media.tv.tuner.frontend.FrontendSettings; import android.media.tv.tuner.frontend.FrontendStatus; import android.media.tv.tuner.frontend.FrontendStatus.FrontendStatusType; +import android.media.tv.tuner.frontend.FrontendStatusReadiness; import android.media.tv.tuner.frontend.OnTuneEventListener; import android.media.tv.tuner.frontend.ScanCallback; import android.media.tv.tunerresourcemanager.ResourceClientProfile; @@ -61,9 +62,7 @@ import android.os.Looper; import android.os.Message; import android.os.Process; import android.util.Log; - import com.android.internal.util.FrameworkStatsLog; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.ref.WeakReference; @@ -1005,6 +1004,7 @@ public class Tuner implements AutoCloseable { private native int nativeRemoveOutputPid(int pid); private native Lnb nativeOpenLnbByHandle(int handle); private native Lnb nativeOpenLnbByName(String name); + private native FrontendStatusReadiness[] nativeGetFrontendStatusReadiness(int[] statusTypes); private native Descrambler nativeOpenDescramblerByHandle(int handle); private native int nativeOpenDemuxByhandle(int handle); @@ -1594,6 +1594,38 @@ public class Tuner implements AutoCloseable { } } + /** + * Gets Frontend Status Readiness statuses for given status types. + * + *
This API is only supported by Tuner HAL 2.0 or higher. Unsupported versions would cause
+ * no-op. Use {@link TunerVersionChecker#getTunerVersion()} to check the version.
+ *
+ * @param statusTypes an array of status types.
+ *
+ * @return an array of current readiness states. {@code null} if the operation failed or
+ * unsupported versions.
+ * @throws IllegalStateException if there is no active frontend currently.
+ */
+ @Nullable
+ @SuppressLint("ArrayReturn")
+ @SuppressWarnings("NullableCollection")
+ public FrontendStatusReadiness[] getFrontendStatusReadiness(
+ @NonNull @FrontendStatusType int[] statusTypes) {
+ mFrontendLock.lock();
+ try {
+ if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
+ TunerVersionChecker.TUNER_VERSION_2_0, "Remove output PID")) {
+ return null;
+ }
+ if (mFrontend == null) {
+ throw new IllegalStateException("frontend is not initialized");
+ }
+ return nativeGetFrontendStatusReadiness(statusTypes);
+ } finally {
+ mFrontendLock.unlock();
+ }
+ }
+
/**
* Gets the currently initialized and activated frontend information. To get all the available
* frontend info on the device, use {@link getAvailableFrontendInfos()}.
diff --git a/media/java/android/media/tv/tuner/frontend/FrontendStatusReadiness.java b/media/java/android/media/tv/tuner/frontend/FrontendStatusReadiness.java
new file mode 100644
index 0000000000000..52527b3fb065e
--- /dev/null
+++ b/media/java/android/media/tv/tuner/frontend/FrontendStatusReadiness.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.tv.tuner.frontend;
+
+import android.annotation.IntDef;
+import android.annotation.IntRange;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.media.tv.tuner.frontend.FrontendStatus.FrontendStatusType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * A class contains the Frontend Status Readiness of a given type.
+ *
+ * @hide
+ */
+@SystemApi
+public class FrontendStatusReadiness {
+ /** @hide */
+ @IntDef({FRONTEND_STATUS_READINESS_UNDEFINED, FRONTEND_STATUS_READINESS_UNAVAILABLE,
+ FRONTEND_STATUS_READINESS_UNSTABLE, FRONTEND_STATUS_READINESS_STABLE,
+ FRONTEND_STATUS_READINESS_UNSUPPORTED})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Readiness {}
+
+ /**
+ * The FrontendStatus readiness status for the given FrontendStatusType is undefined.
+ */
+ public static final int FRONTEND_STATUS_READINESS_UNDEFINED =
+ android.hardware.tv.tuner.FrontendStatusReadiness.UNDEFINED;
+
+ /**
+ * The FrontendStatus for the given FrontendStatusType is currently unavailable.
+ */
+ public static final int FRONTEND_STATUS_READINESS_UNAVAILABLE =
+ android.hardware.tv.tuner.FrontendStatusReadiness.UNAVAILABLE;
+
+ /**
+ * The FrontendStatus for the given FrontendStatusType is ready to read, but it’s unstable.
+ */
+ public static final int FRONTEND_STATUS_READINESS_UNSTABLE =
+ android.hardware.tv.tuner.FrontendStatusReadiness.UNSTABLE;
+
+ /**
+ * The FrontendStatus for the given FrontendStatusType is ready to read, and it’s stable.
+ */
+ public static final int FRONTEND_STATUS_READINESS_STABLE =
+ android.hardware.tv.tuner.FrontendStatusReadiness.STABLE;
+
+ /**
+ * The FrontendStatus for the given FrontendStatusType is not supported.
+ */
+ public static final int FRONTEND_STATUS_READINESS_UNSUPPORTED =
+ android.hardware.tv.tuner.FrontendStatusReadiness.UNSUPPORTED;
+
+ @FrontendStatusType private int mFrontendStatusType;
+ @Readiness private int mStatusReadiness;
+
+ private FrontendStatusReadiness(int type, int readiness) {
+ mFrontendStatusType = type;
+ mStatusReadiness = readiness;
+ }
+
+ /**
+ * Gets the frontend status type.
+ */
+ @FrontendStatusType
+ public int getStatusType() {
+ return mFrontendStatusType;
+ }
+ /**
+ * Gets the frontend status readiness.
+ */
+ @Readiness
+ public int getStatusReadiness() {
+ return mStatusReadiness;
+ }
+}
diff --git a/media/jni/android_media_tv_Tuner.cpp b/media/jni/android_media_tv_Tuner.cpp
index 41f3a678577c9..68dd8d07750e2 100644
--- a/media/jni/android_media_tv_Tuner.cpp
+++ b/media/jni/android_media_tv_Tuner.cpp
@@ -1631,6 +1631,36 @@ jint JTuner::removeOutputPid(int32_t pid) {
return (jint)mFeClient->removeOutputPid(pid);
}
+jobjectArray JTuner::getFrontendStatusReadiness(jintArray types) {
+ if (mFeClient == nullptr) {
+ ALOGE("frontend is not initialized");
+ return nullptr;
+ }
+
+ JNIEnv *env = AndroidRuntime::getJNIEnv();
+ jsize size = env->GetArrayLength(types);
+ jint intTypes[size];
+ env->GetIntArrayRegion(types, 0, size, intTypes);
+ std::vector