android.telephony.NeighboringCellInfo Java Examples
The following examples show how to use
android.telephony.NeighboringCellInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: b.java From letv with Apache License 2.0 | 7 votes |
public final int[] d() { if (this.c == 0) { return new int[0]; } List<NeighboringCellInfo> neighboringCellInfo = this.q.getNeighboringCellInfo(); if (neighboringCellInfo == null || neighboringCellInfo.size() == 0) { return new int[]{this.c}; } Object obj = new int[((neighboringCellInfo.size() * 2) + 2)]; obj[0] = this.c; obj[1] = this.a; int i = 2; for (NeighboringCellInfo neighboringCellInfo2 : neighboringCellInfo) { int cid = neighboringCellInfo2.getCid(); if (cid > 0 && cid != SupportMenu.USER_MASK) { int i2 = i + 1; obj[i] = cid; i = i2 + 1; obj[i2] = neighboringCellInfo2.getRssi(); } } Object obj2 = new int[i]; System.arraycopy(obj, 0, obj2, 0, i); return obj2; }
Example #2
Source File: RadioSectionFragment.java From satstat with GNU General Public License v3.0 | 6 votes |
/** * Requeries neighboring cells */ protected void updateNeighboringCellInfo() { try { /* * NeighboringCellInfo is not supported on some devices and will return no data. It lists * only GSM and successors' cells, but not CDMA cells. */ List<NeighboringCellInfo> neighboringCells = mainActivity.telephonyManager.getNeighboringCellInfo(); String networkOperator = mainActivity.telephonyManager.getNetworkOperator(); mCellsGsm.updateAll(networkOperator, neighboringCells); mCellsLte.updateAll(networkOperator, neighboringCells); } catch (SecurityException e) { // Permission not granted, can't retrieve cell data Log.w(TAG, "Permission not granted, cannot get neighboring cell info"); } }
Example #3
Source File: CellLocationConverter.java From TowerCollector with Mozilla Public License 2.0 | 6 votes |
public Cell convert(NeighboringCellInfo neighboringCell, int mcc, int mnc, int mainCellLac, long mainCellCid) { Cell cell = new Cell(); cell.setNeighboring(true); // no type checking because only GSM and UMTS cells can have neighboring cells NetworkGroup networkType = NetworkTypeUtils.getNetworkGroup(neighboringCell.getNetworkType()); if (networkType == NetworkGroup.Gsm) { cell.setGsmCellLocation(mcc, mnc, neighboringCell.getLac(), neighboringCell.getCid(), NetworkGroup.Gsm); } else { int psc = neighboringCell.getPsc(); if (psc == NeighboringCellInfo.UNKNOWN_CID) { psc = Cell.UNKNOWN_CID; } cell.setGsmCellLocation(mcc, mnc, mainCellLac, mainCellCid, psc, NetworkGroup.Wcdma); } return cell; }
Example #4
Source File: CellbasedLocationProvider.java From LocalGSMLocationProvider with Apache License 2.0 | 6 votes |
/** * Add neighbouring cells as generated by the getNeighboringCells API. * @param neighbours The list of neighbouring cells. */ public void addNeighbours(List<NeighboringCellInfo> neighbours) { if (neighbours == null || neighbours.isEmpty()) return; for (NeighboringCellInfo neighbour : neighbours) { List<CellInfo> cellInfos = db.query(neighbour.getCid(), neighbour.getLac()); if (cellInfos != null && !cellInfos.isEmpty()) { for (CellInfo cellInfo : cellInfos) { pushRecentCells(cellInfo); } } else { CellInfo ci = new CellInfo(); ci.lng = 0d; ci.lat = 0d; ci.CID = neighbour.getCid(); ci.LAC = neighbour.getLac(); ci.MCC = -1; ci.MNC = -1; pushUnusedCells(ci); } } }
Example #5
Source File: MeasurementUpdater.java From TowerCollector with Mozilla Public License 2.0 | 6 votes |
public synchronized void setLastCellLocation(CellLocation cellLocation, NetworkGroup networkType, String operatorCode, String operatorName, List<NeighboringCellInfo> neighboringCells) { Timber.d("setLastCellLocation(): Cell location updated: %s, network type: %s, operator code: %s, operator name: %s", cellLocation, networkType, operatorCode, operatorName); // check if any changes boolean cellChanged = (!isCellLocationEqual(lastCellLocation, cellLocation) || lastNetworkType != networkType || !lastOperatorCode.equals(operatorCode) || !lastOperatorName.equals(operatorName)); // update last cell this.lastCellLocation = cellLocation; this.lastNetworkType = networkType; this.lastOperatorCode = operatorCode; this.lastOperatorName = operatorName; this.neighboringCells = neighboringCells; if (this.neighboringCells == null) { this.neighboringCells = EMPTY_NEIGHBORING_CELL_LIST; } if (cellChanged) { notifyIfReadyToProcess(); } }
Example #6
Source File: CellbasedLocationProvider.java From LocalGSMLocationProvider with Apache License 2.0 | 6 votes |
/** * Handle a modem event by trying to pull all information. The parameter inc defines if the * measurement counter should be increased on success. * @param inc True if the measurement counter should be increased. */ private void handle(boolean inc) { if (telephonyManager == null) return; final List<android.telephony.CellInfo> cellInfos = telephonyManager.getAllCellInfo(); final List<NeighboringCellInfo> neighbours = telephonyManager.getNeighboringCellInfo(); final CellLocation cellLocation = telephonyManager.getCellLocation(); if (cellInfos == null || cellInfos.isEmpty()) { if (neighbours == null || neighbours.isEmpty()) { if (cellLocation == null || !(cellLocation instanceof GsmCellLocation)) return; } } if (inc) measurement.getAndIncrement(); add(cellLocation); addNeighbours(neighbours); addCells(cellInfos); synchronized (recentCells) { cleanup(); } }
Example #7
Source File: LegacyMeasurementParser.java From TowerCollector with Mozilla Public License 2.0 | 6 votes |
private void removeDuplicatedNeighbors(List<NeighboringCellInfo> neighboringCells, Cell mainCell) { List<NeighboringCellInfo> cellsToRemove = new ArrayList<NeighboringCellInfo>(); Set<String> uniqueCellKeys = new HashSet<String>(); uniqueCellKeys.add(createCellKey(mainCell)); for (NeighboringCellInfo cell : neighboringCells) { String key = createCellKey(cell, mainCell); if (uniqueCellKeys.contains(key)) { Timber.d("removeDuplicatedNeighbors(): Remove duplicated cell: %s", key); cellsToRemove.add(cell); } else { uniqueCellKeys.add(key); } } neighboringCells.removeAll(cellsToRemove); }
Example #8
Source File: PhoneUtils.java From Mobilyzer with Apache License 2.0 | 6 votes |
/** * Returns the information about cell towers in range. Returns null if the information is * not available * * TODO(wenjiezeng): As folklore has it and Wenjie has confirmed, we cannot get cell info from * Samsung phones. */ public String getCellInfo(boolean cidOnly) { if(!(ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)==PackageManager.PERMISSION_GRANTED)){ return null; } initNetwork(); List<NeighboringCellInfo> infos = telephonyManager.getNeighboringCellInfo(); StringBuffer buf = new StringBuffer(); String tempResult = ""; if (infos.size() > 0) { for (NeighboringCellInfo info : infos) { tempResult = cidOnly ? info.getCid() + ";" : info.getLac() + "," + info.getCid() + "," + info.getRssi() + ";"; buf.append(tempResult); } // Removes the trailing semicolon buf.deleteCharAt(buf.length() - 1); return buf.toString(); } else { return null; } }
Example #9
Source File: CellTracker.java From AIMSICDL with GNU General Public License v3.0 | 6 votes |
/** * Description: TODO: add more info * * Issues: * * [ ] Getting and comparing signal strengths between different RATs can be very * tricky, since they all return different ranges of values. AOS doesn't * specify very clearly what exactly is returned, even though people have * a good idea, by trial and error. * * See note in : SignalStrengthTracker.java * * Notes: * * * */ public void onSignalStrengthsChanged(SignalStrength signalStrength) { // Update Signal Strength if (signalStrength.isGsm()) { int dbm; if (signalStrength.getGsmSignalStrength() <= 2 || signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) { // Unknown signal strength, get it another way String[] bits = signalStrength.toString().split(" "); dbm = Integer.parseInt(bits[9]); } else { dbm = signalStrength.getGsmSignalStrength(); } mDevice.setSignalDbm(dbm); } else { int evdoDbm = signalStrength.getEvdoDbm(); int cdmaDbm = signalStrength.getCdmaDbm(); // Use lowest signal to be conservative mDevice.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm); } // Send it to signal tracker signalStrengthTracker.registerSignalStrength(mDevice.mCell.getCID(), mDevice.getSignalDBm()); //signalStrengthTracker.isMysterious(mDevice.mCell.getCID(), mDevice.getSignalDBm()); }
Example #10
Source File: CellTowerDatabase.java From LocalGSMLocationProvider with Apache License 2.0 | 5 votes |
/** * Perform a (cached) DB query for a given cell tower. Note that MCC and MNC can be null. * @param mcc * @param mnc * @param cid * @param lac * @return */ public List<CellInfo> query(final Integer mcc, final Integer mnc, final int cid, final int lac) { if (this.reader == null) return null; if (cid == NeighboringCellInfo.UNKNOWN_CID || cid == Integer.MAX_VALUE) return null; if (mcc != null && mcc == Integer.MAX_VALUE) return query(null, mnc, cid, lac); if (mnc != null && mnc == Integer.MAX_VALUE) return query(mcc, null, cid, lac); QueryArgs args = new QueryArgs(mcc, mnc, cid, lac); Boolean negative = queryResultNegativeCache.get(args); if (negative != null && negative.booleanValue()) return null; List<CellInfo> cached = queryResultCache.get(args); if (cached != null) return cached; List<CellInfo> result = _query(mcc, mnc, cid, lac); if (result == null) { queryResultNegativeCache.put(args, true); return null; } result = Collections.unmodifiableList(result); queryResultCache.put(args, result); return result; }
Example #11
Source File: CellTowerDatabase.java From LocalGSMLocationProvider with Apache License 2.0 | 5 votes |
/** * Internal db query to retrieve all cell tower candidates for a given cid/lac. * @param mcc * @param mnc * @param cid * @param lac * @return */ private List<CellInfo> _query(Integer mcc, Integer mnc, int cid, int lac) { if (this.reader == null) return null; // we need at least CID/LAC if (cid == NeighboringCellInfo.UNKNOWN_CID) return null; android.util.Log.d("LNLP/Query", "(" + mcc + "," + mnc + "," + cid + "," + lac + ")"); List<CellInfo> cil = _queryDirect(mcc, mnc, cid, lac); if (cil == null || cil.size() == 0) { if (cid > 0xffff) { _queryDirect(mcc, mnc, cid & 0xffff, lac); } } if (cil != null && cil.size() > 0) { return cil; } if (mcc != null && mnc != null) { return query(mcc, null, cid, lac); } if (mcc != null || mnc != null) { return query(null,null,cid,lac); } return null; }
Example #12
Source File: CellBackendHelper.java From android_external_UnifiedNlpApi with Apache License 2.0 | 5 votes |
private Cell parseCellInfo(NeighboringCellInfo info) { try { if (getCellType(info.getNetworkType()) != Cell.CellType.GSM) return null; return new Cell(Cell.CellType.GSM, getMcc(), getMnc(), info.getLac(), info.getCid(), info.getPsc(), info.getRssi()); } catch (Exception ignored) { } return null; }
Example #13
Source File: CellTracker.java From AIMSICDL with GNU General Public License v3.0 | 5 votes |
private void handlePhoneStateChange() { List<NeighboringCellInfo> neighboringCellInfo = tm.getNeighboringCellInfo(); if (neighboringCellInfo == null || neighboringCellInfo.size() == 0) { return; } Log.i(TAG, mTAG + "NeighbouringCellInfo empty - event based polling succeeded!"); tm.listen(phoneStatelistener, PhoneStateListener.LISTEN_NONE); if (neighboringCellInfo == null) { neighboringCellInfo = new ArrayList<>(); } neighboringCellBlockingQueue.addAll(neighboringCellInfo); }
Example #14
Source File: ai.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
protected final List m() { ArrayList arraylist = new ArrayList(); if (b == null) { return arraylist; } if (!c()) { return arraylist; } Iterator iterator = b.getNeighboringCellInfo().iterator(); int i1 = 0; do { if (!iterator.hasNext()) { break; } NeighboringCellInfo neighboringcellinfo = (NeighboringCellInfo)iterator.next(); if (i1 > 15) { break; } if (neighboringcellinfo.getLac() != 0 && neighboringcellinfo.getLac() != 65535 && neighboringcellinfo.getCid() != 65535 && neighboringcellinfo.getCid() != 0xfffffff) { arraylist.add(neighboringcellinfo); i1++; } } while (true); return arraylist; }
Example #15
Source File: CellBackendHelper.java From android_external_UnifiedNlpApi with Apache License 2.0 | 5 votes |
private Cell parseCellInfo(NeighboringCellInfo info) { try { if (getCellType(info.getNetworkType()) != Cell.CellType.GSM) return null; return new Cell(Cell.CellType.GSM, getMcc(), getMnc(), info.getLac(), info.getCid(), info.getPsc(), info.getRssi()); } catch (Exception ignored) { } return null; }
Example #16
Source File: LegacyMeasurementProcessingEvent.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public LegacyMeasurementProcessingEvent(Location lastLocation, long lastLocationObtainedTime, CellLocation lastCellLocation, SignalStrength lastSignalStrength, NetworkGroup lastNetworkType, String lastOperatorCode, String lastOperatorName, List<NeighboringCellInfo> neighboringCells, int minDistance) { this.lastLocation = lastLocation; this.lastLocationObtainedTime = lastLocationObtainedTime; this.lastCellLocation = lastCellLocation; this.lastSignalStrength = lastSignalStrength; this.lastNetworkType = lastNetworkType; this.neighboringCells = neighboringCells; this.lastOperatorCode = lastOperatorCode; this.lastOperatorName = lastOperatorName; this.minDistance = minDistance; }
Example #17
Source File: UnitConverter.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public static int convertLteDbmToAsu(int dbm) { if (dbm == Cell.UNKNOWN_SIGNAL || dbm == NeighboringCellInfo.UNKNOWN_RSSI) return Cell.UNKNOWN_SIGNAL; if (dbm <= -140) return 0; if (dbm >= -43) return 97; return dbm + 140; }
Example #18
Source File: UnitConverter.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public static int convertGsmDbmToAsu(int dbm) { if (dbm == Cell.UNKNOWN_SIGNAL || dbm == NeighboringCellInfo.UNKNOWN_RSSI) return Cell.UNKNOWN_SIGNAL; if (dbm <= -113) return 0; int asu = (dbm + 113) / 2; if (asu > 31) return 31; return asu; }
Example #19
Source File: CollectorService.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
private void processCellLocation(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCells) { // get network type int networkTypeInt = telephonyManager.getNetworkType(); NetworkGroup networkType = NetworkTypeUtils.getNetworkGroup(networkTypeInt); // get network operator (may be unreliable for CDMA) String networkOperatorCode = telephonyManager.getNetworkOperator(); String networkOperatorName = telephonyManager.getNetworkOperatorName(); Timber.d("processCellLocation(): Operator code = '%s', name = '%s'", networkOperatorCode, networkOperatorName); Timber.d("processCellLocation(): Reported %s neighboring cells", (neighboringCells != null ? neighboringCells.size() : null)); measurementUpdater.setLastCellLocation(cellLocation, networkType, networkOperatorCode, networkOperatorName, neighboringCells); }
Example #20
Source File: CellLocationValidator.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public boolean isValid(NeighboringCellInfo neighboringCell, int mcc, int mnc) { NetworkGroup netType = NetworkTypeUtils.getNetworkGroup(neighboringCell.getNetworkType()); if (netType == NetworkGroup.Gsm) { return getGsmValidator().isValid(neighboringCell.getCid(), neighboringCell.getLac(), mnc, mcc, NeighboringCellInfo.UNKNOWN_CID); } else if (netType == NetworkGroup.Wcdma) { // NOTE: Maybe some phones return full set for WCDMA and then it should be valid return getGsmValidator().isValid(neighboringCell.getCid(), neighboringCell.getLac(), mnc, mcc, neighboringCell.getPsc()); } return false; }
Example #21
Source File: CellLocationConverter.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public Cell convert(CellLocation cellLocation, int mcc, int mnc, NetworkGroup networkType) { Cell cell = new Cell(); if (cellLocation instanceof GsmCellLocation) { GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation; if (gsmCellLocation.getCid() <= 65535 && gsmCellLocation.getPsc() == NeighboringCellInfo.UNKNOWN_CID) { cell.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), NetworkGroup.Gsm); } else { // fix invalid network types (unfortunately not possible to distinguish between UMTS and LTE) if (networkType == NetworkGroup.Gsm || networkType == NetworkGroup.Cdma) networkType = NetworkGroup.Unknown; int psc = gsmCellLocation.getPsc(); if (psc == NeighboringCellInfo.UNKNOWN_CID || psc == Cell.UNKNOWN_CID) { psc = Cell.UNKNOWN_CID; } else if (psc >= 504) { // only UMTS networks support larger PSC networkType = NetworkGroup.Wcdma; } cell.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), psc, networkType); } } else if (cellLocation instanceof CdmaCellLocation) { CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation; cell.setCdmaCellLocation(cdmaCellLocation.getSystemId(), cdmaCellLocation.getNetworkId(), cdmaCellLocation.getBaseStationId()); } else { throw new UnsupportedOperationException("Cell location type not supported `" + cellLocation.getClass().getName() + "`"); } return cell; }
Example #22
Source File: CellLocationSignalConverter.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
private void updateGsm(Cell cell, int asu) { Timber.d("update(): Updating GSM signal strength = %s", asu); if (asu == NeighboringCellInfo.UNKNOWN_RSSI) asu = Cell.UNKNOWN_SIGNAL; // NOTE: for GSM asu is always positive but RSSI negative if (asu >= 0) cell.setGsmLocationSignal(asu, UnitConverter.convertGsmAsuToDbm(asu)); else cell.setGsmLocationSignal(UnitConverter.convertGsmDbmToAsu(asu), asu); }
Example #23
Source File: CellLocationSignalConverter.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
private void updateLte(Cell cell, int dbm) { Timber.d("update(): Updating LTE signal strength = %s", dbm); if (dbm == NeighboringCellInfo.UNKNOWN_RSSI) dbm = Cell.UNKNOWN_SIGNAL; // NOTE: for LTE asu is always positive but RSRP negative if (dbm >= 0) cell.setGsmLocationSignal(dbm, UnitConverter.convertLteAsuToDbm(dbm)); else cell.setGsmLocationSignal(UnitConverter.convertLteDbmToAsu(dbm), dbm); }
Example #24
Source File: UnitConverter.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public static int convertLteAsuToDbm(int asu) { if (asu == Cell.UNKNOWN_SIGNAL || asu == NeighboringCellInfo.UNKNOWN_RSSI) return Cell.UNKNOWN_SIGNAL; if (asu <= 0) return -140; if (asu >= 97) return -43; return asu - 140; }
Example #25
Source File: LegacyMeasurementProcessingEvent.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
public List<NeighboringCellInfo> getNeighboringCells() { return neighboringCells; }
Example #26
Source File: LegacyMeasurementParser.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
private String createCellKey(NeighboringCellInfo neighboringCell, Cell cell) { return cell.getMcc() + "_" + cell.getMnc() + "_" + neighboringCell.getLac() + "_" + neighboringCell.getCid(); }
Example #27
Source File: LegacyMeasurementParser.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
private ParseResult parse(Location location, CellLocation cellLocation, SignalStrength signalStrength, NetworkGroup networkType, String operatorCode, String operatorName, List<NeighboringCellInfo> neighboringCells, long timestamp, int minDistance) { // if required accuracy was achieved if (!locationValidator.isValid(location)) { Timber.d("parse(): Required accuracy not achieved: %s", location.getAccuracy()); return ParseResult.AccuracyNotAchieved; } Timber.d("parse(): Required accuracy achieved: %s", location.getAccuracy()); // get last location getAndSetLastLocation(); // operator name may be unreliable for CDMA Timber.d("parse(): Operator name = '%s'", operatorName); // get operator codes int mcc = Cell.UNKNOWN_CID; int mnc = Cell.UNKNOWN_CID; if (cellLocation instanceof GsmCellLocation) { int[] mccMncPair = MobileUtils.getMccMncPair(operatorCode); if (mccMncPair != null) { mcc = mccMncPair[0]; mnc = mccMncPair[1]; } else { Timber.d("parseLocation(): Network operator unknown: %s", operatorCode); } } // validate cell if (!cellLocationValidator.isValid(cellLocation, mcc, mnc)) { Timber.d("parse(): Cell invalid"); return ParseResult.NoNetworkSignal; } // create measurement with basic data Measurement measurement = new Measurement(); measurement.setMeasuredAt(System.currentTimeMillis()); Cell mainCell = cellLocationConverter.convert(cellLocation, mcc, mnc, networkType); measurement.addCell(mainCell); // fix time if incorrect fixMeasurementTimestamp(measurement, location); // if the same cell check distance condition, otherwise accept if (lastSavedMeasurement != null && lastSavedLocation != null && !conditionsValidator.isMinDistanceSatisfied(lastSavedLocation, location, minDistance)) { List<String> lastMeasurementsCellKeys = new ArrayList<>(); for (Cell lastCell : lastSavedMeasurement.getCells()) { lastMeasurementsCellKeys.add(createCellKey(lastCell)); } boolean mainCellChanged = !lastMeasurementsCellKeys.contains(createCellKey(mainCell)); if (mainCellChanged) { Timber.d("parse(): Distance condition not achieved but cell changed"); } else { Timber.d("parse(): Distance condition not achieved"); return ParseResult.DistanceNotAchieved; } } // check if location has been obtained recently if (!locationValidator.isUpToDate(timestamp, System.currentTimeMillis())) { Timber.d("parse(): Location too old"); return ParseResult.LocationTooOld; } Timber.d("parse(): Destination and time conditions achieved"); // update measurement with location updateMeasurementWithLocation(measurement, location); // update measurement with signal strength if (signalStrength != null) { cellSignalConverter.update(mainCell, signalStrength); } if (collectNeighboringCells) { // remove duplicated neighboring cells removeDuplicatedNeighbors(neighboringCells, mainCell); // process neighboring cells for (NeighboringCellInfo neighboringCell : neighboringCells) { // validate cell if (cellLocationValidator.isValid(neighboringCell, mcc, mnc)) { // set values Cell tempCell = cellLocationConverter.convert(neighboringCell, mcc, mnc, mainCell.getLac(), mainCell.getCid()); // update measurement with signal strength cellSignalConverter.update(tempCell, neighboringCell.getRssi()); // save measurement.addCell(tempCell); Timber.d("parse(): Neighboring cell valid: %s", neighboringCell); } else { Timber.d("parse(): Neighboring cell invalid: %s", neighboringCell); } } } // write to database Timber.d("parse(): Measurement: %s", measurement); boolean inserted = MeasurementsDatabase.getInstance(MyApplication.getApplication()).insertMeasurement(measurement); if (inserted) { lastSavedLocation = location; lastSavedMeasurement = measurement; Timber.d("parse(): Measurement saved"); // broadcast information to main activity Statistics stats = MeasurementsDatabase.getInstance(MyApplication.getApplication()).getMeasurementsStatistics(); EventBus.getDefault().post(new MeasurementSavedEvent(measurement, stats)); EventBus.getDefault().post(new MeasurementsCollectedEvent(measurement)); Timber.d("parse(): Notification updated and measurement broadcasted"); return ParseResult.Saved; } else { return ParseResult.SaveFailed; } }
Example #28
Source File: UnitConverter.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
public static int convertGsmAsuToDbm(int asu) { if (asu == Cell.UNKNOWN_SIGNAL || asu == NeighboringCellInfo.UNKNOWN_RSSI) return Cell.UNKNOWN_SIGNAL; return 2 * asu - 113; }
Example #29
Source File: GsmCellLocationValidator.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
public boolean isValid(int cid, int lac, int mnc, int mcc, int psc) { boolean valid = (isCidOrCiInRange(cid) && isLacOrTacInRange(lac) && isMncInRange(mnc) && isMccInRange(mcc) && (psc == NeighboringCellInfo.UNKNOWN_CID || psc == Cell.UNKNOWN_CID || isPscOrPciInRange(psc))); return valid; }
Example #30
Source File: CellTowerListLte.java From satstat with GNU General Public License v3.0 | 4 votes |
/** * Adds or updates a cell tower. * <p> * If the cell tower is already in the list, its data is updated; if not, a * new entry is created. Cells whose network type is not LTE will be * rejected. * <p> * This method will set the cell's identity data, generation and its signal * strength. * @return The new or updated entry, or {@code null} if the cell was rejected */ public CellTowerLte update(String networkOperator, NeighboringCellInfo cell) { int mcc = CellTower.UNKNOWN; int mnc = CellTower.UNKNOWN; if (networkOperator.length() > 3) { mcc = Integer.parseInt(networkOperator.substring(0, 3)); mnc = Integer.parseInt(networkOperator.substring(3)); } CellTowerLte result = null; CellTowerLte cand = this.get(mcc, mnc, cell.getLac(), cell.getCid()); if ((cand != null) && CellTower.matches(cell.getPsc(), cand.getPci())) result = cand; if (result == null) { cand = this.get(cell.getPsc()); if ((cand != null) && CellTower.matches(mcc, cand.getMcc()) && CellTower.matches(mnc, cand.getMnc()) && CellTower.matches(cell.getLac(), cand.getTac()) && CellTower.matches(cell.getCid(), cand.getCi())) result = cand; } if (result == null) result = new CellTowerLte(mcc, mnc, cell.getLac(), cell.getCid(), cell.getPsc()); result.setNeighboringCellInfo(true); int networkType = cell.getNetworkType(); switch (networkType) { case TelephonyManager.NETWORK_TYPE_LTE: result.setAsu(cell.getRssi()); break; default: // not an LTE cell, return return null; } result.setNetworkType(networkType); if (result.getMcc() == CellTower.UNKNOWN) result.setMcc(mcc); if (result.getMnc() == CellTower.UNKNOWN) result.setMnc(mnc); if (result.getTac() == CellTower.UNKNOWN) result.setTac(cell.getLac()); if (result.getCi() == CellTower.UNKNOWN) result.setCi(cell.getCid()); if (result.getPci() == CellTower.UNKNOWN) result.setPci(cell.getPsc()); this.put(result.getText(), result); this.put(result.getAltText(), result); Log.d(this.getClass().getSimpleName(), String.format("Added NeighboringCellInfo for %s, %d G, %d dBm", result.getText(), result.getGeneration(), result.getDbm())); return result; }