我正在使用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 = unknown ,和重复的UARFCNs)。我用来获取我开始写的打印单元信息+帮助类的代码:
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),或某些设备上的getAllCellInfo()= null SDK版本......请问有什么建议如何修复它?
答案 0 :(得分:0)
在WCDMA mCid=2147483647
中表示该小区为Unknown
。
请检查此链接以获取更多详细信息:fields included in Android CellInof data extracts。