• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.media.tv.tuner.frontend;
18 
19 import android.annotation.IntDef;
20 import android.annotation.IntRange;
21 import android.annotation.NonNull;
22 import android.annotation.SystemApi;
23 import android.hardware.tv.tuner.V1_0.Constants;
24 import android.media.tv.tuner.Lnb;
25 import android.media.tv.tuner.TunerVersionChecker;
26 
27 import java.lang.annotation.Retention;
28 import java.lang.annotation.RetentionPolicy;
29 
30 /**
31  * A Frontend Status class that contains the metrics of the active frontend.
32  *
33  * @hide
34  */
35 @SystemApi
36 public class FrontendStatus {
37 
38     /** @hide */
39     @IntDef({FRONTEND_STATUS_TYPE_DEMOD_LOCK, FRONTEND_STATUS_TYPE_SNR, FRONTEND_STATUS_TYPE_BER,
40             FRONTEND_STATUS_TYPE_PER, FRONTEND_STATUS_TYPE_PRE_BER,
41             FRONTEND_STATUS_TYPE_SIGNAL_QUALITY, FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH,
42             FRONTEND_STATUS_TYPE_SYMBOL_RATE, FRONTEND_STATUS_TYPE_FEC,
43             FRONTEND_STATUS_TYPE_MODULATION, FRONTEND_STATUS_TYPE_SPECTRAL,
44             FRONTEND_STATUS_TYPE_LNB_VOLTAGE, FRONTEND_STATUS_TYPE_PLP_ID,
45             FRONTEND_STATUS_TYPE_EWBS, FRONTEND_STATUS_TYPE_AGC, FRONTEND_STATUS_TYPE_LNA,
46             FRONTEND_STATUS_TYPE_LAYER_ERROR, FRONTEND_STATUS_TYPE_MER,
47             FRONTEND_STATUS_TYPE_FREQ_OFFSET, FRONTEND_STATUS_TYPE_HIERARCHY,
48             FRONTEND_STATUS_TYPE_RF_LOCK, FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO,
49             FRONTEND_STATUS_TYPE_BERS, FRONTEND_STATUS_TYPE_CODERATES,
50             FRONTEND_STATUS_TYPE_BANDWIDTH, FRONTEND_STATUS_TYPE_GUARD_INTERVAL,
51             FRONTEND_STATUS_TYPE_TRANSMISSION_MODE, FRONTEND_STATUS_TYPE_UEC,
52             FRONTEND_STATUS_TYPE_T2_SYSTEM_ID, FRONTEND_STATUS_TYPE_INTERLEAVINGS,
53             FRONTEND_STATUS_TYPE_ISDBT_SEGMENTS, FRONTEND_STATUS_TYPE_TS_DATA_RATES,
54             FRONTEND_STATUS_TYPE_MODULATIONS_EXT, FRONTEND_STATUS_TYPE_ROLL_OFF,
55             FRONTEND_STATUS_TYPE_IS_MISO_ENABLED, FRONTEND_STATUS_TYPE_IS_LINEAR,
56             FRONTEND_STATUS_TYPE_IS_SHORT_FRAMES_ENABLED})
57     @Retention(RetentionPolicy.SOURCE)
58     public @interface FrontendStatusType {}
59 
60     /**
61      * Lock status for Demod.
62      */
63     public static final int FRONTEND_STATUS_TYPE_DEMOD_LOCK =
64             Constants.FrontendStatusType.DEMOD_LOCK;
65     /**
66      * Signal to Noise Ratio.
67      */
68     public static final int FRONTEND_STATUS_TYPE_SNR = Constants.FrontendStatusType.SNR;
69     /**
70      * Bit Error Ratio.
71      */
72     public static final int FRONTEND_STATUS_TYPE_BER = Constants.FrontendStatusType.BER;
73     /**
74      * Packages Error Ratio.
75      */
76     public static final int FRONTEND_STATUS_TYPE_PER = Constants.FrontendStatusType.PER;
77     /**
78      * Bit Error Ratio before FEC.
79      */
80     public static final int FRONTEND_STATUS_TYPE_PRE_BER = Constants.FrontendStatusType.PRE_BER;
81     /**
82      * Signal Quality (0..100). Good data over total data in percent can be
83      * used as a way to present Signal Quality.
84      */
85     public static final int FRONTEND_STATUS_TYPE_SIGNAL_QUALITY =
86             Constants.FrontendStatusType.SIGNAL_QUALITY;
87     /**
88      * Signal Strength.
89      */
90     public static final int FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH =
91             Constants.FrontendStatusType.SIGNAL_STRENGTH;
92     /**
93      * Symbol Rate in symbols per second.
94      */
95     public static final int FRONTEND_STATUS_TYPE_SYMBOL_RATE =
96             Constants.FrontendStatusType.SYMBOL_RATE;
97     /**
98      * Forward Error Correction Type.
99      */
100     public static final int FRONTEND_STATUS_TYPE_FEC = Constants.FrontendStatusType.FEC;
101     /**
102      * Modulation Type.
103      */
104     public static final int FRONTEND_STATUS_TYPE_MODULATION =
105             Constants.FrontendStatusType.MODULATION;
106     /**
107      * Spectral Inversion Type.
108      */
109     public static final int FRONTEND_STATUS_TYPE_SPECTRAL = Constants.FrontendStatusType.SPECTRAL;
110     /**
111      * LNB Voltage.
112      */
113     public static final int FRONTEND_STATUS_TYPE_LNB_VOLTAGE =
114             Constants.FrontendStatusType.LNB_VOLTAGE;
115     /**
116      * Physical Layer Pipe ID.
117      */
118     public static final int FRONTEND_STATUS_TYPE_PLP_ID = Constants.FrontendStatusType.PLP_ID;
119     /**
120      * Status for Emergency Warning Broadcasting System.
121      */
122     public static final int FRONTEND_STATUS_TYPE_EWBS = Constants.FrontendStatusType.EWBS;
123     /**
124      * Automatic Gain Control.
125      */
126     public static final int FRONTEND_STATUS_TYPE_AGC = Constants.FrontendStatusType.AGC;
127     /**
128      * Low Noise Amplifier.
129      */
130     public static final int FRONTEND_STATUS_TYPE_LNA = Constants.FrontendStatusType.LNA;
131     /**
132      * Error status by layer.
133      */
134     public static final int FRONTEND_STATUS_TYPE_LAYER_ERROR =
135             Constants.FrontendStatusType.LAYER_ERROR;
136     /**
137      * Modulation Error Ratio.
138      */
139     public static final int FRONTEND_STATUS_TYPE_MER = Constants.FrontendStatusType.MER;
140     /**
141      * Difference between tuning frequency and actual locked frequency.
142      */
143     public static final int FRONTEND_STATUS_TYPE_FREQ_OFFSET =
144             Constants.FrontendStatusType.FREQ_OFFSET;
145     /**
146      * Hierarchy for DVBT.
147      */
148     public static final int FRONTEND_STATUS_TYPE_HIERARCHY = Constants.FrontendStatusType.HIERARCHY;
149     /**
150      * Lock status for RF.
151      */
152     public static final int FRONTEND_STATUS_TYPE_RF_LOCK = Constants.FrontendStatusType.RF_LOCK;
153     /**
154      * PLP information in a frequency band for ATSC-3.0 frontend.
155      */
156     public static final int FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO =
157             Constants.FrontendStatusType.ATSC3_PLP_INFO;
158     /**
159      * BERS Type. Only supported in Tuner HAL 1.1 or higher.
160      */
161     public static final int FRONTEND_STATUS_TYPE_BERS =
162             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.BERS;
163     /**
164      * Coderate Type. Only supported in Tuner HAL 1.1 or higher.
165      */
166     public static final int FRONTEND_STATUS_TYPE_CODERATES =
167             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.CODERATES;
168     /**
169      * Bandwidth Type. Only supported in Tuner HAL 1.1 or higher.
170      */
171     public static final int FRONTEND_STATUS_TYPE_BANDWIDTH =
172             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.BANDWIDTH;
173     /**
174      * Guard Interval Type. Only supported in Tuner HAL 1.1 or higher.
175      */
176     public static final int FRONTEND_STATUS_TYPE_GUARD_INTERVAL =
177             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.GUARD_INTERVAL;
178     /**
179      * Transmission Mode Type. Only supported in Tuner HAL 1.1 or higher.
180      */
181     public static final int FRONTEND_STATUS_TYPE_TRANSMISSION_MODE =
182             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.TRANSMISSION_MODE;
183     /**
184      * UEC Type. Only supported in Tuner HAL 1.1 or higher.
185      */
186     public static final int FRONTEND_STATUS_TYPE_UEC =
187             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.UEC;
188     /**
189      * T2 System Id Type. Only supported in Tuner HAL 1.1 or higher.
190      */
191     public static final int FRONTEND_STATUS_TYPE_T2_SYSTEM_ID =
192             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.T2_SYSTEM_ID;
193     /**
194      * Interleavings Type. Only supported in Tuner HAL 1.1 or higher.
195      */
196     public static final int FRONTEND_STATUS_TYPE_INTERLEAVINGS =
197             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.INTERLEAVINGS;
198     /**
199      * ISDBT Segments Type. Only supported in Tuner HAL 1.1 or higher.
200      */
201     public static final int FRONTEND_STATUS_TYPE_ISDBT_SEGMENTS =
202             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.ISDBT_SEGMENTS;
203     /**
204      * TS Data Rates Type. Only supported in Tuner HAL 1.1 or higher.
205      */
206     public static final int FRONTEND_STATUS_TYPE_TS_DATA_RATES =
207             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.TS_DATA_RATES;
208     /**
209      * Extended Modulations Type. Only supported in Tuner HAL 1.1 or higher.
210      */
211     public static final int FRONTEND_STATUS_TYPE_MODULATIONS_EXT =
212             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.MODULATIONS;
213     /**
214      * Roll Off Type status of the frontend. Only supported in Tuner HAL 1.1 or higher.
215      */
216     public static final int FRONTEND_STATUS_TYPE_ROLL_OFF =
217             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.ROLL_OFF;
218     /**
219      * If the frontend currently supports MISO or not. Only supported in Tuner HAL 1.1 or higher.
220      */
221     public static final int FRONTEND_STATUS_TYPE_IS_MISO_ENABLED =
222             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.IS_MISO;
223     /**
224      * If the frontend code rate is linear or not. Only supported in Tuner HAL 1.1 or higher.
225      */
226     public static final int FRONTEND_STATUS_TYPE_IS_LINEAR =
227             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.IS_LINEAR;
228     /**
229      * If short frames is enabled or not. Only supported in Tuner HAL 1.1 or higher.
230      */
231     public static final int FRONTEND_STATUS_TYPE_IS_SHORT_FRAMES_ENABLED =
232             android.hardware.tv.tuner.V1_1.Constants.FrontendStatusTypeExt1_1.IS_SHORT_FRAMES;
233 
234     /** @hide */
235     @IntDef(value = {
236             AtscFrontendSettings.MODULATION_UNDEFINED,
237             AtscFrontendSettings.MODULATION_AUTO,
238             AtscFrontendSettings.MODULATION_MOD_8VSB,
239             AtscFrontendSettings.MODULATION_MOD_16VSB,
240             Atsc3FrontendSettings.MODULATION_UNDEFINED,
241             Atsc3FrontendSettings.MODULATION_AUTO,
242             Atsc3FrontendSettings.MODULATION_MOD_QPSK,
243             Atsc3FrontendSettings.MODULATION_MOD_16QAM,
244             Atsc3FrontendSettings.MODULATION_MOD_64QAM,
245             Atsc3FrontendSettings.MODULATION_MOD_256QAM,
246             Atsc3FrontendSettings.MODULATION_MOD_1024QAM,
247             Atsc3FrontendSettings.MODULATION_MOD_4096QAM,
248             DtmbFrontendSettings.MODULATION_CONSTELLATION_UNDEFINED,
249             DtmbFrontendSettings.MODULATION_CONSTELLATION_AUTO,
250             DtmbFrontendSettings.MODULATION_CONSTELLATION_4QAM,
251             DtmbFrontendSettings.MODULATION_CONSTELLATION_4QAM_NR,
252             DtmbFrontendSettings.MODULATION_CONSTELLATION_16QAM,
253             DtmbFrontendSettings.MODULATION_CONSTELLATION_32QAM,
254             DtmbFrontendSettings.MODULATION_CONSTELLATION_64QAM,
255             DvbcFrontendSettings.MODULATION_UNDEFINED,
256             DvbcFrontendSettings.MODULATION_AUTO,
257             DvbcFrontendSettings.MODULATION_MOD_16QAM,
258             DvbcFrontendSettings.MODULATION_MOD_32QAM,
259             DvbcFrontendSettings.MODULATION_MOD_64QAM,
260             DvbcFrontendSettings.MODULATION_MOD_128QAM,
261             DvbcFrontendSettings.MODULATION_MOD_256QAM,
262             DvbsFrontendSettings.MODULATION_UNDEFINED,
263             DvbsFrontendSettings.MODULATION_AUTO,
264             DvbsFrontendSettings.MODULATION_MOD_QPSK,
265             DvbsFrontendSettings.MODULATION_MOD_8PSK,
266             DvbsFrontendSettings.MODULATION_MOD_16QAM,
267             DvbsFrontendSettings.MODULATION_MOD_16PSK,
268             DvbsFrontendSettings.MODULATION_MOD_32PSK,
269             DvbsFrontendSettings.MODULATION_MOD_ACM,
270             DvbsFrontendSettings.MODULATION_MOD_8APSK,
271             DvbsFrontendSettings.MODULATION_MOD_16APSK,
272             DvbsFrontendSettings.MODULATION_MOD_32APSK,
273             DvbsFrontendSettings.MODULATION_MOD_64APSK,
274             DvbsFrontendSettings.MODULATION_MOD_128APSK,
275             DvbsFrontendSettings.MODULATION_MOD_256APSK,
276             DvbsFrontendSettings.MODULATION_MOD_RESERVED,
277             DvbtFrontendSettings.CONSTELLATION_UNDEFINED,
278             DvbtFrontendSettings.CONSTELLATION_AUTO,
279             DvbtFrontendSettings.CONSTELLATION_QPSK,
280             DvbtFrontendSettings.CONSTELLATION_16QAM,
281             DvbtFrontendSettings.CONSTELLATION_64QAM,
282             DvbtFrontendSettings.CONSTELLATION_256QAM,
283             DvbtFrontendSettings.CONSTELLATION_QPSK_R,
284             DvbtFrontendSettings.CONSTELLATION_16QAM_R,
285             DvbtFrontendSettings.CONSTELLATION_64QAM_R,
286             DvbtFrontendSettings.CONSTELLATION_256QAM_R,
287             IsdbsFrontendSettings.MODULATION_UNDEFINED,
288             IsdbsFrontendSettings.MODULATION_AUTO,
289             IsdbsFrontendSettings.MODULATION_MOD_BPSK,
290             IsdbsFrontendSettings.MODULATION_MOD_QPSK,
291             IsdbsFrontendSettings.MODULATION_MOD_TC8PSK,
292             Isdbs3FrontendSettings.MODULATION_UNDEFINED,
293             Isdbs3FrontendSettings.MODULATION_AUTO,
294             Isdbs3FrontendSettings.MODULATION_MOD_BPSK,
295             Isdbs3FrontendSettings.MODULATION_MOD_QPSK,
296             Isdbs3FrontendSettings.MODULATION_MOD_8PSK,
297             Isdbs3FrontendSettings.MODULATION_MOD_16APSK,
298             Isdbs3FrontendSettings.MODULATION_MOD_32APSK,
299             IsdbtFrontendSettings.MODULATION_UNDEFINED,
300             IsdbtFrontendSettings.MODULATION_AUTO,
301             IsdbtFrontendSettings.MODULATION_MOD_DQPSK,
302             IsdbtFrontendSettings.MODULATION_MOD_QPSK,
303             IsdbtFrontendSettings.MODULATION_MOD_16QAM,
304             IsdbtFrontendSettings.MODULATION_MOD_64QAM})
305     @Retention(RetentionPolicy.SOURCE)
306     public @interface FrontendModulation {}
307 
308     /** @hide */
309     @IntDef(value = {
310             Atsc3FrontendSettings.TIME_INTERLEAVE_MODE_UNDEFINED,
311             Atsc3FrontendSettings.TIME_INTERLEAVE_MODE_AUTO,
312             Atsc3FrontendSettings.TIME_INTERLEAVE_MODE_CTI,
313             Atsc3FrontendSettings.TIME_INTERLEAVE_MODE_HTI,
314             DtmbFrontendSettings.TIME_INTERLEAVE_MODE_UNDEFINED,
315             DtmbFrontendSettings.TIME_INTERLEAVE_MODE_AUTO,
316             DtmbFrontendSettings.TIME_INTERLEAVE_MODE_TIMER_INT_240,
317             DtmbFrontendSettings.TIME_INTERLEAVE_MODE_TIMER_INT_720,
318             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_UNDEFINED,
319             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_AUTO,
320             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_1_0,
321             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_1_1,
322             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_64_2,
323             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_32_4,
324             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_16_8,
325             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_8_16,
326             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_2,
327             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_3,
328             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_4})
329     @Retention(RetentionPolicy.SOURCE)
330     public @interface FrontendInterleaveMode {}
331 
332     /** @hide */
333     @IntDef(value = {
334             Atsc3FrontendSettings.BANDWIDTH_UNDEFINED,
335             Atsc3FrontendSettings.BANDWIDTH_AUTO,
336             Atsc3FrontendSettings.BANDWIDTH_BANDWIDTH_6MHZ,
337             Atsc3FrontendSettings.BANDWIDTH_BANDWIDTH_7MHZ,
338             Atsc3FrontendSettings.BANDWIDTH_BANDWIDTH_8MHZ,
339             DtmbFrontendSettings.BANDWIDTH_UNDEFINED,
340             DtmbFrontendSettings.BANDWIDTH_AUTO,
341             DtmbFrontendSettings.BANDWIDTH_6MHZ,
342             DtmbFrontendSettings.BANDWIDTH_8MHZ,
343             DvbtFrontendSettings.BANDWIDTH_UNDEFINED,
344             DvbtFrontendSettings.BANDWIDTH_AUTO,
345             DvbtFrontendSettings.BANDWIDTH_8MHZ,
346             DvbtFrontendSettings.BANDWIDTH_7MHZ,
347             DvbtFrontendSettings.BANDWIDTH_6MHZ,
348             DvbtFrontendSettings.BANDWIDTH_5MHZ,
349             DvbtFrontendSettings.BANDWIDTH_1_7MHZ,
350             DvbtFrontendSettings.BANDWIDTH_10MHZ,
351             IsdbtFrontendSettings.BANDWIDTH_UNDEFINED,
352             IsdbtFrontendSettings.BANDWIDTH_AUTO,
353             IsdbtFrontendSettings.BANDWIDTH_8MHZ,
354             IsdbtFrontendSettings.BANDWIDTH_7MHZ,
355             IsdbtFrontendSettings.BANDWIDTH_6MHZ})
356     @Retention(RetentionPolicy.SOURCE)
357     public @interface FrontendBandwidth {}
358 
359     /** @hide */
360     @IntDef(value = {
361             DtmbFrontendSettings.TRANSMISSION_MODE_UNDEFINED,
362             DtmbFrontendSettings.TRANSMISSION_MODE_AUTO,
363             DtmbFrontendSettings.TRANSMISSION_MODE_C1,
364             DtmbFrontendSettings.TRANSMISSION_MODE_C3780,
365             DvbtFrontendSettings.TRANSMISSION_MODE_UNDEFINED,
366             DvbtFrontendSettings.TRANSMISSION_MODE_AUTO,
367             DvbtFrontendSettings.TRANSMISSION_MODE_2K,
368             DvbtFrontendSettings.TRANSMISSION_MODE_8K,
369             DvbtFrontendSettings.TRANSMISSION_MODE_4K,
370             DvbtFrontendSettings.TRANSMISSION_MODE_1K,
371             DvbtFrontendSettings.TRANSMISSION_MODE_16K,
372             DvbtFrontendSettings.TRANSMISSION_MODE_32K,
373             IsdbtFrontendSettings.MODE_UNDEFINED,
374             IsdbtFrontendSettings.MODE_AUTO,
375             IsdbtFrontendSettings.MODE_1,
376             IsdbtFrontendSettings.MODE_2,
377             IsdbtFrontendSettings.MODE_3})
378     @Retention(RetentionPolicy.SOURCE)
379     public @interface FrontendTransmissionMode {}
380 
381     /** @hide */
382     @IntDef(value = {
383             DtmbFrontendSettings.GUARD_INTERVAL_UNDEFINED,
384             DtmbFrontendSettings.GUARD_INTERVAL_AUTO,
385             DtmbFrontendSettings.GUARD_INTERVAL_PN_420_VARIOUS,
386             DtmbFrontendSettings.GUARD_INTERVAL_PN_595_CONST,
387             DtmbFrontendSettings.GUARD_INTERVAL_PN_945_VARIOUS,
388             DtmbFrontendSettings.GUARD_INTERVAL_PN_420_CONST,
389             DtmbFrontendSettings.GUARD_INTERVAL_PN_945_CONST,
390             DtmbFrontendSettings.GUARD_INTERVAL_PN_RESERVED,
391             DvbtFrontendSettings.GUARD_INTERVAL_UNDEFINED,
392             DvbtFrontendSettings.GUARD_INTERVAL_AUTO,
393             DvbtFrontendSettings.GUARD_INTERVAL_1_32,
394             DvbtFrontendSettings.GUARD_INTERVAL_1_16,
395             DvbtFrontendSettings.GUARD_INTERVAL_1_8,
396             DvbtFrontendSettings.GUARD_INTERVAL_1_4,
397             DvbtFrontendSettings.GUARD_INTERVAL_1_128,
398             DvbtFrontendSettings.GUARD_INTERVAL_19_128,
399             DvbtFrontendSettings.GUARD_INTERVAL_19_256,
400             DvbtFrontendSettings.GUARD_INTERVAL_19_128})
401     @Retention(RetentionPolicy.SOURCE)
402     public @interface FrontendGuardInterval {}
403 
404     /** @hide */
405     @IntDef(value = {
406             DvbsFrontendSettings.ROLLOFF_UNDEFINED,
407             DvbsFrontendSettings.ROLLOFF_0_35,
408             DvbsFrontendSettings.ROLLOFF_0_25,
409             DvbsFrontendSettings.ROLLOFF_0_20,
410             DvbsFrontendSettings.ROLLOFF_0_15,
411             DvbsFrontendSettings.ROLLOFF_0_10,
412             DvbsFrontendSettings.ROLLOFF_0_5,
413             Isdbs3FrontendSettings.ROLLOFF_UNDEFINED,
414             Isdbs3FrontendSettings.ROLLOFF_0_03,
415             IsdbsFrontendSettings.ROLLOFF_UNDEFINED,
416             IsdbsFrontendSettings.ROLLOFF_0_35})
417     @Retention(RetentionPolicy.SOURCE)
418     public @interface FrontendRollOff {}
419 
420     private Boolean mIsDemodLocked;
421     private Integer mSnr;
422     private Integer mBer;
423     private Integer mPer;
424     private Integer mPerBer;
425     private Integer mSignalQuality;
426     private Integer mSignalStrength;
427     private Integer mSymbolRate;
428     private Long mInnerFec;
429     private Integer mModulation;
430     private Integer mInversion;
431     private Integer mLnbVoltage;
432     private Integer mPlpId;
433     private Boolean mIsEwbs;
434     private Integer mAgc;
435     private Boolean mIsLnaOn;
436     private boolean[] mIsLayerErrors;
437     private Integer mMer;
438     private Integer mFreqOffset;
439     private Integer mHierarchy;
440     private Boolean mIsRfLocked;
441     private Atsc3PlpTuningInfo[] mPlpInfo;
442     private int[] mBers;
443     private int[] mCodeRates;
444     private Integer mBandwidth;
445     private Integer mGuardInterval;
446     private Integer mTransmissionMode;
447     private Integer mUec;
448     private Integer mSystemId;
449     private int[] mInterleaving;
450     private int[] mTsDataRate;
451     private int[] mIsdbtSegment;
452     private int[] mModulationsExt;
453     private Integer mRollOff;
454     private Boolean mIsMisoEnabled;
455     private Boolean mIsLinear;
456     private Boolean mIsShortFrames;
457 
458 
459     // Constructed and fields set by JNI code.
FrontendStatus()460     private FrontendStatus() {
461     }
462 
463     /**
464      * Gets if the demod is currently locked or not.
465      */
isDemodLocked()466     public boolean isDemodLocked() {
467         if (mIsDemodLocked == null) {
468             throw new IllegalStateException("DemodLocked status is empty");
469         }
470         return mIsDemodLocked;
471     }
472     /**
473      * Gets the current Signal to Noise Ratio in thousandths of a deciBel (0.001dB).
474      */
getSnr()475     public int getSnr() {
476         if (mSnr == null) {
477             throw new IllegalStateException("Snr status is empty");
478         }
479         return mSnr;
480     }
481     /**
482      * Gets the current Bit Error Ratio.
483      *
484      * <p>The number of error bit per 1 billion bits.
485      */
getBer()486     public int getBer() {
487         if (mBer == null) {
488             throw new IllegalStateException("Ber status is empty");
489         }
490         return mBer;
491     }
492 
493     /**
494      * Gets the current Packages Error Ratio.
495      *
496      * <p>The number of error package per 1 billion packages.
497      */
getPer()498     public int getPer() {
499         if (mPer == null) {
500             throw new IllegalStateException("Per status is empty");
501         }
502         return mPer;
503     }
504     /**
505      * Gets the current Bit Error Ratio before Forward Error Correction (FEC).
506      *
507      * <p>The number of error bit per 1 billion bits before FEC.
508      */
getPerBer()509     public int getPerBer() {
510         if (mPerBer == null) {
511             throw new IllegalStateException("PerBer status is empty");
512         }
513         return mPerBer;
514     }
515     /**
516      * Gets the current Signal Quality in percent.
517      */
getSignalQuality()518     public int getSignalQuality() {
519         if (mSignalQuality == null) {
520             throw new IllegalStateException("SignalQuality status is empty");
521         }
522         return mSignalQuality;
523     }
524     /**
525      * Gets the current Signal Strength in thousandths of a dBm (0.001dBm).
526      */
getSignalStrength()527     public int getSignalStrength() {
528         if (mSignalStrength == null) {
529             throw new IllegalStateException("SignalStrength status is empty");
530         }
531         return mSignalStrength;
532     }
533     /**
534      * Gets the current symbol rate in symbols per second.
535      */
getSymbolRate()536     public int getSymbolRate() {
537         if (mSymbolRate == null) {
538             throw new IllegalStateException("SymbolRate status is empty");
539         }
540         return mSymbolRate;
541     }
542     /**
543      *  Gets the current Inner Forward Error Correction type as specified in ETSI EN 300 468 V1.15.1
544      *  and ETSI EN 302 307-2 V1.1.1.
545      */
546     @FrontendSettings.InnerFec
getInnerFec()547     public long getInnerFec() {
548         if (mInnerFec == null) {
549             throw new IllegalStateException("InnerFec status is empty");
550         }
551         return mInnerFec;
552     }
553     /**
554      * Gets the currently modulation information.
555      */
556     @FrontendModulation
getModulation()557     public int getModulation() {
558         if (mModulation == null) {
559             throw new IllegalStateException("Modulation status is empty");
560         }
561         return mModulation;
562     }
563     /**
564      * Gets the currently Spectral Inversion information for DVBC.
565      */
566     @FrontendSettings.FrontendSpectralInversion
getSpectralInversion()567     public int getSpectralInversion() {
568         if (mInversion == null) {
569             throw new IllegalStateException("SpectralInversion status is empty");
570         }
571         return mInversion;
572     }
573     /**
574      * Gets the current Power Voltage Type for LNB.
575      */
576     @Lnb.Voltage
getLnbVoltage()577     public int getLnbVoltage() {
578         if (mLnbVoltage == null) {
579             throw new IllegalStateException("LnbVoltage status is empty");
580         }
581         return mLnbVoltage;
582     }
583     /**
584      * Gets the current Physical Layer Pipe ID.
585      */
getPlpId()586     public int getPlpId() {
587         if (mPlpId == null) {
588             throw new IllegalStateException("PlpId status is empty");
589         }
590         return mPlpId;
591     }
592     /**
593      * Checks whether it's Emergency Warning Broadcasting System
594      */
isEwbs()595     public boolean isEwbs() {
596         if (mIsEwbs == null) {
597             throw new IllegalStateException("Ewbs status is empty");
598         }
599         return mIsEwbs;
600     }
601     /**
602      * Gets the current Automatic Gain Control value which is normalized from 0 to 255.
603      */
getAgc()604     public int getAgc() {
605         if (mAgc == null) {
606             throw new IllegalStateException("Agc status is empty");
607         }
608         return mAgc;
609     }
610     /**
611      * Checks LNA (Low Noise Amplifier) is on or not.
612      */
isLnaOn()613     public boolean isLnaOn() {
614         if (mIsLnaOn == null) {
615             throw new IllegalStateException("LnaOn status is empty");
616         }
617         return mIsLnaOn;
618     }
619     /**
620      * Gets the current Error information by layer.
621      */
622     @NonNull
getLayerErrors()623     public boolean[] getLayerErrors() {
624         if (mIsLayerErrors == null) {
625             throw new IllegalStateException("LayerErrors status is empty");
626         }
627         return mIsLayerErrors;
628     }
629     /**
630      * Gets the current Modulation Error Ratio in thousandths of a deciBel (0.001dB).
631      */
getMer()632     public int getMer() {
633         if (mMer == null) {
634             throw new IllegalStateException("Mer status is empty");
635         }
636         return mMer;
637     }
638     /**
639      * Gets the current frequency difference in Hz.
640      *
641      * <p>Difference between tuning frequency and actual locked frequency.
642      */
getFreqOffset()643     public int getFreqOffset() {
644         if (mFreqOffset == null) {
645             throw new IllegalStateException("FreqOffset status is empty");
646         }
647         return mFreqOffset;
648     }
649     /**
650      * Gets the current hierarchy Type for DVBT.
651      */
652     @DvbtFrontendSettings.Hierarchy
getHierarchy()653     public int getHierarchy() {
654         if (mHierarchy == null) {
655             throw new IllegalStateException("Hierarchy status is empty");
656         }
657         return mHierarchy;
658     }
659     /**
660      * Gets if the RF is locked or not.
661      */
isRfLocked()662     public boolean isRfLocked() {
663         if (mIsRfLocked == null) {
664             throw new IllegalStateException("isRfLocked status is empty");
665         }
666         return mIsRfLocked;
667     }
668     /**
669      * Gets an array of the current tuned PLPs information of ATSC3 frontend.
670      */
671     @NonNull
getAtsc3PlpTuningInfo()672     public Atsc3PlpTuningInfo[] getAtsc3PlpTuningInfo() {
673         if (mPlpInfo == null) {
674             throw new IllegalStateException("Atsc3PlpTuningInfo status is empty");
675         }
676         return mPlpInfo;
677     }
678 
679     /**
680      * Gets an array of the current extended bit error ratio.
681      *
682      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
683      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
684      */
685     @NonNull
getBers()686     public int[] getBers() {
687         TunerVersionChecker.checkHigherOrEqualVersionTo(
688                 TunerVersionChecker.TUNER_VERSION_1_1, "getBers status");
689         if (mBers == null) {
690             throw new IllegalStateException("Bers status is empty");
691         }
692         return mBers;
693     }
694 
695     /**
696      * Gets an array of the current code rates.
697      *
698      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
699      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
700      */
701     @NonNull
702     @FrontendSettings.InnerFec
getCodeRates()703     public int[] getCodeRates() {
704         TunerVersionChecker.checkHigherOrEqualVersionTo(
705                 TunerVersionChecker.TUNER_VERSION_1_1, "getCodeRates status");
706         if (mCodeRates == null) {
707             throw new IllegalStateException("CodeRates status is empty");
708         }
709         return mCodeRates;
710     }
711 
712     /**
713      * Gets the current bandwidth information.
714      *
715      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
716      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
717      */
718     @FrontendBandwidth
getBandwidth()719     public int getBandwidth() {
720         TunerVersionChecker.checkHigherOrEqualVersionTo(
721                 TunerVersionChecker.TUNER_VERSION_1_1, "getBandwidth status");
722         if (mBandwidth == null) {
723             throw new IllegalStateException("Bandwidth status is empty");
724         }
725         return mBandwidth;
726     }
727 
728     /**
729      * Gets the current guard interval information.
730      *
731      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
732      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
733      */
734     @FrontendGuardInterval
getGuardInterval()735     public int getGuardInterval() {
736         TunerVersionChecker.checkHigherOrEqualVersionTo(
737                 TunerVersionChecker.TUNER_VERSION_1_1, "getGuardInterval status");
738         if (mGuardInterval == null) {
739             throw new IllegalStateException("GuardInterval status is empty");
740         }
741         return mGuardInterval;
742     }
743 
744     /**
745      * Gets the current transmission mode information.
746      *
747      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
748      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
749      */
750     @FrontendTransmissionMode
getTransmissionMode()751     public int getTransmissionMode() {
752         TunerVersionChecker.checkHigherOrEqualVersionTo(
753                 TunerVersionChecker.TUNER_VERSION_1_1, "getTransmissionMode status");
754         if (mTransmissionMode == null) {
755             throw new IllegalStateException("TransmissionMode status is empty");
756         }
757         return mTransmissionMode;
758     }
759 
760     /**
761      * Gets the current Uncorrectable Error Counts of the frontend's Physical Layer Pipe (PLP)
762      * since the last tune operation.
763      *
764      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
765      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
766      */
getUec()767     public int getUec() {
768         TunerVersionChecker.checkHigherOrEqualVersionTo(
769                 TunerVersionChecker.TUNER_VERSION_1_1, "getUec status");
770         if (mUec == null) {
771             throw new IllegalStateException("Uec status is empty");
772         }
773         return mUec;
774     }
775 
776     /**
777      * Gets the current DVB-T2 system id.
778      *
779      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
780      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
781      */
782     @IntRange(from = 0, to = 0xffff)
getSystemId()783     public int getSystemId() {
784         TunerVersionChecker.checkHigherOrEqualVersionTo(
785                 TunerVersionChecker.TUNER_VERSION_1_1, "getSystemId status");
786         if (mSystemId == null) {
787             throw new IllegalStateException("SystemId status is empty");
788         }
789         return mSystemId;
790     }
791 
792     /**
793      * Gets an array of the current interleaving mode information.
794      *
795      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
796      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
797      */
798     @NonNull
799     @FrontendInterleaveMode
getInterleaving()800     public int[] getInterleaving() {
801         TunerVersionChecker.checkHigherOrEqualVersionTo(
802                 TunerVersionChecker.TUNER_VERSION_1_1, "getInterleaving status");
803         if (mInterleaving == null) {
804             throw new IllegalStateException("Interleaving status is empty");
805         }
806         return mInterleaving;
807     }
808 
809     /**
810      * Gets an array of the current segments information in ISDB-T Specification of all the
811      * channels.
812      *
813      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
814      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
815      */
816     @NonNull
817     @IntRange(from = 0, to = 0xff)
getIsdbtSegment()818     public int[] getIsdbtSegment() {
819         TunerVersionChecker.checkHigherOrEqualVersionTo(
820                 TunerVersionChecker.TUNER_VERSION_1_1, "getIsdbtSegment status");
821         if (mIsdbtSegment == null) {
822             throw new IllegalStateException("IsdbtSegment status is empty");
823         }
824         return mIsdbtSegment;
825     }
826 
827     /**
828      * Gets an array of the Transport Stream Data Rate in BPS of the current channel.
829      *
830      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
831      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
832      */
833     @NonNull
getTsDataRate()834     public int[] getTsDataRate() {
835         TunerVersionChecker.checkHigherOrEqualVersionTo(
836                 TunerVersionChecker.TUNER_VERSION_1_1, "getTsDataRate status");
837         if (mTsDataRate == null) {
838             throw new IllegalStateException("TsDataRate status is empty");
839         }
840         return mTsDataRate;
841     }
842 
843     /**
844      * Gets an array of the current extended modulations information.
845      *
846      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
847      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
848      */
849     @NonNull
850     @FrontendModulation
getExtendedModulations()851     public int[] getExtendedModulations() {
852         TunerVersionChecker.checkHigherOrEqualVersionTo(
853                 TunerVersionChecker.TUNER_VERSION_1_1, "getExtendedModulations status");
854         if (mModulationsExt == null) {
855             throw new IllegalStateException("ExtendedModulations status is empty");
856         }
857         return mModulationsExt;
858     }
859 
860     /**
861      * Gets the current roll off information.
862      *
863      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
864      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
865      */
866     @FrontendRollOff
getRollOff()867     public int getRollOff() {
868         TunerVersionChecker.checkHigherOrEqualVersionTo(
869                 TunerVersionChecker.TUNER_VERSION_1_1, "getRollOff status");
870         if (mRollOff == null) {
871             throw new IllegalStateException("RollOff status is empty");
872         }
873         return mRollOff;
874     }
875 
876     /**
877      * Gets is MISO enabled or not.
878      *
879      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
880      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
881      */
isMisoEnabled()882     public boolean isMisoEnabled() {
883         TunerVersionChecker.checkHigherOrEqualVersionTo(
884                 TunerVersionChecker.TUNER_VERSION_1_1, "isMisoEnabled status");
885         if (mIsMisoEnabled == null) {
886             throw new IllegalStateException("isMisoEnabled status is empty");
887         }
888         return mIsMisoEnabled;
889     }
890 
891     /**
892      * Gets is the Code Rate of the frontend is linear or not.
893      *
894      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
895      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
896      */
isLinear()897     public boolean isLinear() {
898         TunerVersionChecker.checkHigherOrEqualVersionTo(
899                 TunerVersionChecker.TUNER_VERSION_1_1, "isLinear status");
900         if (mIsLinear == null) {
901             throw new IllegalStateException("isLinear status is empty");
902         }
903         return mIsLinear;
904     }
905 
906     /**
907      * Gets is the Short Frames enabled or not.
908      *
909      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
910      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
911      */
isShortFramesEnabled()912     public boolean isShortFramesEnabled() {
913         TunerVersionChecker.checkHigherOrEqualVersionTo(
914                 TunerVersionChecker.TUNER_VERSION_1_1, "isShortFramesEnabled status");
915         if (mIsShortFrames == null) {
916             throw new IllegalStateException("isShortFramesEnabled status is empty");
917         }
918         return mIsShortFrames;
919     }
920 
921     /**
922      * Information of each tuning Physical Layer Pipes.
923      */
924     public static class Atsc3PlpTuningInfo {
925         private final int mPlpId;
926         private final boolean mIsLocked;
927         private final int mUec;
928 
Atsc3PlpTuningInfo(int plpId, boolean isLocked, int uec)929         private Atsc3PlpTuningInfo(int plpId, boolean isLocked, int uec) {
930             mPlpId = plpId;
931             mIsLocked = isLocked;
932             mUec = uec;
933         }
934 
935         /**
936          * Gets Physical Layer Pipe ID.
937          */
getPlpId()938         public int getPlpId() {
939             return mPlpId;
940         }
941         /**
942          * Gets Demod Lock/Unlock status of this particular PLP.
943          */
isLocked()944         public boolean isLocked() {
945             return mIsLocked;
946         }
947         /**
948          * Gets Uncorrectable Error Counts (UEC) of this particular PLP since last tune operation.
949          */
getUec()950         public int getUec() {
951             return mUec;
952         }
953     }
954 }
955