zoukankan      html  css  js  c++  java
  • Android手机信号

    <3G与2G信号区分>

    <BatteryStatsImpl.java>

    if (!signalStrength.isGsm()) {

       int dBm = signalStrength.getCdmaDbm();
       if (dBm >= -75) bin = SIGNAL_STRENGTH_GREAT;
       else if (dBm >= -85) bin = SIGNAL_STRENGTH_GOOD;
       else if (dBm >= -95) bin = SIGNAL_STRENGTH_MODERATE;
       else if (dBm >= -100) bin = SIGNAL_STRENGTH_POOR;
       else bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
    } else {
       int asu = signalStrength.getGsmSignalStrength();
       if (asu < 0 || asu >= 99) bin = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
       else if (asu >= 16) bin = SIGNAL_STRENGTH_GREAT;
       else if (asu >= 8) bin = SIGNAL_STRENGTH_GOOD;
       else if (asu >= 4) bin = SIGNAL_STRENGTH_MODERATE;
       else bin = SIGNAL_STRENGTH_POOR;

    }

    <Phone.java>

    GSM信号单位<dBm-asu>换算公式:dBm = -113 -2*asu;

    /**
    * Get current signal strength. No change notification available on this
    * interface. Use <code>PhoneStateNotifier</code> or an equivalent.
    * An ASU is 0-31 or -1 if unknown (for GSM, dBm = -113 - 2 * asu).
    * The following special values are defined:</p>
    * <ul><li>0 means "-113 dBm or less".</li>
    * <li>31 means "-51 dBm or greater".</li></ul>
    *
    * @return Current signal strength as SignalStrength
    */
    SignalStrength getSignalStrength();


    其它信息:

    4G:

    String ssignal = signalStrength.toString();
    String[] parts = ssignal.split(" ");



    String ssignal = signalStrength.toString();


    String[] parts = ssignal.split(" ");
    The parts[] array will then contain these elements:


    part[0] = "Signalstrength:"  _ignore this, it's just the title_
    parts[1] = GsmSignalStrength
    parts[2] = GsmBitErrorRate
    parts[3] = CdmaDbm
    parts[4] = CdmaEcio
    parts[5] = EvdoDbm
    parts[6] = EvdoEcio
    parts[7] = EvdoSnr
    parts[8] = LteSignalStrength
    parts[9] = LteRsrp
    parts[10] = LteRsrq
    parts[11] = LteRssnr
    parts[12] = LteCqi
    parts[13] = gsm|lte
    parts[14] = _not really sure what this number is_

    So, LTEdBm is :
    TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
    int dbm = 0;
    if ( tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE){
       dbm = Integer.parseInt(parts[8])*2-113;
    }
    else{
       if (signalStrength.getGsmSignalStrength() != 99) {
                       int intdbm = -113 + 2
                               * signalStrength.getGsmSignalStrength();
                       dbm = Integer.toString(intdbm);
                   }
    }


    //GSM信号单位<dBm-asu>换算公式:dBm = -113 +2*asu;


    参考:

    http://code.taobao.org/p/cnandroiddocs/src/trunk/telephony/java/android/telephony/CellSignalStrengthLte.java

  • 相关阅读:
    2017.9.29 ubuntu安装mysql服务
    如何在树莓派上安装mjpeg-streamer(针对摄像头为UVC的)
    2016.9.22感想及收获
    GL-iNET路由器如何安装DDNS服务
    2016.7.5 记项目过程中犯的一个从未察觉的低级错误
    C++课程笔记 Lesson 01
    关于Jlink在linux系统下连接错误的解决方法
    如何通过命令提示符进入MySQL服务器
    java面试题
    hive面试题
  • 原文地址:https://www.cnblogs.com/vegetate/p/9997320.html
Copyright © 2011-2022 走看看