FileDocCategorySizeDatePackage
CellSignalStrengthGsm.javaAPI DocAndroid 5.1 API6533Thu Mar 12 22:22:42 GMT 2015android.telephony

CellSignalStrengthGsm

public final class CellSignalStrengthGsm extends CellSignalStrength implements android.os.Parcelable
GSM signal strength related information.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DBG
private static final int
GSM_SIGNAL_STRENGTH_GREAT
private static final int
GSM_SIGNAL_STRENGTH_GOOD
private static final int
GSM_SIGNAL_STRENGTH_MODERATE
private int
mSignalStrength
private int
mBitErrorRate
public static final Parcelable.Creator
CREATOR
Implement the Parcelable interface
Constructors Summary
public CellSignalStrengthGsm()
Empty constructor

hide

   // bit error rate (0-7, 99) as defined in TS 27.007 8.5

            
      
        setDefaultValues();
    
private CellSignalStrengthGsm(android.os.Parcel in)
Construct a SignalStrength object from the given parcel where the token is already been processed.

        mSignalStrength = in.readInt();
        mBitErrorRate = in.readInt();
        if (DBG) log("CellSignalStrengthGsm(Parcel): " + toString());
    
public CellSignalStrengthGsm(int ss, int ber)
Constructor

hide

        initialize(ss, ber);
    
public CellSignalStrengthGsm(CellSignalStrengthGsm s)
Copy constructors

param
s Source SignalStrength
hide

        copyFrom(s);
    
Methods Summary
public android.telephony.CellSignalStrengthGsmcopy()

hide

        return new CellSignalStrengthGsm(this);
    
protected voidcopyFrom(android.telephony.CellSignalStrengthGsm s)

hide

        mSignalStrength = s.mSignalStrength;
        mBitErrorRate = s.mBitErrorRate;
    
public intdescribeContents()
Implement the Parcelable interface

        return 0;
    
public booleanequals(java.lang.Object o)

        CellSignalStrengthGsm s;

        try {
            s = (CellSignalStrengthGsm) o;
        } catch (ClassCastException ex) {
            return false;
        }

        if (o == null) {
            return false;
        }

        return mSignalStrength == s.mSignalStrength && mBitErrorRate == s.mBitErrorRate;
    
public intgetAsuLevel()
Get the signal level as an asu value between 0..31, 99 is unknown Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69

        // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
        // asu = 0 (-113dB or less) is very weak
        // signal, its better to show 0 bars to the user in such cases.
        // asu = 99 is a special case, where the signal strength is unknown.
        int level = mSignalStrength;
        if (DBG) log("getAsuLevel=" + level);
        return level;
    
public intgetDbm()
Get the signal strength as dBm

        int dBm;

        int level = mSignalStrength;
        int asu = (level == 99 ? Integer.MAX_VALUE : level);
        if (asu != Integer.MAX_VALUE) {
            dBm = -113 + (2 * asu);
        } else {
            dBm = Integer.MAX_VALUE;
        }
        if (DBG) log("getDbm=" + dBm);
        return dBm;
    
public intgetLevel()
Get signal level as an int from 0..4

        int level;

        // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
        // asu = 0 (-113dB or less) is very weak
        // signal, its better to show 0 bars to the user in such cases.
        // asu = 99 is a special case, where the signal strength is unknown.
        int asu = mSignalStrength;
        if (asu <= 2 || asu == 99) level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
        else if (asu >= GSM_SIGNAL_STRENGTH_GREAT) level = SIGNAL_STRENGTH_GREAT;
        else if (asu >= GSM_SIGNAL_STRENGTH_GOOD)  level = SIGNAL_STRENGTH_GOOD;
        else if (asu >= GSM_SIGNAL_STRENGTH_MODERATE)  level = SIGNAL_STRENGTH_MODERATE;
        else level = SIGNAL_STRENGTH_POOR;
        if (DBG) log("getLevel=" + level);
        return level;
    
public inthashCode()

        int primeNum = 31;
        return (mSignalStrength * primeNum) + (mBitErrorRate * primeNum);
    
public voidinitialize(int ss, int ber)
Initialize all the values

param
ss SignalStrength as ASU value
param
ber is Bit Error Rate
hide

        mSignalStrength = ss;
        mBitErrorRate = ber;
    
private static voidlog(java.lang.String s)
log


          
         
        Rlog.w(LOG_TAG, s);
    
public voidsetDefaultValues()

hide

        mSignalStrength = Integer.MAX_VALUE;
        mBitErrorRate = Integer.MAX_VALUE;
    
public java.lang.StringtoString()

return
string representation.

        return "CellSignalStrengthGsm:"
                + " ss=" + mSignalStrength
                + " ber=" + mBitErrorRate;
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Implement the Parcelable interface

        if (DBG) log("writeToParcel(Parcel, int): " + toString());
        dest.writeInt(mSignalStrength);
        dest.writeInt(mBitErrorRate);