3

I am using getAllCellInfo to acquire serving- and neighboring cell info from my phone (unrooted LG G5 - for what it's worth), but the function returns duplicate data for all the neighboring-measured towers. In the area that I'm in, my test data is 3G (WCDMA) most of the time. Here's an extraction of my WCDMA results, showing the raw string and parsed values (in code quoted for readibility):

Site_0
Registered: true
dBm: -99
Raw str: CellIdentityWcdma:{ mMcc=655 mMnc=1 mLac=63 mCid=9538943 mPsc=190 
mUarfcn=10562}

Site_1
Registered: false
dBm: -101
Raw str: CellIdentityWcdma:{ mMcc=2147483647 mMnc=2147483647 mLac=2147483647 
mCid=2147483647 mPsc=477 mUarfcn=10562}

Site_2
Registered: false
dBm: -103
Raw str: CellIdentityWcdma:{ mMcc=2147483647 mMnc=2147483647 mLac=2147483647 
mCid=2147483647 mPsc=331 mUarfcn=10562}

Site_3
Registered: false
dBm: -103
Raw str: CellIdentityWcdma:{ mMcc=2147483647 mMnc=2147483647 mLac=2147483647 
mCid=2147483647 mPsc=364 mUarfcn=10562}

Site_4
Registered: false
dBm: -105
Raw str: CellIdentityWcdma:{ mMcc=2147483647 mMnc=2147483647 mLac=2147483647 
mCid=2147483647 mPsc=50 mUarfcn=10562}

Note that the serving and neighboring cells are identified (isRegistered) and show respective signal strengths (dBm), and cell Identity data of the serving cell given, but neighboring cell identity data all messed up (2147483647 = Integer.MAX_VALUE = unknown, and duplicate UARFCNs). The code that I'm using for getting an printing cell info + helper class that I started to wrote:

        List<CellInfo> infos = tel.getAllCellInfo();
        for (int i = 0; i<infos.size(); ++i) {
            try {
                CellInfo info = infos.get(i);
                if (info instanceof CellInfoGsm)
                {
                    //stuff
                }
                else if (info instanceof CellInfoLte)
                {
                    //stuff
                }
                else if (info instanceof CellInfoWcdma)
                {
                    WCDMAStruct wcdma = new WCDMAStruct(this);
                    wcdma.parse(((CellInfoWcdma)info).getCellIdentity());

                    list += "Site_"+i + "\r\n";
                    list += "Registered: " + info.isRegistered() + "\r\n";
                    CellSignalStrengthWcdma wcdmaS = ((CellInfoWcdma) info).getCellSignalStrength();
                    list += "dBm: " + wcdmaS.getDbm() + "\r\n";
                    list += "Raw str: " + wcdma.CellInfoStr + "\r\n\r\n";
                }

            } catch (Exception ex) {
                Log.i("neighboring error 2: " ,ex.getMessage());
            }

The parsing function from WCDMA helper class:

    //parse input data object to variables
public void parse(CellIdentityWcdma input)
{
    CellInfoStr = input.toString();

    CID = input.getCid();
    if(CID == Integer.MAX_VALUE)    //unknown
        CID = UNKNOWN;

    LAC = input.getLac();
    if(LAC == Integer.MAX_VALUE)    //unknown
        LAC = UNKNOWN;

    MCC = input.getMcc();
    if(MCC == Integer.MAX_VALUE)    //unknown
        MCC = UNKNOWN;

    MNC = input.getMnc();
    if(MNC == Integer.MAX_VALUE)    //unknown
        MNC = UNKNOWN;

    PSC = input.getPsc();
    if(PSC == Integer.MAX_VALUE)    //unknown
        PSC = UNKNOWN;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
    {
        chnlNum_DL = input.getUarfcn();
        if(chnlNum_DL == Integer.MAX_VALUE)
            chnlNum_DL = UNKNOWN;
        else
        {
            FreqBand = getFreqBand(chnlNum_DL); //freq band from UARFCN
        }
    }
}

So I don't know if other people are experiencing the same issues, or could test it on their devices? Similar unresolved posts suggest the same issue (1), or where getAllCellInfo() = null on some devices & SDK versions... Does anyone please have some suggestions how to fix it?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Paul
  • 756
  • 1
  • 8
  • 22

1 Answers1

0

When in WCDMA mCid=2147483647 that means that the Cell is Unknown. Please, check this link for more details: fields included in Android CellInof data extracts.

Noureddine
  • 232
  • 2
  • 10