getAllCellInfo - duplicate values

北城以北 提交于 2020-01-03 19:04:29

问题


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?

来源:https://stackoverflow.com/questions/48337100/getallcellinfo-duplicate-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!