I am unable to retrieve the signal strength of a 3G (Wcdma) connection using telephonyManager.requestCellInfoUpdate() :
private fun getSignal(context: Context) {
if (context.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED
|| context.checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_DENIED) return
telephonyManager.requestCellInfoUpdate(context.mainExecutor, object : TelephonyManager.CellInfoCallback() {
override fun onCellInfo(cellInfos: List<CellInfo>) {
for (cellInfo in cellInfos)
if (cellInfo.isRegistered) {
when (cellInfo) {
is CellInfoWcdma -> {
Log.i("LOG", cellInfo.cellSignalStrength.toString())
}
}
return
}
}
})
}
The returned value is always -24 :
-24 (CellSignalStrengthWcdma: ss=-105 ber=99 rscp=-24 ecno=0 level=1)
Digging into the source code I found that getDbm() actually returns the mRscp when it is valid (which is the case), the problem is that it is never updated when called from telephonyManager.requestCellInfoUpdate() :
public int getDbm() {
if (mRscp != CellInfo.UNAVAILABLE) return mRscp;
return mRssi;
}
Strangely, the signal strength returned by telephonyManager.signalStrength.cellSignalStrengths[0].dbm is working fine (something like -99), but it has a latency of up to 10 seconds, which is too high for my intended use.