• 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.SuppressLint;
23 import android.annotation.SystemApi;
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 import java.util.Arrays;
30 import java.util.Collections;
31 import java.util.List;
32 
33 /**
34  * A Frontend Status class that contains the metrics of the active frontend.
35  *
36  * @hide
37  */
38 @SystemApi
39 public class FrontendStatus {
40 
41     /** @hide */
42     @IntDef({FRONTEND_STATUS_TYPE_DEMOD_LOCK, FRONTEND_STATUS_TYPE_SNR, FRONTEND_STATUS_TYPE_BER,
43             FRONTEND_STATUS_TYPE_PER, FRONTEND_STATUS_TYPE_PRE_BER,
44             FRONTEND_STATUS_TYPE_SIGNAL_QUALITY, FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH,
45             FRONTEND_STATUS_TYPE_SYMBOL_RATE, FRONTEND_STATUS_TYPE_FEC,
46             FRONTEND_STATUS_TYPE_MODULATION, FRONTEND_STATUS_TYPE_SPECTRAL,
47             FRONTEND_STATUS_TYPE_LNB_VOLTAGE, FRONTEND_STATUS_TYPE_PLP_ID,
48             FRONTEND_STATUS_TYPE_EWBS, FRONTEND_STATUS_TYPE_AGC, FRONTEND_STATUS_TYPE_LNA,
49             FRONTEND_STATUS_TYPE_LAYER_ERROR, FRONTEND_STATUS_TYPE_MER,
50             FRONTEND_STATUS_TYPE_FREQ_OFFSET, FRONTEND_STATUS_TYPE_HIERARCHY,
51             FRONTEND_STATUS_TYPE_RF_LOCK, FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO,
52             FRONTEND_STATUS_TYPE_BERS, FRONTEND_STATUS_TYPE_CODERATES,
53             FRONTEND_STATUS_TYPE_BANDWIDTH, FRONTEND_STATUS_TYPE_GUARD_INTERVAL,
54             FRONTEND_STATUS_TYPE_TRANSMISSION_MODE, FRONTEND_STATUS_TYPE_UEC,
55             FRONTEND_STATUS_TYPE_T2_SYSTEM_ID, FRONTEND_STATUS_TYPE_INTERLEAVINGS,
56             FRONTEND_STATUS_TYPE_ISDBT_SEGMENTS, FRONTEND_STATUS_TYPE_TS_DATA_RATES,
57             FRONTEND_STATUS_TYPE_MODULATIONS_EXT, FRONTEND_STATUS_TYPE_ROLL_OFF,
58             FRONTEND_STATUS_TYPE_IS_MISO_ENABLED, FRONTEND_STATUS_TYPE_IS_LINEAR,
59             FRONTEND_STATUS_TYPE_IS_SHORT_FRAMES_ENABLED, FRONTEND_STATUS_TYPE_ISDBT_MODE,
60             FRONTEND_STATUS_TYPE_ISDBT_PARTIAL_RECEPTION_FLAG, FRONTEND_STATUS_TYPE_STREAM_IDS,
61             FRONTEND_STATUS_TYPE_DVBT_CELL_IDS, FRONTEND_STATUS_TYPE_ATSC3_ALL_PLP_INFO,
62             FRONTEND_STATUS_TYPE_IPTV_CONTENT_URL, FRONTEND_STATUS_TYPE_IPTV_PACKETS_LOST,
63             FRONTEND_STATUS_TYPE_IPTV_PACKETS_RECEIVED, FRONTEND_STATUS_TYPE_IPTV_WORST_JITTER_MS,
64             FRONTEND_STATUS_TYPE_IPTV_AVERAGE_JITTER_MS})
65     @Retention(RetentionPolicy.SOURCE)
66     public @interface FrontendStatusType {}
67 
68     /**
69      * Lock status for Demod.
70      */
71     public static final int FRONTEND_STATUS_TYPE_DEMOD_LOCK =
72             android.hardware.tv.tuner.FrontendStatusType.DEMOD_LOCK;
73     /**
74      * Signal to Noise Ratio.
75      */
76     public static final int FRONTEND_STATUS_TYPE_SNR =
77             android.hardware.tv.tuner.FrontendStatusType.SNR;
78     /**
79      * Bit Error Ratio.
80      */
81     public static final int FRONTEND_STATUS_TYPE_BER =
82             android.hardware.tv.tuner.FrontendStatusType.BER;
83     /**
84      * Packages Error Ratio.
85      */
86     public static final int FRONTEND_STATUS_TYPE_PER =
87             android.hardware.tv.tuner.FrontendStatusType.PER;
88     /**
89      * Bit Error Ratio before FEC.
90      */
91     public static final int FRONTEND_STATUS_TYPE_PRE_BER =
92             android.hardware.tv.tuner.FrontendStatusType.PRE_BER;
93     /**
94      * Signal Quality (0..100). Good data over total data in percent can be
95      * used as a way to present Signal Quality.
96      */
97     public static final int FRONTEND_STATUS_TYPE_SIGNAL_QUALITY =
98             android.hardware.tv.tuner.FrontendStatusType.SIGNAL_QUALITY;
99     /**
100      * Signal Strength.
101      */
102     public static final int FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH =
103             android.hardware.tv.tuner.FrontendStatusType.SIGNAL_STRENGTH;
104     /**
105      * Symbol Rate in symbols per second.
106      */
107     public static final int FRONTEND_STATUS_TYPE_SYMBOL_RATE =
108             android.hardware.tv.tuner.FrontendStatusType.SYMBOL_RATE;
109     /**
110      * Forward Error Correction Type.
111      */
112     public static final int FRONTEND_STATUS_TYPE_FEC =
113             android.hardware.tv.tuner.FrontendStatusType.FEC;
114     /**
115      * Modulation Type.
116      */
117     public static final int FRONTEND_STATUS_TYPE_MODULATION =
118             android.hardware.tv.tuner.FrontendStatusType.MODULATION;
119     /**
120      * Spectral Inversion Type.
121      */
122     public static final int FRONTEND_STATUS_TYPE_SPECTRAL =
123             android.hardware.tv.tuner.FrontendStatusType.SPECTRAL;
124     /**
125      * LNB Voltage.
126      */
127     public static final int FRONTEND_STATUS_TYPE_LNB_VOLTAGE =
128             android.hardware.tv.tuner.FrontendStatusType.LNB_VOLTAGE;
129     /**
130      * Physical Layer Pipe ID.
131      */
132     public static final int FRONTEND_STATUS_TYPE_PLP_ID =
133             android.hardware.tv.tuner.FrontendStatusType.PLP_ID;
134     /**
135      * Status for Emergency Warning Broadcasting System.
136      */
137     public static final int FRONTEND_STATUS_TYPE_EWBS =
138             android.hardware.tv.tuner.FrontendStatusType.EWBS;
139     /**
140      * Automatic Gain Control.
141      */
142     public static final int FRONTEND_STATUS_TYPE_AGC =
143             android.hardware.tv.tuner.FrontendStatusType.AGC;
144     /**
145      * Low Noise Amplifier.
146      */
147     public static final int FRONTEND_STATUS_TYPE_LNA =
148             android.hardware.tv.tuner.FrontendStatusType.LNA;
149     /**
150      * Error status by layer.
151      */
152     public static final int FRONTEND_STATUS_TYPE_LAYER_ERROR =
153             android.hardware.tv.tuner.FrontendStatusType.LAYER_ERROR;
154     /**
155      * Modulation Error Ratio.
156      */
157     public static final int FRONTEND_STATUS_TYPE_MER =
158             android.hardware.tv.tuner.FrontendStatusType.MER;
159     /**
160      * Difference between tuning frequency and actual locked frequency.
161      */
162     public static final int FRONTEND_STATUS_TYPE_FREQ_OFFSET =
163             android.hardware.tv.tuner.FrontendStatusType.FREQ_OFFSET;
164     /**
165      * Hierarchy for DVBT.
166      */
167     public static final int FRONTEND_STATUS_TYPE_HIERARCHY =
168             android.hardware.tv.tuner.FrontendStatusType.HIERARCHY;
169     /**
170      * Lock status for RF.
171      */
172     public static final int FRONTEND_STATUS_TYPE_RF_LOCK =
173             android.hardware.tv.tuner.FrontendStatusType.RF_LOCK;
174     /**
175      * Current tuned PLP information in a frequency band for ATSC-3.0 frontend.
176      */
177     public static final int FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO =
178             android.hardware.tv.tuner.FrontendStatusType.ATSC3_PLP_INFO;
179     /**
180      * BERS Type. Only supported in Tuner HAL 1.1 or higher.
181      */
182     public static final int FRONTEND_STATUS_TYPE_BERS =
183             android.hardware.tv.tuner.FrontendStatusType.BERS;
184     /**
185      * Coderate Type. Only supported in Tuner HAL 1.1 or higher.
186      */
187     public static final int FRONTEND_STATUS_TYPE_CODERATES =
188             android.hardware.tv.tuner.FrontendStatusType.CODERATES;
189     /**
190      * Bandwidth Type. Only supported in Tuner HAL 1.1 or higher.
191      */
192     public static final int FRONTEND_STATUS_TYPE_BANDWIDTH =
193             android.hardware.tv.tuner.FrontendStatusType.BANDWIDTH;
194     /**
195      * Guard Interval Type. Only supported in Tuner HAL 1.1 or higher.
196      */
197     public static final int FRONTEND_STATUS_TYPE_GUARD_INTERVAL =
198             android.hardware.tv.tuner.FrontendStatusType.GUARD_INTERVAL;
199     /**
200      * Transmission Mode Type. Only supported in Tuner HAL 1.1 or higher.
201      */
202     public static final int FRONTEND_STATUS_TYPE_TRANSMISSION_MODE =
203             android.hardware.tv.tuner.FrontendStatusType.TRANSMISSION_MODE;
204     /**
205      * UEC Type. Only supported in Tuner HAL 1.1 or higher.
206      */
207     public static final int FRONTEND_STATUS_TYPE_UEC =
208             android.hardware.tv.tuner.FrontendStatusType.UEC;
209     /**
210      * T2 System Id Type. Only supported in Tuner HAL 1.1 or higher.
211      */
212     public static final int FRONTEND_STATUS_TYPE_T2_SYSTEM_ID =
213             android.hardware.tv.tuner.FrontendStatusType.T2_SYSTEM_ID;
214     /**
215      * Interleavings Type. Only supported in Tuner HAL 1.1 or higher.
216      */
217     public static final int FRONTEND_STATUS_TYPE_INTERLEAVINGS =
218             android.hardware.tv.tuner.FrontendStatusType.INTERLEAVINGS;
219     /**
220      * ISDBT Segments Type. Only supported in Tuner HAL 1.1 or higher.
221      */
222     public static final int FRONTEND_STATUS_TYPE_ISDBT_SEGMENTS =
223             android.hardware.tv.tuner.FrontendStatusType.ISDBT_SEGMENTS;
224     /**
225      * TS Data Rates Type. Only supported in Tuner HAL 1.1 or higher.
226      */
227     public static final int FRONTEND_STATUS_TYPE_TS_DATA_RATES =
228             android.hardware.tv.tuner.FrontendStatusType.TS_DATA_RATES;
229     /**
230      * Extended Modulations Type. Only supported in Tuner HAL 1.1 or higher.
231      */
232     public static final int FRONTEND_STATUS_TYPE_MODULATIONS_EXT =
233             android.hardware.tv.tuner.FrontendStatusType.MODULATIONS;
234     /**
235      * Roll Off Type status of the frontend. Only supported in Tuner HAL 1.1 or higher.
236      */
237     public static final int FRONTEND_STATUS_TYPE_ROLL_OFF =
238             android.hardware.tv.tuner.FrontendStatusType.ROLL_OFF;
239     /**
240      * If the frontend currently supports MISO or not. Only supported in Tuner HAL 1.1 or higher.
241      */
242     public static final int FRONTEND_STATUS_TYPE_IS_MISO_ENABLED =
243             android.hardware.tv.tuner.FrontendStatusType.IS_MISO;
244     /**
245      * If the frontend code rate is linear or not. Only supported in Tuner HAL 1.1 or higher.
246      */
247     public static final int FRONTEND_STATUS_TYPE_IS_LINEAR =
248             android.hardware.tv.tuner.FrontendStatusType.IS_LINEAR;
249     /**
250      * If short frames is enabled or not. Only supported in Tuner HAL 1.1 or higher.
251      */
252     public static final int FRONTEND_STATUS_TYPE_IS_SHORT_FRAMES_ENABLED =
253             android.hardware.tv.tuner.FrontendStatusType.IS_SHORT_FRAMES;
254     /**
255      * ISDB-T mode. Only supported in Tuner HAL 2.0 or higher.
256      */
257     public static final int FRONTEND_STATUS_TYPE_ISDBT_MODE =
258             android.hardware.tv.tuner.FrontendStatusType.ISDBT_MODE;
259     /**
260      * ISDB-T partial reception flag. Only supported in Tuner HAL 2.0 or higher.
261      */
262     public static final int FRONTEND_STATUS_TYPE_ISDBT_PARTIAL_RECEPTION_FLAG =
263             android.hardware.tv.tuner.FrontendStatusType.ISDBT_PARTIAL_RECEPTION_FLAG;
264 
265     /**
266      * Stream IDs included in a transponder.
267      */
268     public static final int FRONTEND_STATUS_TYPE_STREAM_IDS =
269             android.hardware.tv.tuner.FrontendStatusType.STREAM_ID_LIST;
270 
271     /**
272      * DVB-T Cell IDs.
273      */
274     public static final int FRONTEND_STATUS_TYPE_DVBT_CELL_IDS =
275             android.hardware.tv.tuner.FrontendStatusType.DVBT_CELL_IDS;
276 
277     /**
278      * IPTV content URL.
279      */
280     public static final int FRONTEND_STATUS_TYPE_IPTV_CONTENT_URL =
281             android.hardware.tv.tuner.FrontendStatusType.IPTV_CONTENT_URL;
282 
283     /**
284      * IPTV packets lost.
285      */
286     public static final int FRONTEND_STATUS_TYPE_IPTV_PACKETS_LOST =
287             android.hardware.tv.tuner.FrontendStatusType.IPTV_PACKETS_LOST;
288 
289     /**
290      * IPTV packets received.
291      */
292     public static final int FRONTEND_STATUS_TYPE_IPTV_PACKETS_RECEIVED =
293             android.hardware.tv.tuner.FrontendStatusType.IPTV_PACKETS_RECEIVED;
294 
295     /**
296      * IPTV worst jitter.
297      */
298     public static final int FRONTEND_STATUS_TYPE_IPTV_WORST_JITTER_MS =
299             android.hardware.tv.tuner.FrontendStatusType.IPTV_WORST_JITTER_MS;
300 
301     /**
302      * IPTV average jitter.
303      */
304     public static final int FRONTEND_STATUS_TYPE_IPTV_AVERAGE_JITTER_MS =
305             android.hardware.tv.tuner.FrontendStatusType.IPTV_AVERAGE_JITTER_MS;
306 
307     /**
308      * All PLP information in a frequency band for ATSC-3.0 frontend, which includes both tuned and
309      * not tuned PLPs for currently watching service.
310      */
311     public static final int FRONTEND_STATUS_TYPE_ATSC3_ALL_PLP_INFO =
312             android.hardware.tv.tuner.FrontendStatusType.ATSC3_ALL_PLP_INFO;
313 
314     /** @hide */
315     @IntDef(value = {
316             AtscFrontendSettings.MODULATION_UNDEFINED,
317             AtscFrontendSettings.MODULATION_AUTO,
318             AtscFrontendSettings.MODULATION_MOD_8VSB,
319             AtscFrontendSettings.MODULATION_MOD_16VSB,
320             Atsc3FrontendSettings.MODULATION_UNDEFINED,
321             Atsc3FrontendSettings.MODULATION_AUTO,
322             Atsc3FrontendSettings.MODULATION_MOD_QPSK,
323             Atsc3FrontendSettings.MODULATION_MOD_16QAM,
324             Atsc3FrontendSettings.MODULATION_MOD_64QAM,
325             Atsc3FrontendSettings.MODULATION_MOD_256QAM,
326             Atsc3FrontendSettings.MODULATION_MOD_1024QAM,
327             Atsc3FrontendSettings.MODULATION_MOD_4096QAM,
328             DtmbFrontendSettings.MODULATION_CONSTELLATION_UNDEFINED,
329             DtmbFrontendSettings.MODULATION_CONSTELLATION_AUTO,
330             DtmbFrontendSettings.MODULATION_CONSTELLATION_4QAM,
331             DtmbFrontendSettings.MODULATION_CONSTELLATION_4QAM_NR,
332             DtmbFrontendSettings.MODULATION_CONSTELLATION_16QAM,
333             DtmbFrontendSettings.MODULATION_CONSTELLATION_32QAM,
334             DtmbFrontendSettings.MODULATION_CONSTELLATION_64QAM,
335             DvbcFrontendSettings.MODULATION_UNDEFINED,
336             DvbcFrontendSettings.MODULATION_AUTO,
337             DvbcFrontendSettings.MODULATION_MOD_16QAM,
338             DvbcFrontendSettings.MODULATION_MOD_32QAM,
339             DvbcFrontendSettings.MODULATION_MOD_64QAM,
340             DvbcFrontendSettings.MODULATION_MOD_128QAM,
341             DvbcFrontendSettings.MODULATION_MOD_256QAM,
342             DvbsFrontendSettings.MODULATION_UNDEFINED,
343             DvbsFrontendSettings.MODULATION_AUTO,
344             DvbsFrontendSettings.MODULATION_MOD_QPSK,
345             DvbsFrontendSettings.MODULATION_MOD_8PSK,
346             DvbsFrontendSettings.MODULATION_MOD_16QAM,
347             DvbsFrontendSettings.MODULATION_MOD_16PSK,
348             DvbsFrontendSettings.MODULATION_MOD_32PSK,
349             DvbsFrontendSettings.MODULATION_MOD_ACM,
350             DvbsFrontendSettings.MODULATION_MOD_8APSK,
351             DvbsFrontendSettings.MODULATION_MOD_16APSK,
352             DvbsFrontendSettings.MODULATION_MOD_32APSK,
353             DvbsFrontendSettings.MODULATION_MOD_64APSK,
354             DvbsFrontendSettings.MODULATION_MOD_128APSK,
355             DvbsFrontendSettings.MODULATION_MOD_256APSK,
356             DvbsFrontendSettings.MODULATION_MOD_RESERVED,
357             DvbtFrontendSettings.CONSTELLATION_UNDEFINED,
358             DvbtFrontendSettings.CONSTELLATION_AUTO,
359             DvbtFrontendSettings.CONSTELLATION_QPSK,
360             DvbtFrontendSettings.CONSTELLATION_16QAM,
361             DvbtFrontendSettings.CONSTELLATION_64QAM,
362             DvbtFrontendSettings.CONSTELLATION_256QAM,
363             DvbtFrontendSettings.CONSTELLATION_QPSK_R,
364             DvbtFrontendSettings.CONSTELLATION_16QAM_R,
365             DvbtFrontendSettings.CONSTELLATION_64QAM_R,
366             DvbtFrontendSettings.CONSTELLATION_256QAM_R,
367             IsdbsFrontendSettings.MODULATION_UNDEFINED,
368             IsdbsFrontendSettings.MODULATION_AUTO,
369             IsdbsFrontendSettings.MODULATION_MOD_BPSK,
370             IsdbsFrontendSettings.MODULATION_MOD_QPSK,
371             IsdbsFrontendSettings.MODULATION_MOD_TC8PSK,
372             Isdbs3FrontendSettings.MODULATION_UNDEFINED,
373             Isdbs3FrontendSettings.MODULATION_AUTO,
374             Isdbs3FrontendSettings.MODULATION_MOD_BPSK,
375             Isdbs3FrontendSettings.MODULATION_MOD_QPSK,
376             Isdbs3FrontendSettings.MODULATION_MOD_8PSK,
377             Isdbs3FrontendSettings.MODULATION_MOD_16APSK,
378             Isdbs3FrontendSettings.MODULATION_MOD_32APSK,
379             IsdbtFrontendSettings.MODULATION_UNDEFINED,
380             IsdbtFrontendSettings.MODULATION_AUTO,
381             IsdbtFrontendSettings.MODULATION_MOD_DQPSK,
382             IsdbtFrontendSettings.MODULATION_MOD_QPSK,
383             IsdbtFrontendSettings.MODULATION_MOD_16QAM,
384             IsdbtFrontendSettings.MODULATION_MOD_64QAM})
385     @Retention(RetentionPolicy.SOURCE)
386     public @interface FrontendModulation {}
387 
388     /** @hide */
389     @IntDef(value = {
390             Atsc3FrontendSettings.TIME_INTERLEAVE_MODE_UNDEFINED,
391             Atsc3FrontendSettings.TIME_INTERLEAVE_MODE_AUTO,
392             Atsc3FrontendSettings.TIME_INTERLEAVE_MODE_CTI,
393             Atsc3FrontendSettings.TIME_INTERLEAVE_MODE_HTI,
394             DtmbFrontendSettings.TIME_INTERLEAVE_MODE_UNDEFINED,
395             DtmbFrontendSettings.TIME_INTERLEAVE_MODE_AUTO,
396             DtmbFrontendSettings.TIME_INTERLEAVE_MODE_TIMER_INT_240,
397             DtmbFrontendSettings.TIME_INTERLEAVE_MODE_TIMER_INT_720,
398             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_UNDEFINED,
399             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_AUTO,
400             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_1_0,
401             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_1_1,
402             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_64_2,
403             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_32_4,
404             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_16_8,
405             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_8_16,
406             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_2,
407             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_3,
408             DvbcFrontendSettings.TIME_INTERLEAVE_MODE_128_4,
409             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_UNDEFINED,
410             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_AUTO,
411             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_1_0,
412             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_1_4,
413             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_1_8,
414             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_1_16,
415             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_2_0,
416             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_2_2,
417             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_2_4,
418             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_2_8,
419             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_3_0,
420             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_3_1,
421             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_3_2,
422             IsdbtFrontendSettings.TIME_INTERLEAVE_MODE_3_4})
423     @Retention(RetentionPolicy.SOURCE)
424     public @interface FrontendInterleaveMode {}
425 
426     /** @hide */
427     @IntDef(value = {
428             Atsc3FrontendSettings.BANDWIDTH_UNDEFINED,
429             Atsc3FrontendSettings.BANDWIDTH_AUTO,
430             Atsc3FrontendSettings.BANDWIDTH_BANDWIDTH_6MHZ,
431             Atsc3FrontendSettings.BANDWIDTH_BANDWIDTH_7MHZ,
432             Atsc3FrontendSettings.BANDWIDTH_BANDWIDTH_8MHZ,
433             DtmbFrontendSettings.BANDWIDTH_UNDEFINED,
434             DtmbFrontendSettings.BANDWIDTH_AUTO,
435             DtmbFrontendSettings.BANDWIDTH_6MHZ,
436             DtmbFrontendSettings.BANDWIDTH_8MHZ,
437             DvbtFrontendSettings.BANDWIDTH_UNDEFINED,
438             DvbtFrontendSettings.BANDWIDTH_AUTO,
439             DvbtFrontendSettings.BANDWIDTH_8MHZ,
440             DvbtFrontendSettings.BANDWIDTH_7MHZ,
441             DvbtFrontendSettings.BANDWIDTH_6MHZ,
442             DvbtFrontendSettings.BANDWIDTH_5MHZ,
443             DvbtFrontendSettings.BANDWIDTH_1_7MHZ,
444             DvbtFrontendSettings.BANDWIDTH_10MHZ,
445             IsdbtFrontendSettings.BANDWIDTH_UNDEFINED,
446             IsdbtFrontendSettings.BANDWIDTH_AUTO,
447             IsdbtFrontendSettings.BANDWIDTH_8MHZ,
448             IsdbtFrontendSettings.BANDWIDTH_7MHZ,
449             IsdbtFrontendSettings.BANDWIDTH_6MHZ})
450     @Retention(RetentionPolicy.SOURCE)
451     public @interface FrontendBandwidth {}
452 
453     /** @hide */
454     @IntDef(value = {
455             DtmbFrontendSettings.TRANSMISSION_MODE_UNDEFINED,
456             DtmbFrontendSettings.TRANSMISSION_MODE_AUTO,
457             DtmbFrontendSettings.TRANSMISSION_MODE_C1,
458             DtmbFrontendSettings.TRANSMISSION_MODE_C3780,
459             DvbtFrontendSettings.TRANSMISSION_MODE_UNDEFINED,
460             DvbtFrontendSettings.TRANSMISSION_MODE_AUTO,
461             DvbtFrontendSettings.TRANSMISSION_MODE_2K,
462             DvbtFrontendSettings.TRANSMISSION_MODE_8K,
463             DvbtFrontendSettings.TRANSMISSION_MODE_4K,
464             DvbtFrontendSettings.TRANSMISSION_MODE_1K,
465             DvbtFrontendSettings.TRANSMISSION_MODE_16K,
466             DvbtFrontendSettings.TRANSMISSION_MODE_32K,
467             IsdbtFrontendSettings.MODE_UNDEFINED,
468             IsdbtFrontendSettings.MODE_AUTO,
469             IsdbtFrontendSettings.MODE_1,
470             IsdbtFrontendSettings.MODE_2,
471             IsdbtFrontendSettings.MODE_3})
472     @Retention(RetentionPolicy.SOURCE)
473     public @interface FrontendTransmissionMode {}
474 
475     /** @hide */
476     @IntDef(value = {
477             DtmbFrontendSettings.GUARD_INTERVAL_UNDEFINED,
478             DtmbFrontendSettings.GUARD_INTERVAL_AUTO,
479             DtmbFrontendSettings.GUARD_INTERVAL_PN_420_VARIOUS,
480             DtmbFrontendSettings.GUARD_INTERVAL_PN_595_CONST,
481             DtmbFrontendSettings.GUARD_INTERVAL_PN_945_VARIOUS,
482             DtmbFrontendSettings.GUARD_INTERVAL_PN_420_CONST,
483             DtmbFrontendSettings.GUARD_INTERVAL_PN_945_CONST,
484             DtmbFrontendSettings.GUARD_INTERVAL_PN_RESERVED,
485             DvbtFrontendSettings.GUARD_INTERVAL_UNDEFINED,
486             DvbtFrontendSettings.GUARD_INTERVAL_AUTO,
487             DvbtFrontendSettings.GUARD_INTERVAL_1_32,
488             DvbtFrontendSettings.GUARD_INTERVAL_1_16,
489             DvbtFrontendSettings.GUARD_INTERVAL_1_8,
490             DvbtFrontendSettings.GUARD_INTERVAL_1_4,
491             DvbtFrontendSettings.GUARD_INTERVAL_1_128,
492             DvbtFrontendSettings.GUARD_INTERVAL_19_128,
493             DvbtFrontendSettings.GUARD_INTERVAL_19_256,
494             DvbtFrontendSettings.GUARD_INTERVAL_19_128})
495     @Retention(RetentionPolicy.SOURCE)
496     public @interface FrontendGuardInterval {}
497 
498     /** @hide */
499     @IntDef(value = {
500             DvbsFrontendSettings.ROLLOFF_UNDEFINED,
501             DvbsFrontendSettings.ROLLOFF_0_35,
502             DvbsFrontendSettings.ROLLOFF_0_25,
503             DvbsFrontendSettings.ROLLOFF_0_20,
504             DvbsFrontendSettings.ROLLOFF_0_15,
505             DvbsFrontendSettings.ROLLOFF_0_10,
506             DvbsFrontendSettings.ROLLOFF_0_5,
507             Isdbs3FrontendSettings.ROLLOFF_UNDEFINED,
508             Isdbs3FrontendSettings.ROLLOFF_0_03,
509             IsdbsFrontendSettings.ROLLOFF_UNDEFINED,
510             IsdbsFrontendSettings.ROLLOFF_0_35})
511     @Retention(RetentionPolicy.SOURCE)
512     public @interface FrontendRollOff {}
513 
514     private Boolean mIsDemodLocked;
515     private Integer mSnr;
516     private Integer mBer;
517     private Integer mPer;
518     private Integer mPerBer;
519     private Integer mSignalQuality;
520     private Integer mSignalStrength;
521     private Integer mSymbolRate;
522     private Long mInnerFec;
523     private Integer mModulation;
524     private Integer mInversion;
525     private Integer mLnbVoltage;
526     private Integer mPlpId;
527     private Boolean mIsEwbs;
528     private Integer mAgc;
529     private Boolean mIsLnaOn;
530     private boolean[] mIsLayerErrors;
531     private Integer mMer;
532     private Long mFreqOffset;
533     private Integer mHierarchy;
534     private Boolean mIsRfLocked;
535     private Atsc3PlpTuningInfo[] mPlpInfo;
536     private int[] mBers;
537     private int[] mCodeRates;
538     private Integer mBandwidth;
539     private Integer mGuardInterval;
540     private Integer mTransmissionMode;
541     private Integer mUec;
542     private Integer mSystemId;
543     private int[] mInterleaving;
544     private int[] mTsDataRate;
545     private int[] mIsdbtSegment;
546     private int[] mModulationsExt;
547     private Integer mRollOff;
548     private Boolean mIsMisoEnabled;
549     private Boolean mIsLinear;
550     private Boolean mIsShortFrames;
551     private Integer mIsdbtMode;
552     private Integer mIsdbtPartialReceptionFlag;
553     private int[] mStreamIds;
554     private int[] mDvbtCellIds;
555     private Atsc3PlpInfo[] mAllPlpInfo;
556     private String mIptvContentUrl;
557     private Long mIptvPacketsLost;
558     private Long mIptvPacketsReceived;
559     private Integer mIptvWorstJitterMs;
560     private Integer mIptvAverageJitterMs;
561 
562     // Constructed and fields set by JNI code.
FrontendStatus()563     private FrontendStatus() {
564     }
565 
566     /**
567      * Gets if the demod is currently locked or not.
568      */
isDemodLocked()569     public boolean isDemodLocked() {
570         if (mIsDemodLocked == null) {
571             throw new IllegalStateException("DemodLocked status is empty");
572         }
573         return mIsDemodLocked;
574     }
575     /**
576      * Gets the current Signal to Noise Ratio in thousandths of a deciBel (0.001dB).
577      */
getSnr()578     public int getSnr() {
579         if (mSnr == null) {
580             throw new IllegalStateException("Snr status is empty");
581         }
582         return mSnr;
583     }
584     /**
585      * Gets the current Bit Error Ratio.
586      *
587      * <p>The number of error bit per 1 billion bits.
588      */
getBer()589     public int getBer() {
590         if (mBer == null) {
591             throw new IllegalStateException("Ber status is empty");
592         }
593         return mBer;
594     }
595 
596     /**
597      * Gets the current Packages Error Ratio.
598      *
599      * <p>The number of error package per 1 billion packages.
600      */
getPer()601     public int getPer() {
602         if (mPer == null) {
603             throw new IllegalStateException("Per status is empty");
604         }
605         return mPer;
606     }
607     /**
608      * Gets the current Bit Error Ratio before Forward Error Correction (FEC).
609      *
610      * <p>The number of error bit per 1 billion bits before FEC.
611      */
getPerBer()612     public int getPerBer() {
613         if (mPerBer == null) {
614             throw new IllegalStateException("PerBer status is empty");
615         }
616         return mPerBer;
617     }
618     /**
619      * Gets the current Signal Quality in percent.
620      */
getSignalQuality()621     public int getSignalQuality() {
622         if (mSignalQuality == null) {
623             throw new IllegalStateException("SignalQuality status is empty");
624         }
625         return mSignalQuality;
626     }
627     /**
628      * Gets the current Signal Strength in thousandths of a dBm (0.001dBm).
629      */
getSignalStrength()630     public int getSignalStrength() {
631         if (mSignalStrength == null) {
632             throw new IllegalStateException("SignalStrength status is empty");
633         }
634         return mSignalStrength;
635     }
636     /**
637      * Gets the current symbol rate in symbols per second.
638      */
getSymbolRate()639     public int getSymbolRate() {
640         if (mSymbolRate == null) {
641             throw new IllegalStateException("SymbolRate status is empty");
642         }
643         return mSymbolRate;
644     }
645     /**
646      *  Gets the current Inner Forward Error Correction type as specified in ETSI EN 300 468 V1.15.1
647      *  and ETSI EN 302 307-2 V1.1.1.
648      */
649     @FrontendSettings.InnerFec
getInnerFec()650     public long getInnerFec() {
651         if (mInnerFec == null) {
652             throw new IllegalStateException("InnerFec status is empty");
653         }
654         return mInnerFec;
655     }
656     /**
657      * Gets the currently modulation information.
658      */
659     @FrontendModulation
getModulation()660     public int getModulation() {
661         if (mModulation == null) {
662             throw new IllegalStateException("Modulation status is empty");
663         }
664         return mModulation;
665     }
666     /**
667      * Gets the currently Spectral Inversion information for DVBC.
668      */
669     @FrontendSettings.FrontendSpectralInversion
getSpectralInversion()670     public int getSpectralInversion() {
671         if (mInversion == null) {
672             throw new IllegalStateException("SpectralInversion status is empty");
673         }
674         return mInversion;
675     }
676     /**
677      * Gets the current Power Voltage Type for LNB.
678      */
679     @Lnb.Voltage
getLnbVoltage()680     public int getLnbVoltage() {
681         if (mLnbVoltage == null) {
682             throw new IllegalStateException("LnbVoltage status is empty");
683         }
684         return mLnbVoltage;
685     }
686     /**
687      * Gets the current Physical Layer Pipe ID.
688      */
getPlpId()689     public int getPlpId() {
690         if (mPlpId == null) {
691             throw new IllegalStateException("PlpId status is empty");
692         }
693         return mPlpId;
694     }
695     /**
696      * Checks whether it's Emergency Warning Broadcasting System
697      */
isEwbs()698     public boolean isEwbs() {
699         if (mIsEwbs == null) {
700             throw new IllegalStateException("Ewbs status is empty");
701         }
702         return mIsEwbs;
703     }
704     /**
705      * Gets the current Automatic Gain Control value which is normalized from 0 to 255.
706      *
707      * Larger AGC values indicate it is applying more gain.
708      */
getAgc()709     public int getAgc() {
710         if (mAgc == null) {
711             throw new IllegalStateException("Agc status is empty");
712         }
713         return mAgc;
714     }
715     /**
716      * Checks LNA (Low Noise Amplifier) is on or not.
717      */
isLnaOn()718     public boolean isLnaOn() {
719         if (mIsLnaOn == null) {
720             throw new IllegalStateException("LnaOn status is empty");
721         }
722         return mIsLnaOn;
723     }
724     /**
725      * Gets the current Error information by layer.
726      *
727      * The order of the vectors is in ascending order of the required CNR (Contrast-to-noise ratio).
728      * The most robust layer is the first. For example, in ISDB-T, vec[0] is the information of
729      * layer A. vec[1] is the information of layer B.
730      */
731     @NonNull
getLayerErrors()732     public boolean[] getLayerErrors() {
733         if (mIsLayerErrors == null) {
734             throw new IllegalStateException("LayerErrors status is empty");
735         }
736         return mIsLayerErrors;
737     }
738     /**
739      * Gets the current Modulation Error Ratio in thousandths of a deciBel (0.001dB).
740      */
getMer()741     public int getMer() {
742         if (mMer == null) {
743             throw new IllegalStateException("Mer status is empty");
744         }
745         return mMer;
746     }
747     /**
748      * Gets the current frequency difference in Hz.
749      *
750      * <p>Difference between tuning frequency and actual locked frequency.
751      * @deprecated Use {@link #getFreqOffsetLong()}
752      */
753     @Deprecated
getFreqOffset()754     public int getFreqOffset() {
755         return (int) getFreqOffsetLong();
756     }
757     /**
758      * Gets the current frequency difference in Hz.
759      *
760      * <p>Difference between tuning frequency and actual locked frequency.
761      */
getFreqOffsetLong()762     public long getFreqOffsetLong() {
763         if (mFreqOffset == null) {
764             throw new IllegalStateException("FreqOffset status is empty");
765         }
766         return mFreqOffset;
767     }
768     /**
769      * Gets the current hierarchy Type for DVBT.
770      */
771     @DvbtFrontendSettings.Hierarchy
getHierarchy()772     public int getHierarchy() {
773         if (mHierarchy == null) {
774             throw new IllegalStateException("Hierarchy status is empty");
775         }
776         return mHierarchy;
777     }
778     /**
779      * Gets if the RF is locked or not.
780      */
isRfLocked()781     public boolean isRfLocked() {
782         if (mIsRfLocked == null) {
783             throw new IllegalStateException("isRfLocked status is empty");
784         }
785         return mIsRfLocked;
786     }
787     /**
788      * Gets an array of the current tuned PLPs information of ATSC3 frontend.
789      */
790     @NonNull
getAtsc3PlpTuningInfo()791     public Atsc3PlpTuningInfo[] getAtsc3PlpTuningInfo() {
792         if (mPlpInfo == null) {
793             throw new IllegalStateException("Atsc3PlpTuningInfo status is empty");
794         }
795         return mPlpInfo;
796     }
797 
798     /**
799      * Gets an array of the current extended bit error ratio.
800      *
801      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
802      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
803      *
804      * The order of the vectors is in ascending order of the required CNR (Contrast-to-noise ratio).
805      * The most robust layer is the first. For example, in ISDB-T, vec[0] is the information of
806      * layer A. vec[1] is the information of layer B.
807      */
808     @NonNull
getBers()809     public int[] getBers() {
810         TunerVersionChecker.checkHigherOrEqualVersionTo(
811                 TunerVersionChecker.TUNER_VERSION_1_1, "getBers status");
812         if (mBers == null) {
813             throw new IllegalStateException("Bers status is empty");
814         }
815         return mBers;
816     }
817 
818     /**
819      * Gets an array of the current code rates.
820      *
821      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
822      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
823      *
824      * The order of the vectors is in ascending order of the required CNR (Contrast-to-noise ratio).
825      * The most robust layer is the first. For example, in ISDB-T, vec[0] is the information of
826      * layer A. vec[1] is the information of layer B.
827      */
828     @NonNull
829     @FrontendSettings.InnerFec
getCodeRates()830     public int[] getCodeRates() {
831         TunerVersionChecker.checkHigherOrEqualVersionTo(
832                 TunerVersionChecker.TUNER_VERSION_1_1, "getCodeRates status");
833         if (mCodeRates == null) {
834             throw new IllegalStateException("CodeRates status is empty");
835         }
836         return mCodeRates;
837     }
838 
839     /**
840      * Gets the current bandwidth information.
841      *
842      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
843      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
844      */
845     @FrontendBandwidth
getBandwidth()846     public int getBandwidth() {
847         TunerVersionChecker.checkHigherOrEqualVersionTo(
848                 TunerVersionChecker.TUNER_VERSION_1_1, "getBandwidth status");
849         if (mBandwidth == null) {
850             throw new IllegalStateException("Bandwidth status is empty");
851         }
852         return mBandwidth;
853     }
854 
855     /**
856      * Gets the current guard interval information.
857      *
858      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
859      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
860      */
861     @FrontendGuardInterval
getGuardInterval()862     public int getGuardInterval() {
863         TunerVersionChecker.checkHigherOrEqualVersionTo(
864                 TunerVersionChecker.TUNER_VERSION_1_1, "getGuardInterval status");
865         if (mGuardInterval == null) {
866             throw new IllegalStateException("GuardInterval status is empty");
867         }
868         return mGuardInterval;
869     }
870 
871     /**
872      * Gets the current transmission mode information.
873      *
874      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
875      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
876      */
877     @FrontendTransmissionMode
getTransmissionMode()878     public int getTransmissionMode() {
879         TunerVersionChecker.checkHigherOrEqualVersionTo(
880                 TunerVersionChecker.TUNER_VERSION_1_1, "getTransmissionMode status");
881         if (mTransmissionMode == null) {
882             throw new IllegalStateException("TransmissionMode status is empty");
883         }
884         return mTransmissionMode;
885     }
886 
887     /**
888      * Gets the current Uncorrectable Error Counts of the frontend's Physical Layer Pipe (PLP)
889      * since the last tune operation.
890      *
891      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
892      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
893      */
getUec()894     public int getUec() {
895         TunerVersionChecker.checkHigherOrEqualVersionTo(
896                 TunerVersionChecker.TUNER_VERSION_1_1, "getUec status");
897         if (mUec == null) {
898             throw new IllegalStateException("Uec status is empty");
899         }
900         return mUec;
901     }
902 
903     /**
904      * Gets the current DVB-T2 system id.
905      *
906      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
907      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
908      */
909     @IntRange(from = 0, to = 0xffff)
getSystemId()910     public int getSystemId() {
911         TunerVersionChecker.checkHigherOrEqualVersionTo(
912                 TunerVersionChecker.TUNER_VERSION_1_1, "getSystemId status");
913         if (mSystemId == null) {
914             throw new IllegalStateException("SystemId status is empty");
915         }
916         return mSystemId;
917     }
918 
919     /**
920      * Gets an array of the current interleaving mode information.
921      *
922      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
923      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
924      *
925      * The order of the vectors is in ascending order of the required CNR (Contrast-to-noise ratio).
926      * The most robust layer is the first. For example, in ISDB-T, vec[0] is the information of
927      * layer A. vec[1] is the information of layer B.
928      */
929     @NonNull
930     @FrontendInterleaveMode
getInterleaving()931     public int[] getInterleaving() {
932         TunerVersionChecker.checkHigherOrEqualVersionTo(
933                 TunerVersionChecker.TUNER_VERSION_1_1, "getInterleaving status");
934         if (mInterleaving == null) {
935             throw new IllegalStateException("Interleaving status is empty");
936         }
937         return mInterleaving;
938     }
939 
940     /**
941      * Gets an array of the current segments information in ISDB-T Specification of all the
942      * channels.
943      *
944      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
945      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
946      *
947      * The order of the vectors is in ascending order of the required CNR (Contrast-to-noise ratio).
948      * The most robust layer is the first. For example, in ISDB-T, vec[0] is the information of
949      * layer A. vec[1] is the information of layer B.
950      */
951     @NonNull
952     @IntRange(from = 0, to = 0xff)
getIsdbtSegment()953     public int[] getIsdbtSegment() {
954         TunerVersionChecker.checkHigherOrEqualVersionTo(
955                 TunerVersionChecker.TUNER_VERSION_1_1, "getIsdbtSegment status");
956         if (mIsdbtSegment == null) {
957             throw new IllegalStateException("IsdbtSegment status is empty");
958         }
959         return mIsdbtSegment;
960     }
961 
962     /**
963      * Gets an array of the Transport Stream Data Rate in BPS of the current channel.
964      *
965      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
966      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
967      */
968     @NonNull
getTsDataRate()969     public int[] getTsDataRate() {
970         TunerVersionChecker.checkHigherOrEqualVersionTo(
971                 TunerVersionChecker.TUNER_VERSION_1_1, "getTsDataRate status");
972         if (mTsDataRate == null) {
973             throw new IllegalStateException("TsDataRate status is empty");
974         }
975         return mTsDataRate;
976     }
977 
978     /**
979      * Gets an array of the current extended modulations information.
980      *
981      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
982      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
983      *
984      * The order of the vectors is in ascending order of the required CNR (Contrast-to-noise ratio).
985      * The most robust layer is the first. For example, in ISDB-T, vec[0] is the information of
986      * layer A. vec[1] is the information of layer B.
987      */
988     @NonNull
989     @FrontendModulation
getExtendedModulations()990     public int[] getExtendedModulations() {
991         TunerVersionChecker.checkHigherOrEqualVersionTo(
992                 TunerVersionChecker.TUNER_VERSION_1_1, "getExtendedModulations status");
993         if (mModulationsExt == null) {
994             throw new IllegalStateException("ExtendedModulations status is empty");
995         }
996         return mModulationsExt;
997     }
998 
999     /**
1000      * Gets the current roll off information.
1001      *
1002      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
1003      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1004      */
1005     @FrontendRollOff
getRollOff()1006     public int getRollOff() {
1007         TunerVersionChecker.checkHigherOrEqualVersionTo(
1008                 TunerVersionChecker.TUNER_VERSION_1_1, "getRollOff status");
1009         if (mRollOff == null) {
1010             throw new IllegalStateException("RollOff status is empty");
1011         }
1012         return mRollOff;
1013     }
1014 
1015     /**
1016      * Gets is MISO enabled or not.
1017      *
1018      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
1019      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1020      */
isMisoEnabled()1021     public boolean isMisoEnabled() {
1022         TunerVersionChecker.checkHigherOrEqualVersionTo(
1023                 TunerVersionChecker.TUNER_VERSION_1_1, "isMisoEnabled status");
1024         if (mIsMisoEnabled == null) {
1025             throw new IllegalStateException("isMisoEnabled status is empty");
1026         }
1027         return mIsMisoEnabled;
1028     }
1029 
1030     /**
1031      * Gets is the Code Rate of the frontend is linear or not.
1032      *
1033      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
1034      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1035      */
isLinear()1036     public boolean isLinear() {
1037         TunerVersionChecker.checkHigherOrEqualVersionTo(
1038                 TunerVersionChecker.TUNER_VERSION_1_1, "isLinear status");
1039         if (mIsLinear == null) {
1040             throw new IllegalStateException("isLinear status is empty");
1041         }
1042         return mIsLinear;
1043     }
1044 
1045     /**
1046      * Gets is the Short Frames enabled or not.
1047      *
1048      * <p>This query is only supported by Tuner HAL 1.1 or higher. Use
1049      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1050      */
isShortFramesEnabled()1051     public boolean isShortFramesEnabled() {
1052         TunerVersionChecker.checkHigherOrEqualVersionTo(
1053                 TunerVersionChecker.TUNER_VERSION_1_1, "isShortFramesEnabled status");
1054         if (mIsShortFrames == null) {
1055             throw new IllegalStateException("isShortFramesEnabled status is empty");
1056         }
1057         return mIsShortFrames;
1058     }
1059 
1060     /**
1061      * Gets ISDB-T mode.
1062      *
1063      * <p>This query is only supported by Tuner HAL 2.0 or higher. Unsupported version or if HAL
1064      * doesn't return ISDB-T mode status will throw IllegalStateException. Use
1065      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1066      */
1067     @IsdbtFrontendSettings.Mode
getIsdbtMode()1068     public int getIsdbtMode() {
1069         TunerVersionChecker.checkHigherOrEqualVersionTo(
1070                 TunerVersionChecker.TUNER_VERSION_2_0, "IsdbtMode status");
1071         if (mIsdbtMode == null) {
1072             throw new IllegalStateException("IsdbtMode status is empty");
1073         }
1074         return mIsdbtMode;
1075     }
1076 
1077     /**
1078      * Gets ISDB-T partial reception flag.
1079      *
1080      * <p>This query is only supported by Tuner HAL 2.0 or higher. Unsupported version or if HAL
1081      * doesn't return partial reception flag status will throw IllegalStateException. Use
1082      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1083      */
1084     @IsdbtFrontendSettings.PartialReceptionFlag
getIsdbtPartialReceptionFlag()1085     public int getIsdbtPartialReceptionFlag() {
1086         TunerVersionChecker.checkHigherOrEqualVersionTo(
1087                 TunerVersionChecker.TUNER_VERSION_2_0, "IsdbtPartialReceptionFlag status");
1088         if (mIsdbtPartialReceptionFlag == null) {
1089             throw new IllegalStateException("IsdbtPartialReceptionFlag status is empty");
1090         }
1091         return mIsdbtPartialReceptionFlag;
1092     }
1093 
1094     /**
1095      * Gets stream ids included in a transponder.
1096      *
1097      * <p>This query is only supported by Tuner HAL 2.0 or higher. Unsupported version or if HAL
1098      * doesn't return stream ids will throw IllegalStateException. Use
1099      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1100      */
1101     @SuppressLint("ArrayReturn")
1102     @NonNull
getStreamIds()1103     public int[] getStreamIds() {
1104         TunerVersionChecker.checkHigherOrEqualVersionTo(
1105                 TunerVersionChecker.TUNER_VERSION_2_0, "stream ids status");
1106         if (mStreamIds == null) {
1107             throw new IllegalStateException("stream ids are empty");
1108         }
1109         return mStreamIds;
1110     }
1111 
1112     /**
1113      * Gets DVB-T cell ids.
1114      *
1115      * <p>This query is only supported by Tuner HAL 2.0 or higher. Unsupported version or if HAL
1116      * doesn't return cell ids will throw IllegalStateException. Use
1117      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1118      */
1119     @SuppressLint("ArrayReturn")
1120     @NonNull
getDvbtCellIds()1121     public int[] getDvbtCellIds() {
1122         TunerVersionChecker.checkHigherOrEqualVersionTo(
1123                 TunerVersionChecker.TUNER_VERSION_2_0, "dvbt cell ids status");
1124         if (mDvbtCellIds == null) {
1125             throw new IllegalStateException("dvbt cell ids are empty");
1126         }
1127         return mDvbtCellIds;
1128     }
1129 
1130     /**
1131      * Gets a list of all PLPs information of ATSC3 frontend, which includes both tuned and not
1132      * tuned PLPs for currently watching service.
1133      *
1134      * <p>This query is only supported by Tuner HAL 2.0 or higher. Unsupported version will throw
1135      * UnsupportedOperationException. Use {@link TunerVersionChecker#getTunerVersion()} to check
1136      * the version.
1137      *
1138      * @return a list of all PLPs information. It is empty if HAL doesn't return all PLPs
1139      *         information status.
1140      */
1141     @NonNull
getAllAtsc3PlpInfo()1142     public List<Atsc3PlpInfo> getAllAtsc3PlpInfo() {
1143         if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
1144                     TunerVersionChecker.TUNER_VERSION_2_0, "Atsc3PlpInfo all status")) {
1145             throw new UnsupportedOperationException("Atsc3PlpInfo all status is empty");
1146         }
1147         if (mAllPlpInfo == null) {
1148             return Collections.EMPTY_LIST;
1149         }
1150         return Arrays.asList(mAllPlpInfo);
1151     }
1152 
1153     /**
1154      * Information of each tuning Physical Layer Pipes.
1155      */
1156     public static class Atsc3PlpTuningInfo {
1157         private final int mPlpId;
1158         private final boolean mIsLocked;
1159         private final int mUec;
1160 
Atsc3PlpTuningInfo(int plpId, boolean isLocked, int uec)1161         private Atsc3PlpTuningInfo(int plpId, boolean isLocked, int uec) {
1162             mPlpId = plpId;
1163             mIsLocked = isLocked;
1164             mUec = uec;
1165         }
1166 
1167         /**
1168          * Gets Physical Layer Pipe ID.
1169          */
getPlpId()1170         public int getPlpId() {
1171             return mPlpId;
1172         }
1173         /**
1174          * Gets Demod Lock/Unlock status of this particular PLP.
1175          */
isLocked()1176         public boolean isLocked() {
1177             return mIsLocked;
1178         }
1179         /**
1180          * Gets Uncorrectable Error Counts (UEC) of this particular PLP since last tune operation.
1181          */
getUec()1182         public int getUec() {
1183             return mUec;
1184         }
1185     }
1186 
1187     /**
1188      * Gets the IPTV content URL.
1189      *
1190      * @return A String URL in the format protocol://ip:port (udp://127.0.0.1:3000).
1191      *
1192      * <p>This query is only supported by Tuner HAL 3.0 or higher. Use
1193      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1194      */
1195     @NonNull
getIptvContentUrl()1196     public String getIptvContentUrl() {
1197         TunerVersionChecker.checkHigherOrEqualVersionTo(
1198                 TunerVersionChecker.TUNER_VERSION_3_0, "IptvContentUrl status");
1199         if (mIptvContentUrl == null) {
1200             throw new IllegalStateException("IptvContentUrl status is empty");
1201         }
1202         return mIptvContentUrl;
1203     }
1204 
1205     /**
1206      * Gets the number of packets lost.
1207      *
1208      * @return A long value representing the number of packets lost in transmission.
1209      *
1210      * <p>This query is only supported by Tuner HAL 3.0 or higher. Use
1211      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1212      */
1213     @IntRange(from = 0)
getIptvPacketsLost()1214     public long getIptvPacketsLost() {
1215         TunerVersionChecker.checkHigherOrEqualVersionTo(
1216                 TunerVersionChecker.TUNER_VERSION_3_0, "IptvPacketsLost status");
1217         if (mIptvPacketsLost == null) {
1218             throw new IllegalStateException("IptvPacketsLost status is empty");
1219         }
1220         return mIptvPacketsLost;
1221     }
1222 
1223     /**
1224      * Gets the number of packets received.
1225      *
1226      * @return A long value representing the number of packets received.
1227      *
1228      * <p>This query is only supported by Tuner HAL 3.0 or higher. Use
1229      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1230      */
1231     @IntRange(from = 0)
getIptvPacketsReceived()1232     public long getIptvPacketsReceived() {
1233         TunerVersionChecker.checkHigherOrEqualVersionTo(
1234                 TunerVersionChecker.TUNER_VERSION_3_0, "IptvPacketsReceived status");
1235         if (mIptvPacketsReceived == null) {
1236             throw new IllegalStateException("IptvPacketsReceived status is empty");
1237         }
1238         return mIptvPacketsReceived;
1239     }
1240 
1241     /**
1242      * Gets the worst jitter.
1243      *
1244      * @return An integer representing worst jitter recorded (in milliseconds).
1245      *
1246      * <p>This query is only supported by Tuner HAL 3.0 or higher. Use
1247      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1248      */
1249     @IntRange(from = 0)
getIptvWorstJitterMillis()1250     public int getIptvWorstJitterMillis() {
1251         TunerVersionChecker.checkHigherOrEqualVersionTo(
1252                 TunerVersionChecker.TUNER_VERSION_3_0, "IptvWorstJitterMs status");
1253         if (mIptvWorstJitterMs == null) {
1254             throw new IllegalStateException("IptvWorstJitterMs status is empty");
1255         }
1256         return mIptvWorstJitterMs;
1257     }
1258 
1259     /**
1260      * Gets the average jitter.
1261      *
1262      * @return An integer representing average jitter recorded (in milliseconds).
1263      *
1264      * <p>This query is only supported by Tuner HAL 3.0 or higher. Use
1265      * {@link TunerVersionChecker#getTunerVersion()} to check the version.
1266      */
1267     @IntRange(from = 0)
getIptvAverageJitterMillis()1268     public int getIptvAverageJitterMillis() {
1269         TunerVersionChecker.checkHigherOrEqualVersionTo(
1270                 TunerVersionChecker.TUNER_VERSION_3_0, "IptvAverageJitterMs status");
1271         if (mIptvAverageJitterMs == null) {
1272             throw new IllegalStateException("IptvAverageJitterMs status is empty");
1273         }
1274         return mIptvAverageJitterMs;
1275     }
1276 }
1277