我正在检查CDMA设备的信号强度。任何人都可以指定signalStrength.getCdmaDbm()
返回的范围吗?最低的是-120,但对于完整的信号强度,值是多少?我最高的是-52。
最佳答案
好吧,我不确定这是否是您要查找的内容,但是在查看了Android源代码中的SignalStrength.java文件后,我注意到了一些代码,其中包含一堆cdma dbm和ecio级别的代码。
DBM
level 4 >= -75
level 3 >= -85
level 2 >= -95
level 1 >= -100
Ecio
level 4 >= -90
level 3 >= -110
level 2 >= -130
level 1 >= -150
和级别是两者中的最低者
actualLevel = (levelDbm < levelEcio) ? levelDbm : levelEcio;
但我注意到这与通知中显示的实际条形不相关。如果在3G中,则忽略此级别,并使用信噪比。
signalStrength.getEvdoSnr() // value is 0 to 8 so divide by two to get the bars
如果数据从3G下降到1倍,则使用actualLevel。
这是我的代码,用于显示显示条数。
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
if (signalStrength.isGsm()) {
if (signalStrength.getGsmSignalStrength() != 99)
signalStrengthValue = signalStrength.getGsmSignalStrength() * 2 - 113;
else
signalStrengthValue = signalStrength.getGsmSignalStrength();
} else {
final int snr = signalStrength.getEvdoSnr();
final int cdmaDbm = signalStrength.getCdmaDbm();
final int cdmaEcio = signalStrength.getCdmaEcio();
int levelDbm;
int levelEcio;
int level = 0;
if (snr == -1) {
if (cdmaDbm >= -75) levelDbm = 4;
else if (cdmaDbm >= -85) levelDbm = 3;
else if (cdmaDbm >= -95) levelDbm = 2;
else if (cdmaDbm >= -100) levelDbm = 1;
else levelDbm = 0;
// Ec/Io are in dB*10
if (cdmaEcio >= -90) levelEcio = 4;
else if (cdmaEcio >= -110) levelEcio = 3;
else if (cdmaEcio >= -130) levelEcio = 2;
else if (cdmaEcio >= -150) levelEcio = 1;
else levelEcio = 0;
level = (levelDbm < levelEcio) ? levelDbm : levelEcio;
} else {
if (snr == 7 || snr == 8) level =4;
else if (snr == 5 || snr == 6 ) level =3;
else if (snr == 3 || snr == 4) level = 2;
else if (snr ==1 || snr ==2) level =1;
}
text.setText("Bars= " + level);
}
}
在on create方法中,请在下面使用此方法,并确保 list 使用READ_PHONE_STATE。
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
AndroidPhoneStateListener phoneStateListener = new AndroidPhoneStateListener(text);
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
关于android - CDMA设备的信号强度范围(以dbm为单位),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9464671/