我正在使用getAllCellInfo从我的手机(未扎根的LG G5-获取其价格)获取服务和邻近小区的信息,但是该函数返回所有邻近测量塔的重复数据。在我所在的地区,我的测试数据大多数时候都是3G(WCDMA)。这是我的WCDMA结果的摘录,显示了原始字符串和已解析的值(以可读性引用代码):

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}


请注意,服务小区和相邻小区已被识别(isRegistered)并显示各自的信号强度(dBm),并且给出了服务小区的小区标识数据,但是相邻小区标识数据全部弄乱了(2147483647 = Integer.MAX_VALUE =未知,并且重复UARFCN)。我用来获取我开始编写的打印单元信息+助手类的代码:

        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());
            }


WCDMA帮助程序类的解析功能:

    //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
        }
    }
}


因此,我不知道其他人是否也遇到相同的问题,还是可以在他们的设备上对其进行测试?相似的未解决帖子提出了相同的问题(1),或者在某些设备和SDK版本上getAllCellInfo()= null ...是否有人建议如何解决?

最佳答案

在WCDMA中,当mCid=2147483647表示该小区为Unknown
请检查此链接以获取更多详细信息:fields included in Android CellInof data extracts

关于android - getAllCellInfo-重复值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48337100/

10-09 06:51