'Convert RSRP to RSSI from CellSignalStrengthLte

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
                }
            }
        }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source