Skip to content

Commit

Permalink
Optimize signal strength range for NR
Browse files Browse the repository at this point in the history
  • Loading branch information
dzlabing committed Apr 24, 2023
1 parent 9e33c57 commit b24e13e
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions core/src/main/java/at/specure/info/strength/SignalStrengthInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ abstract class SignalStrengthInfo : Parcelable {
const val TDSCDMA_RSRP_SIGNAL_MIN = -120
const val TDSCDMA_RSRP_SIGNAL_MAX = -24

const val NR_RSRP_SIGNAL_MIN = -140 // dbm
const val NR_RSRP_SIGNAL_MAX = -44 // values taken from CellSignalStrengthNr
const val NR_RSRP_SIGNAL_MIN = -130 // dbm
const val NR_RSRP_SIGNAL_MAX = -70

const val NR_RSRQ_SIGNAL_MIN = -20 // dbm
const val NR_RSRQ_SIGNAL_MAX = -3 // values taken from CellSignalStrengthNr
Expand All @@ -118,12 +118,10 @@ abstract class SignalStrengthInfo : Parcelable {
// Lifted from Default carrier configs and max range of SSRSRP from
// mSsRsrpThresholds array
// Boundaries: [-140 dB, -44 dB]
const val SSRSRP_SIGNAL_STRENGTH_NONE = -140
const val SSRSRP_SIGNAL_STRENGTH_NONE = -130
const val SSRSRP_SIGNAL_STRENGTH_POOR = -110
const val SSRSRP_SIGNAL_STRENGTH_MODERATE = -90
const val SSRSRP_SIGNAL_STRENGTH_GOOD = -80
const val SSRSRP_SIGNAL_STRENGTH_FULL = -65
const val SSRSRP_SIGNAL_STRENGTH_MAX = -44
const val SSRSRP_SIGNAL_STRENGTH_GOOD = -70

@SuppressLint("BinaryOperationInTimber")
@RequiresApi(Build.VERSION_CODES.Q)
Expand All @@ -136,7 +134,7 @@ abstract class SignalStrengthInfo : Parcelable {
transport = TransportType.CELLULAR,
value = signal.extractSignalValue()?.fixNrRsrp(),
rsrq = signal.extractSignalQualityValue()?.fixNrRsrq(),
signalLevel = calculateNRCellSignalLevel(signal),
signalLevel = calculateCellSignalLevel(signal.ssRsrp, NR_RSRP_SIGNAL_MIN, NR_RSRP_SIGNAL_MAX),
min = NR_RSRP_SIGNAL_MIN,
max = NR_RSRP_SIGNAL_MAX,
timestampNanos = System.nanoTime(),
Expand Down Expand Up @@ -763,19 +761,6 @@ abstract class SignalStrengthInfo : Parcelable {
}
}

/**
* Count level of the 5G signal only from ssrsrp field value according to NR ssrsrp thresholds
* 0 - NONE
* 1
* 2
* 3
* 4 - HIGHEST
*/
private fun calculateNRCellSignalLevel(signal: CellSignalStrengthNr): Int {
val signalValue = signal.extractSignalValue().fixNrRsrp()
return calculateNRSignalLevel(signalValue)
}

fun calculateNRSignalLevel(signalValue: Int?): Int {
return when {
signalValue == null -> 0
Expand Down

0 comments on commit b24e13e

Please sign in to comment.