Number of signal strength cells displayed on the smartphone

Source: Internet
Author: User

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;    }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.