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.

2
  • Please provide the device model (any Android version) where getPsc() returns the correct value. Even solutions that require to use reflection are welcome. Commented Jul 31, 2012 at 3:55
  • I can confirm that cellLocation.getPsc() is reported on a Nexus 4 connected to UMTS (with above code). Also for getNeighboringCellInfo. Commented Nov 15, 2013 at 16:14

2 Answers 2

1

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

3
  • 1
    I'm aware of that. getPsc() always returns -1 on UMTS networks on the devices I've tested. Commented Aug 1, 2012 at 14:54
  • Yes, I do have that permission. Commented Aug 1, 2012 at 16:43
  • The term PSC (Primary Scrambling Code) is irrelevant for GSM radio - it's part of the parameters of UMTS radio (WCDMA).
    – Doigen
    Commented Jan 20, 2015 at 14:36
0
+100

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.

5
  • Do you know which version of Nexus it is? Nexus S / Galaxy Nexus / Nexus 7? Commented Aug 7, 2012 at 6: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
    Commented Aug 7, 2012 at 8: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? Commented Aug 7, 2012 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
    Commented Aug 7, 2012 at 10:44
  • I found that getPSC() works on HTC Nexus One running Android 2.3.4. Thanks for the information. Commented Aug 9, 2012 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.