diff options
| author | 2024-08-27 17:00:29 +0000 | |
|---|---|---|
| committer | 2024-08-27 17:00:29 +0000 | |
| commit | 88f1c7e682fe8c15d3c003faf2433ad2a764b7e8 (patch) | |
| tree | 214ff2b60cc1c05fead2f1015bf4808c4bd82f37 | |
| parent | fc990b40b47dc6df666f56c1b080a8a1f991a372 (diff) | |
| parent | b669c31fce785988693d394ea6aa6257e572a8b0 (diff) | |
Merge "Add new Tuner API applyFrontendByType" into main
| -rw-r--r-- | core/api/system-current.txt | 1 | ||||
| -rw-r--r-- | media/java/android/media/tv/tuner/Tuner.java | 46 |
2 files changed, 47 insertions, 0 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index e1e63ccc07ae..47e12aef9926 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -8083,6 +8083,7 @@ package android.media.tv.tuner { public class Tuner implements java.lang.AutoCloseable { ctor @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) public Tuner(@NonNull android.content.Context, @Nullable String, int); method public int applyFrontend(@NonNull android.media.tv.tuner.frontend.FrontendInfo); + method @FlaggedApi("android.media.tv.flags.tuner_w_apis") @RequiresPermission(allOf={"android.permission.TUNER_RESOURCE_ACCESS", "android.permission.ACCESS_TV_TUNER"}) public int applyFrontendByType(int); method public int cancelScanning(); method public int cancelTuning(); method public void clearOnTuneEventListener(); diff --git a/media/java/android/media/tv/tuner/Tuner.java b/media/java/android/media/tv/tuner/Tuner.java index 2c71ee01b3f1..d14275ff2fd6 100644 --- a/media/java/android/media/tv/tuner/Tuner.java +++ b/media/java/android/media/tv/tuner/Tuner.java @@ -18,6 +18,7 @@ package android.media.tv.tuner; import android.annotation.BytesLong; import android.annotation.CallbackExecutor; +import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; @@ -32,6 +33,7 @@ import android.hardware.tv.tuner.Constant64Bit; import android.hardware.tv.tuner.FrontendScanType; import android.media.MediaCodec; import android.media.tv.TvInputService; +import android.media.tv.flags.Flags; import android.media.tv.tuner.dvr.DvrPlayback; import android.media.tv.tuner.dvr.DvrRecorder; import android.media.tv.tuner.dvr.OnPlaybackStatusChangedListener; @@ -2529,6 +2531,50 @@ public class Tuner implements AutoCloseable { } /** + * Request a frontend by frontend type. + * + * <p> This API is used if the applications want to select a frontend with desired type when + * there are multiple frontends of the same type is there before {@link tune}. The applied + * frontend will be one of the not in-use frontend. If all frontends are in-use, this API will + * reclaim and apply the frontend owned by the lowest priority client if current client has + * higher priority. Otherwise, this API will not apply any frontend and return + * {@link #RESULT_UNAVAILABLE}. + * + * @param desiredFrontendType the Type of the desired fronted. Should be one of + * {@link android.media.tv.tuner.frontend.FrontendSettings.Type} + * @return result status of open operation. + */ + @Result + @FlaggedApi(Flags.FLAG_TUNER_W_APIS) + @RequiresPermission( + allOf = {"android.permission.TUNER_RESOURCE_ACCESS", "android.permission.ACCESS_TV_TUNER"}) + public int applyFrontendByType(@FrontendSettings.Type int desiredFrontendType) { + mFrontendLock.lock(); + try { + if (mFeOwnerTuner != null) { + Log.e(TAG, "Operation connot be done by sharee of tuner"); + return RESULT_INVALID_STATE; + } + if (mFrontendHandle != null) { + Log.e(TAG, "A frontend has been opened before"); + return RESULT_INVALID_STATE; + } + + mDesiredFrontendId = null; + mFrontendType = desiredFrontendType; + if (DEBUG) { + Log.d(TAG, "Applying frontend with type " + mFrontendType); + } + if (!checkResource(TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND, mFrontendLock)) { + return RESULT_UNAVAILABLE; + } + return RESULT_SUCCESS; + } finally { + mFrontendLock.unlock(); + } + } + + /** * Open a shared filter instance. * * @param context the context of the caller. |