FileDocCategorySizeDatePackage
CellSignalStrengthCdma.javaAPI DocAndroid 5.1 API11167Thu Mar 12 22:22:42 GMT 2015android.telephony

CellSignalStrengthCdma

public final class CellSignalStrengthCdma extends CellSignalStrength implements android.os.Parcelable
Signal strength related information.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DBG
private int
mCdmaDbm
private int
mCdmaEcio
private int
mEvdoDbm
private int
mEvdoEcio
private int
mEvdoSnr
public static final Parcelable.Creator
CREATOR
Implement the Parcelable interface
Constructors Summary
public CellSignalStrengthCdma()
Empty constructor

hide

   // Valid values are 0-8.  8 is the highest signal to noise ratio

            
      
        setDefaultValues();
    
public CellSignalStrengthCdma(int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio, int evdoSnr)
Constructor

hide

        initialize(cdmaDbm, cdmaEcio, evdoDbm, evdoEcio, evdoSnr);
    
private CellSignalStrengthCdma(android.os.Parcel in)
Construct a SignalStrength object from the given parcel where the TYPE_CDMA token is already been processed.

        // CdmaDbm, CdmaEcio, EvdoDbm and EvdoEcio are written into
        // the parcel as positive values.
        // Need to convert into negative values
        mCdmaDbm = in.readInt() * -1;
        mCdmaEcio = in.readInt() * -1;
        mEvdoDbm = in.readInt() * -1;
        mEvdoEcio = in.readInt() * -1;
        mEvdoSnr = in.readInt();
        if (DBG) log("CellSignalStrengthCdma(Parcel): " + toString());
    
public CellSignalStrengthCdma(CellSignalStrengthCdma s)
Copy constructors

param
s Source SignalStrength
hide

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

hide

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

hide

        mCdmaDbm = s.mCdmaDbm;
        mCdmaEcio = s.mCdmaEcio;
        mEvdoDbm = s.mEvdoDbm;
        mEvdoEcio = s.mEvdoEcio;
        mEvdoSnr = s.mEvdoSnr;
    
public intdescribeContents()
Implement the Parcelable interface

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

        CellSignalStrengthCdma s;

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

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

        return mCdmaDbm == s.mCdmaDbm
                && mCdmaEcio == s.mCdmaEcio
                && mEvdoDbm == s.mEvdoDbm
                && mEvdoEcio == s.mEvdoEcio
                && mEvdoSnr == s.mEvdoSnr;
    
public intgetAsuLevel()
Get the signal level as an asu value between 0..97, 99 is unknown

        final int cdmaDbm = getCdmaDbm();
        final int cdmaEcio = getCdmaEcio();
        int cdmaAsuLevel;
        int ecioAsuLevel;

        if (cdmaDbm >= -75) cdmaAsuLevel = 16;
        else if (cdmaDbm >= -82) cdmaAsuLevel = 8;
        else if (cdmaDbm >= -90) cdmaAsuLevel = 4;
        else if (cdmaDbm >= -95) cdmaAsuLevel = 2;
        else if (cdmaDbm >= -100) cdmaAsuLevel = 1;
        else cdmaAsuLevel = 99;

        // Ec/Io are in dB*10
        if (cdmaEcio >= -90) ecioAsuLevel = 16;
        else if (cdmaEcio >= -100) ecioAsuLevel = 8;
        else if (cdmaEcio >= -115) ecioAsuLevel = 4;
        else if (cdmaEcio >= -130) ecioAsuLevel = 2;
        else if (cdmaEcio >= -150) ecioAsuLevel = 1;
        else ecioAsuLevel = 99;

        int level = (cdmaAsuLevel < ecioAsuLevel) ? cdmaAsuLevel : ecioAsuLevel;
        if (DBG) log("getAsuLevel=" + level);
        return level;
    
public intgetCdmaDbm()
Get the CDMA RSSI value in dBm

        return mCdmaDbm;
    
public intgetCdmaEcio()
Get the CDMA Ec/Io value in dB*10

        return mCdmaEcio;
    
public intgetCdmaLevel()
Get cdma as level 0..4

        final int cdmaDbm = getCdmaDbm();
        final int cdmaEcio = getCdmaEcio();
        int levelDbm;
        int levelEcio;

        if (cdmaDbm >= -75) levelDbm = SIGNAL_STRENGTH_GREAT;
        else if (cdmaDbm >= -85) levelDbm = SIGNAL_STRENGTH_GOOD;
        else if (cdmaDbm >= -95) levelDbm = SIGNAL_STRENGTH_MODERATE;
        else if (cdmaDbm >= -100) levelDbm = SIGNAL_STRENGTH_POOR;
        else levelDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;

        // Ec/Io are in dB*10
        if (cdmaEcio >= -90) levelEcio = SIGNAL_STRENGTH_GREAT;
        else if (cdmaEcio >= -110) levelEcio = SIGNAL_STRENGTH_GOOD;
        else if (cdmaEcio >= -130) levelEcio = SIGNAL_STRENGTH_MODERATE;
        else if (cdmaEcio >= -150) levelEcio = SIGNAL_STRENGTH_POOR;
        else levelEcio = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;

        int level = (levelDbm < levelEcio) ? levelDbm : levelEcio;
        if (DBG) log("getCdmaLevel=" + level);
        return level;
    
