@Override public void onCellInfoChanged(List<CellInfo> cellInfo) { CellLocationInfo.Params p; List<CellLocationInfo> cells = new ArrayList<CellLocationInfo>(cellInfo.size()); for (CellInfo info : cellInfo) { p = new CellLocationInfo.Params(); p.time = info.getTimeStamp(); if (info instanceof CellInfoCdma) { CellInfoCdma cdma = (CellInfoCdma) info; p.id = cdma.getCellIdentity().getBasestationId(); p.lat = cdma.getCellIdentity().getLatitude(); p.lon = cdma.getCellIdentity().getLongitude(); p.dbm = cdma.getCellSignalStrength().getDbm(); // there's two other dbm methods p.asu = cdma.getCellSignalStrength().getAsuLevel(); } else if (info instanceof CellInfoGsm) { CellInfoGsm gsm = (CellInfoGsm) info; p.id = gsm.getCellIdentity().getCid(); p.dbm = gsm.getCellSignalStrength().getDbm(); p.asu = gsm.getCellSignalStrength().getAsuLevel(); } else if (info instanceof CellInfoLte) { CellInfoLte lte = (CellInfoLte) info; p.id = lte.getCellIdentity().getCi(); p.dbm = lte.getCellSignalStrength().getDbm(); p.asu = lte.getCellSignalStrength().getAsuLevel(); } else if (info instanceof CellInfoWcdma) { CellInfoWcdma wcdma = (CellInfoWcdma) info; p.id = wcdma.getCellIdentity().getCid(); p.dbm = wcdma.getCellSignalStrength().getDbm(); p.asu = wcdma.getCellSignalStrength().getAsuLevel(); } cells.add(new CellLocationInfo(p)); } cellInfos = cells.toArray(new CellLocationInfo[cells.size()]); notifyListeners(EVENT_CELL_INFOS); }
/** * Retrieves the tower ID, network type, RSS, and timestamp for a GSM cell. * * @param info * @return */ private CellularInfo processGsmInfo(CellInfoGsm info) { int id = info.getCellIdentity().getCid(); int asu = info.getCellSignalStrength().getAsuLevel(); int rss = info.getCellSignalStrength().getDbm(); String type = CellularInfo.TYPE_GSM; // RSS can not always be obtained String strRss = (asu == 99 || rss > 100 || rss < -200) ? "N/A" : Integer.toString(rss); if (id < 0) return null; return new CellularInfo(Integer.toString(id), type, strRss, Utils.getTimestamp()); }