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

Commit fbb0a99f authored by shubang's avatar shubang
Browse files

Clean up tuner constants and update according to ag/9977359

and more minor cleanups

Test: make;
Change-Id: Iaa45289edf53a0c9ec48048e0c6f1cb6caad1bd6
parent 43a8d489
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import java.lang.annotation.RetentionPolicy;
 */
public class Descrambler implements AutoCloseable {
    /** @hide */
    @IntDef(prefix = "PID_TYPE_", value = {PID_TYPE_T, PID_TYPE_MMPT})
    @IntDef(prefix = "PID_TYPE_", value = {PID_TYPE_T, PID_TYPE_MMTP})
    @Retention(RetentionPolicy.SOURCE)
    public @interface PidType {}

@@ -45,7 +45,7 @@ public class Descrambler implements AutoCloseable {
    /**
     * Packet ID is used to specify packets in MMTP.
     */
    public static final int PID_TYPE_MMPT = 2;
    public static final int PID_TYPE_MMTP = 2;


    private long mNativeContext;
+37 −3
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@ import java.lang.annotation.RetentionPolicy;
@SystemApi
public class Lnb implements AutoCloseable {
    /** @hide */
    @IntDef({VOLTAGE_NONE, VOLTAGE_5V, VOLTAGE_11V, VOLTAGE_12V, VOLTAGE_13V, VOLTAGE_14V,
    @IntDef(prefix = "VOLTAGE_",
            value = {VOLTAGE_NONE, VOLTAGE_5V, VOLTAGE_11V, VOLTAGE_12V, VOLTAGE_13V, VOLTAGE_14V,
            VOLTAGE_15V, VOLTAGE_18V, VOLTAGE_19V})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Voltage {}
@@ -83,7 +84,8 @@ public class Lnb implements AutoCloseable {
    public static final int VOLTAGE_19V = Constants.LnbVoltage.VOLTAGE_19V;

    /** @hide */
    @IntDef({TONE_NONE, TONE_CONTINUOUS})
    @IntDef(prefix = "TONE_",
            value = {TONE_NONE, TONE_CONTINUOUS})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Tone {}

@@ -97,7 +99,8 @@ public class Lnb implements AutoCloseable {
    public static final int TONE_CONTINUOUS = Constants.LnbTone.CONTINUOUS;

    /** @hide */
    @IntDef({POSITION_UNDEFINED, POSITION_A, POSITION_B})
    @IntDef(prefix = "POSITION_",
            value = {POSITION_UNDEFINED, POSITION_A, POSITION_B})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Position {}

@@ -114,6 +117,37 @@ public class Lnb implements AutoCloseable {
     */
    public static final int POSITION_B = Constants.LnbPosition.POSITION_B;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "EVENT_TYPE_",
            value = {EVENT_TYPE_DISEQC_RX_OVERFLOW, EVENT_TYPE_DISEQC_RX_TIMEOUT,
            EVENT_TYPE_DISEQC_RX_PARITY_ERROR, EVENT_TYPE_LNB_OVERLOAD})
    public @interface EventType {}

    /**
     * Outgoing Diseqc message overflow.
     * @hide
     */
    public static final int EVENT_TYPE_DISEQC_RX_OVERFLOW =
            Constants.LnbEventType.DISEQC_RX_OVERFLOW;
    /**
     * Outgoing Diseqc message isn't delivered on time.
     * @hide
     */
    public static final int EVENT_TYPE_DISEQC_RX_TIMEOUT =
            Constants.LnbEventType.DISEQC_RX_TIMEOUT;
    /**
     * Incoming Diseqc message has parity error.
     * @hide
     */
    public static final int EVENT_TYPE_DISEQC_RX_PARITY_ERROR =
            Constants.LnbEventType.DISEQC_RX_PARITY_ERROR;
    /**
     * LNB is overload.
     * @hide
     */
    public static final int EVENT_TYPE_LNB_OVERLOAD = Constants.LnbEventType.LNB_OVERLOAD;

    int mId;
    LnbCallback mCallback;
    Context mContext;
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.media.tv.tuner;


import android.media.tv.tuner.Lnb.EventType;

/**
 * Callback interface for receiving information from LNBs.
 *
@@ -26,7 +28,7 @@ public interface LnbCallback {
    /**
     * Invoked when there is a LNB event.
     */
    void onEvent(int lnbEventType);
    void onEvent(@EventType int lnbEventType);

    /**
     * Invoked when there is a new DiSEqC message.
+32 −12
Original line number Diff line number Diff line
@@ -24,13 +24,13 @@ import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.content.Context;
import android.media.tv.tuner.TunerConstants.FilterStatus;
import android.media.tv.tuner.TunerConstants.FilterSubtype;
import android.media.tv.tuner.TunerConstants.FrontendScanType;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.dvr.Dvr;
import android.media.tv.tuner.dvr.DvrCallback;
import android.media.tv.tuner.dvr.DvrSettings;
import android.media.tv.tuner.filter.FilterConfiguration.FilterType;
import android.media.tv.tuner.filter.Filter.Subtype;
import android.media.tv.tuner.filter.Filter.Type;
import android.media.tv.tuner.filter.FilterEvent;
import android.media.tv.tuner.filter.TimeFilter;
import android.media.tv.tuner.frontend.FrontendCallback;
@@ -102,7 +102,8 @@ public final class Tuner implements AutoCloseable {
     * TODO: replace the other constructor
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    public Tuner(@NonNull Context context, @NonNull String tvInputSessionId, int useCase) {
    public Tuner(@NonNull Context context, @NonNull String tvInputSessionId, int useCase,
            @Nullable OnResourceLostListener listener) {
        mContext = context;
    }

@@ -113,7 +114,8 @@ public final class Tuner implements AutoCloseable {
     *
     * @hide
     */
    public void shareFrontend(@NonNull Tuner tuner) { }
    public void shareFrontendFromTuner(@NonNull Tuner tuner) {
    }


    private long mNativeContext; // used by native jMediaTuner
@@ -513,18 +515,18 @@ public final class Tuner implements AutoCloseable {
     * @param subType the subtype of the filter.
     * @param bufferSize the buffer size of the filter to be opened in bytes. The buffer holds the
     * data output from the filter.
     * @param cb the callback to receive notifications from filter.
     * @param executor the executor on which callback will be invoked. The default event handler
     * executor is used if it's {@code null}.
     * @param cb the callback to receive notifications from filter.
     * @return the opened filter. {@code null} if the operation failed.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @Nullable
    public Filter openFilter(@FilterType int mainType, @FilterSubtype int subType,
            @BytesLong long bufferSize, @Nullable FilterCallback cb,
            @CallbackExecutor @Nullable Executor executor) {
    public Filter openFilter(@Type int mainType, @Subtype int subType,
            @BytesLong long bufferSize, @CallbackExecutor @Nullable Executor executor,
            @Nullable FilterCallback cb) {
        TunerUtils.checkTunerPermission(mContext);
        Filter filter = nativeOpenFilter(
                mainType, TunerUtils.getFilterSubtype(mainType, subType), bufferSize);
@@ -540,16 +542,34 @@ public final class Tuner implements AutoCloseable {
    /**
     * Opens an LNB (low-noise block downconverter) object.
     *
     * @param executor the executor on which callback will be invoked. The default event handler
     * executor is used if it's {@code null}.
     * @param cb the callback to receive notifications from LNB.
     * @return the opened LNB object. {@code null} if the operation failed.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @Nullable
    public Lnb openLnb(@CallbackExecutor @Nullable Executor executor, LnbCallback cb) {
        return openLnbByName(null, executor, cb);
    }

    /**
     * Opens an LNB (low-noise block downconverter) object.
     *
     * @param name the LNB name.
     * @param executor the executor on which callback will be invoked. The default event handler
     * executor is used if it's {@code null}.
     * @param cb the callback to receive notifications from LNB.
     * @return the opened LNB object. {@code null} if the operation failed.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @Nullable
    public Lnb openLnb(LnbCallback cb, @CallbackExecutor @Nullable Executor executor) {
    public Lnb openLnbByName(@Nullable String name, @CallbackExecutor @Nullable Executor executor,
            LnbCallback cb) {
        TunerUtils.checkTunerPermission(mContext);
        // TODO: use resource manager to get LNB ID.
        return new Lnb(0);
@@ -608,17 +628,17 @@ public final class Tuner implements AutoCloseable {
     * @param type the DVR type to be opened.
     * @param bufferSize the buffer size of the output in bytes. It's used to hold output data of
     * the attached filters.
     * @param cb the callback to receive notifications from DVR.
     * @param executor the executor on which callback will be invoked. The default event handler
     * executor is used if it's {@code null}.
     * @param cb the callback to receive notifications from DVR.
     * @return the opened DVR object. {@code null} if the operation failed.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER)
    @Nullable
    public Dvr openDvr(@DvrSettings.Type int type, @BytesLong long bufferSize, DvrCallback cb,
            @CallbackExecutor @Nullable Executor executor) {
    public Dvr openDvr(@DvrSettings.Type int type, @BytesLong long bufferSize,
            @CallbackExecutor @Nullable Executor executor, DvrCallback cb) {
        TunerUtils.checkTunerPermission(mContext);
        Dvr dvr = nativeOpenDvr(type, bufferSize);
        return dvr;
+23 −67
Original line number Diff line number Diff line
@@ -36,68 +36,41 @@ import java.lang.annotation.RetentionPolicy;
 */
@SystemApi
public final class TunerConstants {
    /** @hide */
    /**
     * Invalid TS packet ID.
     * @hide
     */
    public static final int INVALID_TS_PID = Constants.Constant.INVALID_TS_PID;
    /** @hide */
    /**
     * Invalid stream ID.
     * @hide
     */
    public static final int INVALID_STREAM_ID = Constants.Constant.INVALID_STREAM_ID;


    /** @hide */
    @IntDef({FRONTEND_EVENT_TYPE_LOCKED, FRONTEND_EVENT_TYPE_NO_SIGNAL,
    @IntDef(prefix = "FRONTEND_EVENT_TYPE_",
            value = {FRONTEND_EVENT_TYPE_LOCKED, FRONTEND_EVENT_TYPE_NO_SIGNAL,
                    FRONTEND_EVENT_TYPE_LOST_LOCK})
    @Retention(RetentionPolicy.SOURCE)
    public @interface FrontendEventType {}
    /** @hide */
    /**
     * Frontend locked.
     * @hide
     */
    public static final int FRONTEND_EVENT_TYPE_LOCKED = Constants.FrontendEventType.LOCKED;
    /** @hide */
    /**
     * No signal detected.
     * @hide
     */
    public static final int FRONTEND_EVENT_TYPE_NO_SIGNAL = Constants.FrontendEventType.NO_SIGNAL;
    /** @hide */
    /**
     * Frontend lock lost.
     * @hide
     */
    public static final int FRONTEND_EVENT_TYPE_LOST_LOCK = Constants.FrontendEventType.LOST_LOCK;


    /** @hide */
    @IntDef({FILTER_SUBTYPE_UNDEFINED, FILTER_SUBTYPE_SECTION, FILTER_SUBTYPE_PES,
            FILTER_SUBTYPE_AUDIO, FILTER_SUBTYPE_VIDEO, FILTER_SUBTYPE_DOWNLOAD,
            FILTER_SUBTYPE_RECORD, FILTER_SUBTYPE_TS, FILTER_SUBTYPE_PCR, FILTER_SUBTYPE_TEMI,
            FILTER_SUBTYPE_MMPT, FILTER_SUBTYPE_NTP, FILTER_SUBTYPE_IP_PAYLOAD, FILTER_SUBTYPE_IP,
            FILTER_SUBTYPE_PAYLOAD_THROUGH, FILTER_SUBTYPE_TLV, FILTER_SUBTYPE_PTP, })
    @Retention(RetentionPolicy.SOURCE)
    public @interface FilterSubtype {}
    /** @hide */
    public static final int FILTER_SUBTYPE_UNDEFINED = 0;
    /** @hide */
    public static final int FILTER_SUBTYPE_SECTION = 1;
    /** @hide */
    public static final int FILTER_SUBTYPE_PES = 2;
    /** @hide */
    public static final int FILTER_SUBTYPE_AUDIO = 3;
    /** @hide */
    public static final int FILTER_SUBTYPE_VIDEO = 4;
    /** @hide */
    public static final int FILTER_SUBTYPE_DOWNLOAD = 5;
    /** @hide */
    public static final int FILTER_SUBTYPE_RECORD = 6;
    /** @hide */
    public static final int FILTER_SUBTYPE_TS = 7;
    /** @hide */
    public static final int FILTER_SUBTYPE_PCR = 8;
    /** @hide */
    public static final int FILTER_SUBTYPE_TEMI = 9;
    /** @hide */
    public static final int FILTER_SUBTYPE_MMPT = 10;
    /** @hide */
    public static final int FILTER_SUBTYPE_NTP = 11;
    /** @hide */
    public static final int FILTER_SUBTYPE_IP_PAYLOAD = 12;
    /** @hide */
    public static final int FILTER_SUBTYPE_IP = 13;
    /** @hide */
    public static final int FILTER_SUBTYPE_PAYLOAD_THROUGH = 14;
    /** @hide */
    public static final int FILTER_SUBTYPE_TLV = 15;
    /** @hide */
    public static final int FILTER_SUBTYPE_PTP = 16;

    /** @hide */
    @IntDef(flag = true, prefix = "FILTER_STATUS_", value = {FILTER_STATUS_DATA_READY,
            FILTER_STATUS_LOW_WATER, FILTER_STATUS_HIGH_WATER, FILTER_STATUS_OVERFLOW})
@@ -501,23 +474,6 @@ public final class TunerConstants {
    public @interface FrontendModulation {}


    /** @hide */
    @IntDef({FILTER_SETTINGS_TS, FILTER_SETTINGS_MMTP, FILTER_SETTINGS_IP, FILTER_SETTINGS_TLV,
            FILTER_SETTINGS_ALP})
    @Retention(RetentionPolicy.SOURCE)
    public @interface FilterSettingsType {}
    /** @hide */
    public static final int FILTER_SETTINGS_TS = Constants.DemuxFilterMainType.TS;
    /** @hide */
    public static final int FILTER_SETTINGS_MMTP = Constants.DemuxFilterMainType.MMTP;
    /** @hide */
    public static final int FILTER_SETTINGS_IP = Constants.DemuxFilterMainType.IP;
    /** @hide */
    public static final int FILTER_SETTINGS_TLV = Constants.DemuxFilterMainType.TLV;
    /** @hide */
    public static final int FILTER_SETTINGS_ALP = Constants.DemuxFilterMainType.ALP;


    /** @hide */
    @IntDef({RESULT_SUCCESS, RESULT_UNAVAILABLE, RESULT_NOT_INITIALIZED, RESULT_INVALID_STATE,
            RESULT_INVALID_ARGUMENT, RESULT_OUT_OF_MEMORY, RESULT_UNKNOWN_ERROR})
Loading