public intgetDbm()
Get the signal strength as dBm

        int cdmaDbm = getCdmaDbm();
        int evdoDbm = getEvdoDbm();

        // Use the lower value to be conservative
        return (cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm;
    
public intgetEvdoDbm()
Get the EVDO RSSI value in dBm

        return mEvdoDbm;
    
public intgetEvdoEcio()
Get the EVDO Ec/Io value in dB*10

        return mEvdoEcio;
    
public intgetEvdoLevel()
Get Evdo as level 0..4

        int evdoDbm = getEvdoDbm();
        int evdoSnr = getEvdoSnr();
        int levelEvdoDbm;
        int levelEvdoSnr;

        if (evdoDbm >= -65) levelEvdoDbm = SIGNAL_STRENGTH_GREAT;
        else if (evdoDbm >= -75) levelEvdoDbm = SIGNAL_STRENGTH_GOOD;
        else if (evdoDbm >= -90) levelEvdoDbm = SIGNAL_STRENGTH_MODERATE;
        else if (evdoDbm >= -105) levelEvdoDbm = SIGNAL_STRENGTH_POOR;
        else levelEvdoDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;

        if (evdoSnr >= 7) levelEvdoSnr = SIGNAL_STRENGTH_GREAT;
        else if (evdoSnr >= 5) levelEvdoSnr = SIGNAL_STRENGTH_GOOD;
        else if (evdoSnr >= 3) levelEvdoSnr = SIGNAL_STRENGTH_MODERATE;
        else if (evdoSnr >= 1) levelEvdoSnr = SIGNAL_STRENGTH_POOR;
        else levelEvdoSnr = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;

        int level = (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr;
        if (DBG) log("getEvdoLevel=" + level);
        return level;
    
public intgetEvdoSnr()
Get the signal to noise ratio. Valid values are 0-8. 8 is the highest.

        return mEvdoSnr;
    
public intgetLevel()
Get signal level as an int from 0..4

        int level;

        int cdmaLevel = getCdmaLevel();
        int evdoLevel = getEvdoLevel();
        if (evdoLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
            /* We don't know evdo, use cdma */
            level = getCdmaLevel();
        } else if (cdmaLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
            /* We don't know cdma, use evdo */
            level = getEvdoLevel();
        } else {
            /* We know both, use the lowest level */
            level = cdmaLevel < evdoLevel ? cdmaLevel : evdoLevel;
        }
        if (DBG) log("getLevel=" + level);
        return level;
    
public inthashCode()

        int primeNum = 31;
        return ((mCdmaDbm * primeNum) + (mCdmaEcio * primeNum)
                + (mEvdoDbm * primeNum) + (mEvdoEcio * primeNum) + (mEvdoSnr * primeNum));
    
public voidinitialize(int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio, int evdoSnr)
Initialize all the values

param
cdmaDbm
param
cdmaEcio
param
evdoDbm
param
evdoEcio
param
evdoSnr
hide

        mCdmaDbm = cdmaDbm;
        mCdmaEcio = cdmaEcio;
        mEvdoDbm = evdoDbm;
        mEvdoEcio = evdoEcio;
        mEvdoSnr = evdoSnr;
    
private static voidlog(java.lang.String s)
log


          
         
        Rlog.w(LOG_TAG, s);
    
public voidsetCdmaDbm(int cdmaDbm)

hide

        mCdmaDbm = cdmaDbm;
    
public voidsetCdmaEcio(int cdmaEcio)

hide

        mCdmaEcio = cdmaEcio;
    
public voidsetDefaultValues()

hide

        mCdmaDbm = Integer.MAX_VALUE;
        mCdmaEcio = Integer.MAX_VALUE;
        mEvdoDbm = Integer.MAX_VALUE;
        mEvdoEcio = Integer.MAX_VALUE;
        mEvdoSnr = Integer.MAX_VALUE;
    
public voidsetEvdoDbm(int evdoDbm)

hide

        mEvdoDbm = evdoDbm;
    
public voidsetEvdoEcio(int evdoEcio)

hide

        mEvdoEcio = evdoEcio;
    
public voidsetEvdoSnr(int evdoSnr)

hide

        mEvdoSnr = evdoSnr;
    
public java.lang.StringtoString()

return
string representation.

        return "CellSignalStrengthCdma:"
                + " cdmaDbm=" + mCdmaDbm
                + " cdmaEcio=" + mCdmaEcio
                + " evdoDbm=" + mEvdoDbm
                + " evdoEcio=" + mEvdoEcio
                + " evdoSnr=" + mEvdoSnr;
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Implement the Parcelable interface

        if (DBG) log("writeToParcel(Parcel, int): " + toString());
        // Need to multiply CdmaDbm, CdmaEcio, EvdoDbm and EvdoEcio by -1
        // to ensure consistency when reading values written here
        dest.writeInt(mCdmaDbm * -1);
        dest.writeInt(mCdmaEcio * -1);
        dest.writeInt(mEvdoDbm * -1);
        dest.writeInt(mEvdoEcio * -1);
        dest.writeInt(mEvdoSnr);