4

I'm successfully getting GsmCellLocation and related cid and lac information but the PSC (primary scrambling code) of the serving cell is always coming back with the initialized value -1. Anyone able to get the real PSC value of the serving cell?

telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
psc = cellLocation.getPsc();
Log.d(TAG, "PSC = " + psc);

I have all the permissions necessary. My neighbor list returns empty as well but that's not a concern at the moment.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
pseudozach
  • 398
  • 6
  • 14
  • Please provide the device model (any Android version) where `getPsc()` returns the correct value. Even solutions that require to use reflection are welcome. – Dheeraj Vepakomma Jul 31 '12 at 03:55
  • I can confirm that cellLocation.getPsc() is reported on a Nexus 4 connected to UMTS (with above code). Also for getNeighboringCellInfo. – Gunnar Bernstein Nov 15 '13 at 16:14

2 Answers2

1

PSC is available only on UMTS network.
Check network type getNetworkType if it's NETWORK_TYPE_UMTS and not NETWORK_TYPE_EDGE

pawelzieba
  • 16,082
  • 3
  • 46
  • 72
0

I have read that the this works on some phones - the Google nexus phone being one of them.

I tried to run your test code on my Motorolla Razr - it returns -1.

By looking at the android source code (GsmServiceStateTracker.java) it looks like this feature is optional and most likely not implemented on many phones. The information you are looking for is sent as unsolicited message from the GSM modem and its not used for anything else (As far as I can see from the android sources) than the value returned from getPsc().

I mean why implement it if you don't have to.

I also tried to extend your test code to obtain info about neighbouring cells which can also be used to get their PSC values. It does not work, as the at command used for getting neighbouring cell info is not implemented in my phone's 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 find out what phones implement this, you should add a test to some benchmark app and hopefully get some results in time.

wojciii
  • 4,253
  • 1
  • 30
  • 39
  • Do you know which version of Nexus it is? Nexus S / Galaxy Nexus / Nexus 7? – Dheeraj Vepakomma Aug 07 '12 at 06:51
  • I suspect that this functionality would work on the Nexus `phones` and not on the tablet since it lacks phone functionality. I don't have any of those phones so that I can test. :( – wojciii Aug 07 '12 at 08:15
  • Is there a way I can get the PSC from the radio logs? I'm able to see only LAC & CID in the radio log. Is the PSC also printed? – Dheeraj Vepakomma Aug 07 '12 at 10:07
  • I also tried to grep radio logs on my razr and looking for clues in some of the other messages. I also see LAC and CID as you do. There is no mention of PSC in my logs. :( – wojciii Aug 07 '12 at 10:44
  • I found that `getPSC()` works on HTC Nexus One running Android 2.3.4. Thanks for the information. – Dheeraj Vepakomma Aug 09 '12 at 12:21