I read that this works on some phones - one of them is the Google Nexus phone.
I tried running your test code on my Motorolla Razr - it returns -1.
Having studied the Android source code (GsmServiceStateTracker.java), it seems that this feature is optional and most likely not implemented on many phones. The information you are looking for is sent as an unsolicited message from a GSM modem and is not used for anything else (as far as I can see from android sources) than the value returned from getPsc()
.
I mean, why implement this if you don't need to.
I also tried expanding your test code to get information about neighboring cells, which can also be used to get their PSC values. It does not work, because the at command, used to obtain information about neighboring cells, is not implemented in the modem of the GSM modem.
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation(); Log.d(TAG, "cid = " + cellLocation.getCid()); Log.d(TAG, "lac = " + cellLocation.getLac()); int psc = cellLocation.getPsc(); Log.d(TAG, "PSC = " + psc); List<NeighboringCellInfo> neighCell = null; neighCell = telephonyManager.getNeighboringCellInfo(); for (int i = 0; i < neighCell.size(); i++) { NeighboringCellInfo thisCell = neighCell.get(i); int CID = thisCell.getCid(); int RSSI = thisCell.getRssi(); int PSC = thisCell.getPsc(); Log.d(TAG, " "+CID+" - "+RSSI + " - " + PSC); }
If you really want to know which phones implement this, you should add a test to some testing application and hopefully get some results on time.
source share