Support frontend status readiness query.
The caller could use it to check whether frontend status is ready to read or not. Bug: 171540820 Fix: 171540820 Test: atest android.media.tv.tuner.cts on AIDL and HILD HALs Change-Id: I55610e02412d6043e7fab91d1a2bf187a8e5e3ba
This commit is contained in:
@@ -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.
|
||||
*
|
||||
* <p>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()}.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user