Reputation: 104
How dual mode works in android for 5G. How is android APIs are supporting this feature. I am wondering if we will get LTE & 5G network parameters at the same time via different APIs? Please help if anyone has clarity on this.
Upvotes: 0
Views: 748
Reputation: 21
There are different android APIs to get 4G and 5G RF parameters(RSRP,RSRQ and SINR). You can use CellSignalStrengthLte to get 4G RF parameters where as use CellSignalStrengthNr for 5G. Here is my implementation of these libraries. You can use the following code to call the nrSignalStrengthInfo function which returns the RF params.
try {
if(Build.VERSION.SDK_INT >= 29){
val tm: TelephonyManager =
context.getSystemService(AppCompatActivity.TELEPHONY_SERVICE) as TelephonyManager
if (tm.signalStrength != null){
Log.i(TAG,"nrSignalStrengthInfo executed")
nrSignalStrengthInfo(tm.signalStrength)
}
}
}catch (e: Exception){
Log.e(TAG,e.stackTraceToString())
}
And this is the nrSignalStrengthInfo function which you will be calling.
private fun nrSignalStrengthInfo(signalStrength: SignalStrength?){
if (Build.VERSION.SDK_INT >= 29){
if (signalStrength != null) {
val lteSS = signalStrength.getCellSignalStrengths(CellSignalStrengthLte::class.java)
val nrSS = signalStrength.getCellSignalStrengths(CellSignalStrengthNr::class.java)
if (nrSS.isNotEmpty() && lteSS.isNotEmpty()) {
this.nrType = "NR_5G_NSA"
} else if (nrSS.isNotEmpty() && lteSS.isEmpty()) {
this.nrType = "NR_5G_SA"
}else{
this.nrType = ""
Log.i(TAG,"nrSS not available")
}
if (nrSS.isNotEmpty()) {
rsrp5g = nrSS[0].ssRsrp.toLong()
rsrq5g = nrSS[0].ssRsrq.toLong()
sinr5g = nrSS[0].ssSinr.toLong()
csiSinr = nrSS[0].csiSinr.toLong()
}else{
if(lteSS.isNotEmpty()){
rsrp = lteSS[0].rsrp.toDouble()
rsrq = lteSS[0].rsrq.toDouble()
}else{
rsrp = (-160).toDouble()
rsrq = (-30).toDouble()
}
rsrp5g = -160
rsrq5g = -30
sinr5g = -30
csiSinr = -30
pci5g = -1
bandsNr = "NA"
}
}
}
}
Hope this helps!!
Upvotes: 1