In the Android system, the code for displaying the number of signal strength cells in the mobile phone is
Frameworks \ base \ telephony \ Java \ Android \ telephony \ signalstrength. Java
Getlevel () function, which is mainly used to obtain the signal strength.
public int getLevel() { int level; if (isGsm) { level = getLteLevel(); if (level == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { level = getGsmLevel(); } } else { int cdmaLevel = getCdmaLevel(); int evdoLevel = getEvdoLevel(); if (evdoLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { /* We don't know evdo, use cdma */ level = cdmaLevel; } else if (cdmaLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { /* We don't know cdma, use evdo */ level = evdoLevel; } else { /* We know both, use the lowest level */ //level = cdmaLevel < evdoLevel ? cdmaLevel : evdoLevel; level = cdmaLevel > evdoLevel ? cdmaLevel : evdoLevel; } } if (DBG) log("getLevel=" + level); return level; }
Getcdmalevel () obtains cdmalevel, and also has the getevdolevel () function. In the previous function, the signal display intensity is determined by comparing the evdo and CDMA strengths, that is, the number of signal cells we see in the notification bar.
public int getCdmaLevel() { 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 + ",cdmaDbm=" + cdmaDbm + ",cdmaEcio=" +cdmaEcio); return level; }