下面列出了android.telephony.NeighboringCellInfo#UNKNOWN_RSSI 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Description: TODO: add more info
*
* Issues:
*
* [ ] Getting and comparing signal strengths between different RATs can be very
* tricky, since they all return different ranges of values. AOS doesn't
* specify very clearly what exactly is returned, even though people have
* a good idea, by trial and error.
*
* See note in : SignalStrengthTracker.java
*
* Notes:
*
*
*
*/
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
// Update Signal Strength
if (signalStrength.isGsm()) {
int dbm;
if (signalStrength.getGsmSignalStrength() <= 2 ||
signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
// Unknown signal strength, get it another way
String[] bits = signalStrength.toString().split(" ");
dbm = Integer.parseInt(bits[9]);
} else {
dbm = signalStrength.getGsmSignalStrength();
}
mDevice.setSignalDbm(dbm);
} else {
int evdoDbm = signalStrength.getEvdoDbm();
int cdmaDbm = signalStrength.getCdmaDbm();
// Use lowest signal to be conservative
mDevice.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
}
// Send it to signal tracker
signalStrengthTracker.registerSignalStrength(mDevice.mCell.getCID(), mDevice.getSignalDBm());
//signalStrengthTracker.isMysterious(mDevice.mCell.getCID(), mDevice.getSignalDBm());
}
private void updateGsm(Cell cell, int asu) {
Timber.d("update(): Updating GSM signal strength = %s", asu);
if (asu == NeighboringCellInfo.UNKNOWN_RSSI)
asu = Cell.UNKNOWN_SIGNAL;
// NOTE: for GSM asu is always positive but RSSI negative
if (asu >= 0)
cell.setGsmLocationSignal(asu, UnitConverter.convertGsmAsuToDbm(asu));
else
cell.setGsmLocationSignal(UnitConverter.convertGsmDbmToAsu(asu), asu);
}
private void updateLte(Cell cell, int dbm) {
Timber.d("update(): Updating LTE signal strength = %s", dbm);
if (dbm == NeighboringCellInfo.UNKNOWN_RSSI)
dbm = Cell.UNKNOWN_SIGNAL;
// NOTE: for LTE asu is always positive but RSRP negative
if (dbm >= 0)
cell.setGsmLocationSignal(dbm, UnitConverter.convertLteAsuToDbm(dbm));
else
cell.setGsmLocationSignal(UnitConverter.convertLteDbmToAsu(dbm), dbm);
}
public static int convertGsmDbmToAsu(int dbm) {
if (dbm == Cell.UNKNOWN_SIGNAL || dbm == NeighboringCellInfo.UNKNOWN_RSSI)
return Cell.UNKNOWN_SIGNAL;
if (dbm <= -113)
return 0;
int asu = (dbm + 113) / 2;
if (asu > 31)
return 31;
return asu;
}
public static int convertLteAsuToDbm(int asu) {
if (asu == Cell.UNKNOWN_SIGNAL || asu == NeighboringCellInfo.UNKNOWN_RSSI)
return Cell.UNKNOWN_SIGNAL;
if (asu <= 0)
return -140;
if (asu >= 97)
return -43;
return asu - 140;
}
public static int convertLteDbmToAsu(int dbm) {
if (dbm == Cell.UNKNOWN_SIGNAL || dbm == NeighboringCellInfo.UNKNOWN_RSSI)
return Cell.UNKNOWN_SIGNAL;
if (dbm <= -140)
return 0;
if (dbm >= -43)
return 97;
return dbm + 140;
}
public static int convertGsmAsuToDbm(int asu) {
if (asu == Cell.UNKNOWN_SIGNAL || asu == NeighboringCellInfo.UNKNOWN_RSSI)
return Cell.UNKNOWN_SIGNAL;
return 2 * asu - 113;
}