将 RSRP 从 CellSignalStrengthLte 转换为 RSSI
所以我需要获取 LTE 网络的 RSSI,并且我知道 CellSignalStrengthLte
有获取 RSSI 的特殊方法,但它适用于 API >= 29,但我的应用程序的最小 API 为 23。 不过,我可以获得信号强度的 RSRP 值,并且我看到有一些公式可以将 RSSI 转换为 RSRP 并返回,但我不知道如何在 Android 中应用它们。
那么有人有解决办法吗?这是代码的一个小示例:
val telephonyManager = requireContext().getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
telephonyManager.allCellInfo.first().let { info ->
when (info) {
is CellInfoLte -> {
val signalStrengthLte = info.cellSignalStrength as CellSignalStrengthLte
signalStrengthLte.rssi // requires API >= 29
signalStrengthLte.dbm // returns RSRP value
// Needs to convert RSRP to RSSI
}
}
}
So I need to get RSSI of LTE network and I know that CellSignalStrengthLte
has special method for getting RSSI, but it is available for API >= 29, but my app has min API of 23.
However I can get a RSRP value for signal strength and I saw that there are some formulas to convert RSSI to RSRP and back, but I don't know how to apply them in Android.
So does anyone have a solution? Here is a small example of code:
val telephonyManager = requireContext().getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
telephonyManager.allCellInfo.first().let { info ->
when (info) {
is CellInfoLte -> {
val signalStrengthLte = info.cellSignalStrength as CellSignalStrengthLte
signalStrengthLte.rssi // requires API >= 29
signalStrengthLte.dbm // returns RSRP value
// Needs to convert RSRP to RSSI
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后我无法将 RSRP 转换为 RSSI,但我设法获得了近似的 RSSI 值。在查看了
CellSignalStrengthLte
类的源代码之后 - 我发现了一个旧的已弃用的信号强度专用字段以及将该信号转换为近似 RSSI 值的方法。因此,为了访问这个
mSignalStrength
私有属性,我使用了反射,然后应用了源代码中的公式。用于从类获取私有属性的扩展:
以及从问题中的代码计算近似 RSSI 值:
同样,此解决方案仅需要针对使用 API << 的设备实现。 29,因为对于较新的版本有一个变量,它返回几乎(如果不是完全)相同的值。
In the end I wasn't able to convert RSRP to RSSI, but I have managed to get approximate RSSI value. After going through source code of
CellSignalStrengthLte
class - I found an old deprecated private field for the signal strength and the method to convert this signal to approximate RSSI value.So to access this
mSignalStrength
private property I used reflection and then applied the formula from the source code.Extension for getting private property from the class:
And the calculation of approximate RSSI value from the code in the question:
And again - this solution needs to be implemented only for devices which uses API < 29, because for newer versions there is a variable, which returns almost(if not fully) the same value.