/**
* Create a measure from current CellInfo
*
* @return a current measure
*/
public Measure createMeasure() {
// Create a measure
Measure m = new Measure();
m.timestamp = System.currentTimeMillis();
TelephonyManager tel = (TelephonyManager) app.getSystemService(Context.TELEPHONY_SERVICE);
for (CellInfo ci : tel.getAllCellInfo()) {
TowerInfo ti = new TowerInfo();
if (ci instanceof CellInfoCdma) {
ti.type = TowerInfo.CDMA;
ti.id = ((CellInfoCdma) ci).getCellIdentity().getBasestationId();
ti.psc = -1;
ti.dbm = ((CellInfoCdma) ci).getCellSignalStrength().getDbm();
} else if (ci instanceof CellInfoGsm) {
ti.type = TowerInfo.GSM;
ti.id = ((CellInfoGsm) ci).getCellIdentity().getCid();
ti.psc = -1; // undefined for GSM
ti.dbm = ((CellInfoGsm) ci).getCellSignalStrength().getDbm();
} else if (ci instanceof CellInfoLte) {
ti.type = TowerInfo.LTE;
ti.id = ((CellInfoLte) ci).getCellIdentity().getCi();
ti.psc = -1;
ti.dbm = ((CellInfoLte) ci).getCellSignalStrength().getDbm();
} else if (ci instanceof CellInfoWcdma) {
ti.type = TowerInfo.WCDMA;
ti.id = ((CellInfoWcdma) ci).getCellIdentity().getCid();
ti.psc = ((CellInfoWcdma) ci).getCellIdentity().getPsc();
ti.dbm = ((CellInfoWcdma) ci).getCellSignalStrength().getDbm();
}
m.towerInfos.add(ti);
}
return m;
}
CellManager.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:smartcells
作者:
评论列表
文章目录