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