Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b669c31f authored by Ray Chin's avatar Ray Chin
Browse files

Add new Tuner API applyFrontendByType

API-Coverage-Bug: 361710629
Flag: android.media.tv.flags.tuner_w_apis
Bug: 291615651
Test: cf_x86_tv-staging-userdebug
Change-Id: I04f80324813e31591c6087a9ef3264d9a1184062
parent 605ae018
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8064,6 +8064,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();
+46 −0
Original line number Diff line number Diff line
@@ -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;
@@ -2528,6 +2530,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.
     *