Reputation: 76
I'm trying to obtain the CellSignalStrength for a device operating in 5G NSA mode. Specifically, I want to retrieve both LTE and NR signal strengths since 5G NSA mode should involve both. However, I'm facing an inconsistency between different devices:
I'm puzzled because some apps on the Play Store are able to capture NR signal strengths on the OnePlus 8T 5G.
*FYI : Everything works well on both device when 5G SA mode turn on
How can I accurately retrieve ss-rsrp and ss-rsrq values from the 5G NSA mode on the OnePlus 8T 5G?
I'm using the Telephony framework to fetch the CellSignalStrength. Here's a snippet of my code:
fun requestCellInfoUpdate() {
//Get the system's TelephonyManager service.
mTelephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
//Ceate a TelephonyManager instance for the default subscription ID. (Current Data SIM)
mTelephonyManager = mTelephonyManager.createForSubscriptionId(getDefault_SubscriptionId(context))
//Request cell info update (Andriod Q). The result will be handled by the provided callback.
mTelephonyManager.requestCellInfoUpdate(context.mainExecutor, object : TelephonyManager.CellInfoCallback() {
override fun onCellInfo(cellInfo: MutableList<CellInfo>) {
// Find the currently registered cell from the list.
val servingCell = cellInfo.find { it.isRegistered}
// If a registered cell is found for serving cellualar, update the cachedCellInfo list.
if (servingCell != null) {
cachedCellInfo = listOf(servingCell)
}
}
//Callback method when there's an error retrieving cell info.
override fun onError(errorCode: Int, detail: Throwable?) {
super.onError(errorCode, detail)
// Handle the error as needed. For example, log the error or display an error message.
}
})
}
fun getInfo(): List<String> {
//Request the current cell information.
requestCellInfoUpdate() // Update Cell Information on return to `cachedCellInfo`
var cellId: String
var cellSignalStrength: String
var telephonyList: List<String> = emptyList()
//Check if the cached cell information is available.
if (cachedCellInfo.isEmpty()) {
// If not available, set error messages indicating the GPS needs to be on.
cellId = "Error! GPS must be turned on."
cellSignalStrength = "Error! GPS must be turned on."
} else {
//Extract cell identity and signal strength from the cached information.
cellId = cachedCellInfo[0].cellIdentity.toString() // index 0 to get only Serving Cell data
cellSignalStrength = cachedCellInfo[0].cellSignalStrength.toString() // index 0 to get only Serving Cell data
}
//Add the extracted cell identity and signal strength to the result list.
telephonyList += cellId // index [i]
telephonyList += cellSignalStrength // index [i+1]
return telephonyList
}
Given that the device is in 5G NSA mode, I was expecting to get signal strengths for both LTE and NR. However, as mentioned, on the OnePlus 8T 5G, I only receive the LTE signal strength.
I initially thought it might be a hardware limitation, but since other apps can capture the NR signal strength on this specific device, I believe there's a way to achieve this.
Any guidance on how to accurately capture the ss-rsrp and ss-rsrq values for 5G NSA mode would be greatly appreciated.
Upvotes: 2
Views: 306