From 341508ff3a2b4312c992fab8f50597a1fc6f1093 Mon Sep 17 00:00:00 2001 From: shubang Date: Mon, 13 Jan 2020 21:16:32 -0800 Subject: [PATCH] Clean up FrontendCapabilities, FrontendInfo, and FrontendStatus Test: make Change-Id: I3e4413071056b7cd5ca1017a6f3296e2f6e5cc22 --- media/java/android/media/tv/tuner/Tuner.java | 8 +- .../media/tv/tuner/TunerConstants.java | 150 ------ .../frontend/AnalogFrontendCapabilities.java | 15 +- .../tuner/frontend/FrontendCapabilities.java | 3 +- .../media/tv/tuner/frontend/FrontendInfo.java | 81 +-- .../tv/tuner/frontend/FrontendStatus.java | 468 +++++++++++++----- 6 files changed, 407 insertions(+), 318 deletions(-) diff --git a/media/java/android/media/tv/tuner/Tuner.java b/media/java/android/media/tv/tuner/Tuner.java index 6f5ba849f8f8f..5a72b221ce08a 100644 --- a/media/java/android/media/tv/tuner/Tuner.java +++ b/media/java/android/media/tv/tuner/Tuner.java @@ -119,7 +119,7 @@ public final class Tuner implements AutoCloseable { private native int nativeStopScan(); private native int nativeSetLnb(int lnbId); private native int nativeSetLna(boolean enable); - private native FrontendStatus[] nativeGetFrontendStatus(int[] statusTypes); + private native FrontendStatus nativeGetFrontendStatus(int[] statusTypes); private native int nativeGetAvSyncHwId(Filter filter); private native long nativeGetAvSyncTime(int avSyncId); private native int nativeConnectCiCam(int ciCamId); @@ -297,11 +297,11 @@ public final class Tuner implements AutoCloseable { * * @param statusTypes an array of status type which the caller request. * - * @return statuses an array of statuses which response the caller's - * request. + * @return statuses which response the caller's requests. * @hide */ - public FrontendStatus[] getFrontendStatus(int[] statusTypes) { + @Nullable + public FrontendStatus getFrontendStatus(int[] statusTypes) { return nativeGetFrontendStatus(statusTypes); } diff --git a/media/java/android/media/tv/tuner/TunerConstants.java b/media/java/android/media/tv/tuner/TunerConstants.java index 202b979c4d66b..19cfa32eccd65 100644 --- a/media/java/android/media/tv/tuner/TunerConstants.java +++ b/media/java/android/media/tv/tuner/TunerConstants.java @@ -322,156 +322,6 @@ public final class TunerConstants { public static final int FRONTEND_SCAN_BLIND = Constants.FrontendScanType.SCAN_BLIND; - /** @hide */ - @IntDef({FRONTEND_STATUS_TYPE_DEMOD_LOCK, FRONTEND_STATUS_TYPE_SNR, FRONTEND_STATUS_TYPE_BER, - FRONTEND_STATUS_TYPE_PER, FRONTEND_STATUS_TYPE_PRE_BER, - FRONTEND_STATUS_TYPE_SIGNAL_QUALITY, FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH, - FRONTEND_STATUS_TYPE_SYMBOL_RATE, FRONTEND_STATUS_TYPE_FEC, - FRONTEND_STATUS_TYPE_MODULATION, FRONTEND_STATUS_TYPE_SPECTRAL, - FRONTEND_STATUS_TYPE_LNB_VOLTAGE, FRONTEND_STATUS_TYPE_PLP_ID, - FRONTEND_STATUS_TYPE_EWBS, FRONTEND_STATUS_TYPE_AGC, FRONTEND_STATUS_TYPE_LNA, - FRONTEND_STATUS_TYPE_LAYER_ERROR, FRONTEND_STATUS_TYPE_VBER_CN, - FRONTEND_STATUS_TYPE_LBER_CN, FRONTEND_STATUS_TYPE_XER_CN, FRONTEND_STATUS_TYPE_MER, - FRONTEND_STATUS_TYPE_FREQ_OFFSET, FRONTEND_STATUS_TYPE_HIERARCHY, - FRONTEND_STATUS_TYPE_RF_LOCK, FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO}) - @Retention(RetentionPolicy.SOURCE) - public @interface FrontendStatusType {} - - /** - * Lock status for Demod. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_DEMOD_LOCK = - Constants.FrontendStatusType.DEMOD_LOCK; - /** - * Signal to Noise Ratio. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_SNR = Constants.FrontendStatusType.SNR; - /** - * Bit Error Ratio. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_BER = Constants.FrontendStatusType.BER; - /** - * Packages Error Ratio. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_PER = Constants.FrontendStatusType.PER; - /** - * Bit Error Ratio before FEC. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_PRE_BER = Constants.FrontendStatusType.PRE_BER; - /** - * Signal Quality (0..100). Good data over total data in percent can be - * used as a way to present Signal Quality. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_SIGNAL_QUALITY = - Constants.FrontendStatusType.SIGNAL_QUALITY; - /** - * Signal Strength. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH = - Constants.FrontendStatusType.SIGNAL_STRENGTH; - /** - * Symbol Rate. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_SYMBOL_RATE = - Constants.FrontendStatusType.SYMBOL_RATE; - /** - * Forward Error Correction Type. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_FEC = Constants.FrontendStatusType.FEC; - /** - * Modulation Type. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_MODULATION = - Constants.FrontendStatusType.MODULATION; - /** - * Spectral Inversion Type. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_SPECTRAL = Constants.FrontendStatusType.SPECTRAL; - /** - * LNB Voltage. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_LNB_VOLTAGE = - Constants.FrontendStatusType.LNB_VOLTAGE; - /** - * Physical Layer Pipe ID. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_PLP_ID = Constants.FrontendStatusType.PLP_ID; - /** - * Status for Emergency Warning Broadcasting System. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_EWBS = Constants.FrontendStatusType.EWBS; - /** - * Automatic Gain Control. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_AGC = Constants.FrontendStatusType.AGC; - /** - * Low Noise Amplifier. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_LNA = Constants.FrontendStatusType.LNA; - /** - * Error status by layer. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_LAYER_ERROR = - Constants.FrontendStatusType.LAYER_ERROR; - /** - * CN value by VBER. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_VBER_CN = Constants.FrontendStatusType.VBER_CN; - /** - * CN value by LBER. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_LBER_CN = Constants.FrontendStatusType.LBER_CN; - /** - * CN value by XER. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_XER_CN = Constants.FrontendStatusType.XER_CN; - /** - * Moduration Error Ratio. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_MER = Constants.FrontendStatusType.MER; - /** - * Difference between tuning frequency and actual locked frequency. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_FREQ_OFFSET = - Constants.FrontendStatusType.FREQ_OFFSET; - /** - * Hierarchy for DVBT. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_HIERARCHY = Constants.FrontendStatusType.HIERARCHY; - /** - * Lock status for RF. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_RF_LOCK = Constants.FrontendStatusType.RF_LOCK; - /** - * PLP information in a frequency band for ATSC3.0 frontend. - * @hide - */ - public static final int FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO = - Constants.FrontendStatusType.ATSC3_PLP_INFO; /** @hide */ @LongDef({FEC_UNDEFINED, FEC_AUTO, FEC_1_2, FEC_1_3, FEC_1_4, FEC_1_5, FEC_2_3, FEC_2_5, diff --git a/media/java/android/media/tv/tuner/frontend/AnalogFrontendCapabilities.java b/media/java/android/media/tv/tuner/frontend/AnalogFrontendCapabilities.java index d92c7869b0c48..aa64df56f5560 100644 --- a/media/java/android/media/tv/tuner/frontend/AnalogFrontendCapabilities.java +++ b/media/java/android/media/tv/tuner/frontend/AnalogFrontendCapabilities.java @@ -17,26 +17,31 @@ package android.media.tv.tuner.frontend; /** - * Analog Capabilities. + * Capabilities for analog tuners. + * * @hide */ public class AnalogFrontendCapabilities extends FrontendCapabilities { + @AnalogFrontendSettings.SignalType private final int mTypeCap; + @AnalogFrontendSettings.SifStandard private final int mSifStandardCap; - AnalogFrontendCapabilities(int typeCap, int sifStandardCap) { + // Called by JNI code. + private AnalogFrontendCapabilities(int typeCap, int sifStandardCap) { mTypeCap = typeCap; mSifStandardCap = sifStandardCap; } + /** - * Gets type capability. + * Gets analog signal type capability. */ @AnalogFrontendSettings.SignalType - public int getTypeCapability() { + public int getSignalTypeCapability() { return mTypeCap; } /** - * Gets SIF standard capability. + * Gets Standard Interchange Format (SIF) capability. */ @AnalogFrontendSettings.SifStandard public int getSifStandardCapability() { diff --git a/media/java/android/media/tv/tuner/frontend/FrontendCapabilities.java b/media/java/android/media/tv/tuner/frontend/FrontendCapabilities.java index 7350bc0c39142..e4f66b80d0086 100644 --- a/media/java/android/media/tv/tuner/frontend/FrontendCapabilities.java +++ b/media/java/android/media/tv/tuner/frontend/FrontendCapabilities.java @@ -17,7 +17,8 @@ package android.media.tv.tuner.frontend; /** - * Frontend Capabilities. + * Frontend capabilities. + * * @hide */ public abstract class FrontendCapabilities { diff --git a/media/java/android/media/tv/tuner/frontend/FrontendInfo.java b/media/java/android/media/tv/tuner/frontend/FrontendInfo.java index 99e8dd2fe31fe..360c84a383e03 100644 --- a/media/java/android/media/tv/tuner/frontend/FrontendInfo.java +++ b/media/java/android/media/tv/tuner/frontend/FrontendInfo.java @@ -16,77 +16,98 @@ package android.media.tv.tuner.frontend; +import android.annotation.NonNull; import android.media.tv.tuner.frontend.FrontendSettings.Type; +import android.media.tv.tuner.frontend.FrontendStatus.FrontendStatusType; +import android.util.Range; /** - * Frontend info. + * This class is used to specify meta information of a frontend. + * * @hide */ public class FrontendInfo { private final int mId; private final int mType; - private final int mMinFrequency; - private final int mMaxFrequency; - private final int mMinSymbolRate; - private final int mMaxSymbolRate; + private final Range mFrequencyRange; + private final Range mSymbolRateRange; private final int mAcquireRange; private final int mExclusiveGroupId; private final int[] mStatusCaps; private final FrontendCapabilities mFrontendCap; - FrontendInfo(int id, int type, int minFrequency, int maxFrequency, int minSymbolRate, + private FrontendInfo(int id, int type, int minFrequency, int maxFrequency, int minSymbolRate, int maxSymbolRate, int acquireRange, int exclusiveGroupId, int[] statusCaps, FrontendCapabilities frontendCap) { mId = id; mType = type; - mMinFrequency = minFrequency; - mMaxFrequency = maxFrequency; - mMinSymbolRate = minSymbolRate; - mMaxSymbolRate = maxSymbolRate; + mFrequencyRange = new Range<>(minFrequency, maxFrequency); + mSymbolRateRange = new Range<>(minSymbolRate, maxSymbolRate); mAcquireRange = acquireRange; mExclusiveGroupId = exclusiveGroupId; mStatusCaps = statusCaps; mFrontendCap = frontendCap; } - /** Gets frontend ID. */ + /** + * Gets frontend ID. + */ public int getId() { return mId; } - /** Gets frontend type. */ + /** + * Gets frontend type. + */ @Type public int getType() { return mType; } - /** Gets min frequency. */ - public int getMinFrequency() { - return mMinFrequency; + + /** + * Gets supported frequency range in Hz. + */ + @NonNull + public Range getFrequencyRange() { + return mFrequencyRange; } - /** Gets max frequency. */ - public int getMaxFrequency() { - return mMaxFrequency; + + /** + * Gets symbol rate range in symbols per second. + */ + @NonNull + public Range getSymbolRateRange() { + return mSymbolRateRange; } - /** Gets min symbol rate. */ - public int getMinSymbolRate() { - return mMinSymbolRate; - } - /** Gets max symbol rate. */ - public int getMaxSymbolRate() { - return mMaxSymbolRate; - } - /** Gets acquire range. */ + + /** + * Gets acquire range in Hz. + * + *

The maximum frequency difference the frontend can detect. + */ public int getAcquireRange() { return mAcquireRange; } - /** Gets exclusive group ID. */ + /** + * Gets exclusive group ID. + * + *

Frontends with the same exclusive group ID indicates they can't function at same time. For + * instance, they share some hardware modules. + */ public int getExclusiveGroupId() { return mExclusiveGroupId; } - /** Gets status capabilities. */ + /** + * Gets status capabilities. + * + * @return An array of supported status types. + */ + @FrontendStatusType public int[] getStatusCapabilities() { return mStatusCaps; } - /** Gets frontend capability. */ + /** + * Gets frontend capabilities. + */ public FrontendCapabilities getFrontendCapability() { return mFrontendCap; } diff --git a/media/java/android/media/tv/tuner/frontend/FrontendStatus.java b/media/java/android/media/tv/tuner/frontend/FrontendStatus.java index f973d88f8f457..088adff630a48 100644 --- a/media/java/android/media/tv/tuner/frontend/FrontendStatus.java +++ b/media/java/android/media/tv/tuner/frontend/FrontendStatus.java @@ -16,11 +16,15 @@ package android.media.tv.tuner.frontend; +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.hardware.tv.tuner.V1_0.Constants; import android.media.tv.tuner.Lnb; -import android.media.tv.tuner.TunerConstants; import android.media.tv.tuner.TunerConstants.FrontendInnerFec; import android.media.tv.tuner.TunerConstants.FrontendModulation; -import android.media.tv.tuner.TunerConstants.FrontendStatusType; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; /** * Frontend status @@ -29,204 +33,409 @@ import android.media.tv.tuner.TunerConstants.FrontendStatusType; */ public class FrontendStatus { - private final int mType; - private final Object mValue; + /** @hide */ + @IntDef({FRONTEND_STATUS_TYPE_DEMOD_LOCK, FRONTEND_STATUS_TYPE_SNR, FRONTEND_STATUS_TYPE_BER, + FRONTEND_STATUS_TYPE_PER, FRONTEND_STATUS_TYPE_PRE_BER, + FRONTEND_STATUS_TYPE_SIGNAL_QUALITY, FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH, + FRONTEND_STATUS_TYPE_SYMBOL_RATE, FRONTEND_STATUS_TYPE_FEC, + FRONTEND_STATUS_TYPE_MODULATION, FRONTEND_STATUS_TYPE_SPECTRAL, + FRONTEND_STATUS_TYPE_LNB_VOLTAGE, FRONTEND_STATUS_TYPE_PLP_ID, + FRONTEND_STATUS_TYPE_EWBS, FRONTEND_STATUS_TYPE_AGC, FRONTEND_STATUS_TYPE_LNA, + FRONTEND_STATUS_TYPE_LAYER_ERROR, FRONTEND_STATUS_TYPE_VBER_CN, + FRONTEND_STATUS_TYPE_LBER_CN, FRONTEND_STATUS_TYPE_XER_CN, FRONTEND_STATUS_TYPE_MER, + FRONTEND_STATUS_TYPE_FREQ_OFFSET, FRONTEND_STATUS_TYPE_HIERARCHY, + FRONTEND_STATUS_TYPE_RF_LOCK, FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO}) + @Retention(RetentionPolicy.SOURCE) + public @interface FrontendStatusType {} - private FrontendStatus(int type, Object value) { - mType = type; - mValue = value; + /** + * Lock status for Demod. + */ + public static final int FRONTEND_STATUS_TYPE_DEMOD_LOCK = + Constants.FrontendStatusType.DEMOD_LOCK; + /** + * Signal to Noise Ratio. + */ + public static final int FRONTEND_STATUS_TYPE_SNR = Constants.FrontendStatusType.SNR; + /** + * Bit Error Ratio. + */ + public static final int FRONTEND_STATUS_TYPE_BER = Constants.FrontendStatusType.BER; + /** + * Packages Error Ratio. + */ + public static final int FRONTEND_STATUS_TYPE_PER = Constants.FrontendStatusType.PER; + /** + * Bit Error Ratio before FEC. + */ + public static final int FRONTEND_STATUS_TYPE_PRE_BER = Constants.FrontendStatusType.PRE_BER; + /** + * Signal Quality (0..100). Good data over total data in percent can be + * used as a way to present Signal Quality. + */ + public static final int FRONTEND_STATUS_TYPE_SIGNAL_QUALITY = + Constants.FrontendStatusType.SIGNAL_QUALITY; + /** + * Signal Strength. + */ + public static final int FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH = + Constants.FrontendStatusType.SIGNAL_STRENGTH; + /** + * Symbol Rate in symbols per second. + */ + public static final int FRONTEND_STATUS_TYPE_SYMBOL_RATE = + Constants.FrontendStatusType.SYMBOL_RATE; + /** + * Forward Error Correction Type. + */ + public static final int FRONTEND_STATUS_TYPE_FEC = Constants.FrontendStatusType.FEC; + /** + * Modulation Type. + */ + public static final int FRONTEND_STATUS_TYPE_MODULATION = + Constants.FrontendStatusType.MODULATION; + /** + * Spectral Inversion Type. + */ + public static final int FRONTEND_STATUS_TYPE_SPECTRAL = Constants.FrontendStatusType.SPECTRAL; + /** + * LNB Voltage. + */ + public static final int FRONTEND_STATUS_TYPE_LNB_VOLTAGE = + Constants.FrontendStatusType.LNB_VOLTAGE; + /** + * Physical Layer Pipe ID. + */ + public static final int FRONTEND_STATUS_TYPE_PLP_ID = Constants.FrontendStatusType.PLP_ID; + /** + * Status for Emergency Warning Broadcasting System. + */ + public static final int FRONTEND_STATUS_TYPE_EWBS = Constants.FrontendStatusType.EWBS; + /** + * Automatic Gain Control. + */ + public static final int FRONTEND_STATUS_TYPE_AGC = Constants.FrontendStatusType.AGC; + /** + * Low Noise Amplifier. + */ + public static final int FRONTEND_STATUS_TYPE_LNA = Constants.FrontendStatusType.LNA; + /** + * Error status by layer. + */ + public static final int FRONTEND_STATUS_TYPE_LAYER_ERROR = + Constants.FrontendStatusType.LAYER_ERROR; + /** + * CN value by VBER. + */ + public static final int FRONTEND_STATUS_TYPE_VBER_CN = Constants.FrontendStatusType.VBER_CN; + /** + * CN value by LBER. + */ + public static final int FRONTEND_STATUS_TYPE_LBER_CN = Constants.FrontendStatusType.LBER_CN; + /** + * CN value by XER. + */ + public static final int FRONTEND_STATUS_TYPE_XER_CN = Constants.FrontendStatusType.XER_CN; + /** + * Modulation Error Ratio. + */ + public static final int FRONTEND_STATUS_TYPE_MER = Constants.FrontendStatusType.MER; + /** + * Difference between tuning frequency and actual locked frequency. + */ + public static final int FRONTEND_STATUS_TYPE_FREQ_OFFSET = + Constants.FrontendStatusType.FREQ_OFFSET; + /** + * Hierarchy for DVBT. + */ + public static final int FRONTEND_STATUS_TYPE_HIERARCHY = Constants.FrontendStatusType.HIERARCHY; + /** + * Lock status for RF. + */ + public static final int FRONTEND_STATUS_TYPE_RF_LOCK = Constants.FrontendStatusType.RF_LOCK; + /** + * PLP information in a frequency band for ATSC-3.0 frontend. + */ + public static final int FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO = + Constants.FrontendStatusType.ATSC3_PLP_INFO; + + + private Boolean mIsDemodLocked; + private Integer mSnr; + private Integer mBer; + private Integer mPer; + private Integer mPerBer; + private Integer mSignalQuality; + private Integer mSignalStrength; + private Integer mSymbolRate; + private Long mInnerFec; + private Integer mModulation; + private Integer mInversion; + private Integer mLnbVoltage; + private Integer mPlpId; + private Boolean mIsEwbs; + private Integer mAgc; + private Boolean mIsLnaOn; + private boolean[] mIsLayerErrors; + private Integer mVberCn; + private Integer mLberCn; + private Integer mXerCn; + private Integer mMer; + private Integer mFreqOffset; + private Integer mHierarchy; + private Boolean mIsRfLocked; + private Atsc3PlpInfo[] mPlpInfo; + + // Constructed and fields set by JNI code. + private FrontendStatus() { } - /** Gets frontend status type. */ - @FrontendStatusType - public int getStatusType() { - return mType; - } - /** Lock status for Demod in True/False. */ - public boolean getIsDemodLocked() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_DEMOD_LOCK) { + /** + * Lock status for Demod. + */ + public boolean isDemodLocked() { + if (mIsDemodLocked == null) { throw new IllegalStateException(); } - return (Boolean) mValue; - } - /** SNR value measured by 0.001 dB. */ - public int getSnr() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_SNR) { - throw new IllegalStateException(); - } - return (int) mValue; - } - /** The number of error bit per 1 billion bits. */ - public int getBer() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_BER) { - throw new IllegalStateException(); - } - return (int) mValue; - } - /** The number of error package per 1 billion packages. */ - public int getPer() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_PER) { - throw new IllegalStateException(); - } - return (int) mValue; - } - /** The number of error bit per 1 billion bits before FEC. */ - public int getPerBer() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_PRE_BER) { - throw new IllegalStateException(); - } - return (int) mValue; - } - /** Signal Quality in percent. */ - public int getSignalQuality() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_SIGNAL_QUALITY) { - throw new IllegalStateException(); - } - return (int) mValue; - } - /** Signal Strength measured by 0.001 dBm. */ - public int getSignalStrength() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH) { - throw new IllegalStateException(); - } - return (int) mValue; - } - /** Symbols per second. */ - public int getSymbolRate() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_SYMBOL_RATE) { - throw new IllegalStateException(); - } - return (int) mValue; + return mIsDemodLocked; } /** - * Inner Forward Error Correction type as specified in ETSI EN 300 468 V1.15.1 + * Gets Signal to Noise Ratio in thousandths of a deciBel (0.001dB). + */ + public int getSnr() { + if (mSnr == null) { + throw new IllegalStateException(); + } + return mSnr; + } + /** + * Gets Bit Error Ratio. + * + *

The number of error bit per 1 billion bits. + */ + public int getBer() { + if (mBer == null) { + throw new IllegalStateException(); + } + return mBer; + } + + /** + * Gets Packages Error Ratio. + * + *

The number of error package per 1 billion packages. + */ + public int getPer() { + if (mPer == null) { + throw new IllegalStateException(); + } + return mPer; + } + /** + * Gets Bit Error Ratio before Forward Error Correction (FEC). + * + *

The number of error bit per 1 billion bits before FEC. + */ + public int getPerBer() { + if (mPerBer == null) { + throw new IllegalStateException(); + } + return mPerBer; + } + /** + * Gets Signal Quality in percent. + */ + public int getSignalQuality() { + if (mSignalQuality == null) { + throw new IllegalStateException(); + } + return mSignalQuality; + } + /** + * Gets Signal Strength in thousandths of a dBm (0.001dBm). + */ + public int getSignalStrength() { + if (mSignalStrength == null) { + throw new IllegalStateException(); + } + return mSignalStrength; + } + /** + * Gets symbol rate in symbols per second. + */ + public int getSymbolRate() { + if (mSymbolRate == null) { + throw new IllegalStateException(); + } + return mSymbolRate; + } + /** + * Gets Inner Forward Error Correction type as specified in ETSI EN 300 468 V1.15.1 * and ETSI EN 302 307-2 V1.1.1. */ @FrontendInnerFec public long getFec() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_FEC) { + if (mInnerFec == null) { throw new IllegalStateException(); } - return (long) mValue; + return mInnerFec; } - /** Modulation */ + /** + * Gets modulation. + */ @FrontendModulation public int getModulation() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_MODULATION) { + if (mModulation == null) { throw new IllegalStateException(); } - return (int) mValue; + return mModulation; } - /** Spectral Inversion for DVBC. */ + /** + * Gets Spectral Inversion for DVBC. + */ @DvbcFrontendSettings.SpectralInversion public int getSpectralInversion() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_SPECTRAL) { + if (mInversion == null) { throw new IllegalStateException(); } - return (int) mValue; + return mInversion; } - /** Power Voltage Type for LNB. */ + /** + * Gets Power Voltage Type for LNB. + */ @Lnb.Voltage public int getLnbVoltage() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_LNB_VOLTAGE) { + if (mLnbVoltage == null) { throw new IllegalStateException(); } - return (int) mValue; + return mLnbVoltage; } - /** PLP ID */ - public byte getPlpId() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_PLP_ID) { + /** + * Gets Physical Layer Pipe ID. + */ + public int getPlpId() { + if (mPlpId == null) { throw new IllegalStateException(); } - return (byte) mValue; + return mPlpId; } - /** Emergency Warning Broadcasting System */ - public boolean getIsEwbs() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_EWBS) { + /** + * Checks whether it's Emergency Warning Broadcasting System + */ + public boolean isEwbs() { + if (mIsEwbs == null) { throw new IllegalStateException(); } - return (Boolean) mValue; + return mIsEwbs; } - /** AGC value is normalized from 0 to 255. */ - public byte getAgc() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_AGC) { + /** + * Gets Automatic Gain Control value which is normalized from 0 to 255. + */ + public int getAgc() { + if (mAgc == null) { throw new IllegalStateException(); } - return (byte) mValue; + return mAgc; } - /** LNA(Low Noise Amplifier) is on or not. */ - public boolean getLnaOn() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_LNA) { + /** + * Checks LNA (Low Noise Amplifier) is on or not. + */ + public boolean isLnaOn() { + if (mIsLnaOn == null) { throw new IllegalStateException(); } - return (Boolean) mValue; + return mIsLnaOn; } - /** Error status by layer. */ - public boolean[] getIsLayerError() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_LAYER_ERROR) { + /** + * Gets Error status by layer. + */ + @NonNull + public boolean[] getLayerErrors() { + if (mIsLayerErrors == null) { throw new IllegalStateException(); } - return (boolean[]) mValue; + return mIsLayerErrors; } - /** CN value by VBER measured by 0.001 dB. */ + /** + * Gets CN value by VBER in thousandths of a deciBel (0.001dB). + */ public int getVberCn() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_VBER_CN) { + if (mVberCn == null) { throw new IllegalStateException(); } - return (int) mValue; + return mVberCn; } - /** CN value by LBER measured by 0.001 dB. */ + /** + * Gets CN value by LBER in thousandths of a deciBel (0.001dB). + */ public int getLberCn() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_LBER_CN) { + if (mLberCn == null) { throw new IllegalStateException(); } - return (int) mValue; + return mLberCn; } - /** CN value by XER measured by 0.001 dB. */ + /** + * Gets CN value by XER in thousandths of a deciBel (0.001dB). + */ public int getXerCn() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_XER_CN) { + if (mXerCn == null) { throw new IllegalStateException(); } - return (int) mValue; + return mXerCn; } - /** MER value measured by 0.001 dB. */ + /** + * Gets Modulation Error Ratio in thousandths of a deciBel (0.001dB). + */ public int getMer() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_MER) { + if (mMer == null) { throw new IllegalStateException(); } - return (int) mValue; + return mMer; } - /** Frequency difference in Hertz. */ + /** + * Gets frequency difference in Hz. + * + *

Difference between tuning frequency and actual locked frequency. + */ public int getFreqOffset() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_FREQ_OFFSET) { + if (mFreqOffset == null) { throw new IllegalStateException(); } - return (int) mValue; + return mFreqOffset; } - /** Hierarchy Type for DVBT. */ + /** + * Gets hierarchy Type for DVBT. + */ @DvbtFrontendSettings.Hierarchy public int getHierarchy() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_HIERARCHY) { + if (mHierarchy == null) { throw new IllegalStateException(); } - return (int) mValue; + return mHierarchy; } - /** Lock status for RF. */ - public boolean getIsRfLock() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_RF_LOCK) { + /** + * Gets lock status for RF. + */ + public boolean isRfLock() { + if (mIsRfLocked == null) { throw new IllegalStateException(); } - return (Boolean) mValue; + return mIsRfLocked; } - /** A list of PLP status for tuned PLPs for ATSC3 frontend. */ + /** + * Gets an array of PLP status for tuned PLPs for ATSC3 frontend. + */ + @NonNull public Atsc3PlpInfo[] getAtsc3PlpInfo() { - if (mType != TunerConstants.FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO) { + if (mPlpInfo == null) { throw new IllegalStateException(); } - return (Atsc3PlpInfo[]) mValue; + return mPlpInfo; } - /** Status for each tuning PLPs. */ + /** + * Status for each tuning Physical Layer Pipes. + */ public static class Atsc3PlpInfo { private final int mPlpId; private final boolean mIsLock; @@ -238,17 +447,20 @@ public class FrontendStatus { mUec = uec; } - /** Gets PLP IDs. */ + /** + * Gets Physical Layer Pipe ID. + */ public int getPlpId() { return mPlpId; } - /** Gets Demod Lock/Unlock status of this particular PLP. */ - public boolean getIsLock() { + /** + * Gets Demod Lock/Unlock status of this particular PLP. + */ + public boolean isLock() { return mIsLock; } /** - * Gets Uncorrectable Error Counts (UEC) of this particular PLP since last tune - * operation. + * Gets Uncorrectable Error Counts (UEC) of this particular PLP since last tune operation. */ public int getUec() { return mUec;