How to use reflection to get the exact LTE PCI (physical cell identifier) ​​in an Android app

I need to get accurate LTE PCI readings, not the neighbors, only the PCI (physical cell identifier) ​​that the phone is connected to. My current implementation uses the Android telephony and telephony manager, as shown in the following class:

protected class SignalStrengthListener extends PhoneStateListener { @Override public void onSignalStrengthsChanged(android.telephony.SignalStrength signalStrength) { tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); ltestr = signalStrength.toString(); parts = ltestr.split(" "); try { cellInfoList = tm.getAllCellInfo(); for (CellInfo cellInfo : cellInfoList) { if (cellInfo instanceof CellInfoLte) { // cast to CellInfoLte and call all the CellInfoLte methods you need // Gets the LTE PCI: (returns Physical Cell Id 0..503, Integer.MAX_VALUE if unknown) cellPci = ((CellInfoLte) cellInfo).getCellIdentity().getPci(); } } } catch (Exception e) { Log.d("SignalStrength", "Exception: " + e.getMessage()); } super.onSignalStrengthsChanged(signalStrength); } } 

The problem with this implementation is described in another question that I posted: Android CellIdentityLte PCI readings are inaccurate, why? Is there anything you can do?

I have heard of other telephony applications that use reflection to collect accurate LTE parameters, but I have no idea how to do this. So, how can I use reflection in the application to get PCI readings?

Thank you and welcome!

0
source share

Source: https://habr.com/ru/post/1308970/


All Articles