@SuppressWarnings("ChainOfInstanceofChecks") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private Cell parceCellInfo18(CellInfo info) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return null; if (info instanceof CellInfoWcdma) { CellIdentityWcdma identity = ((CellInfoWcdma) info).getCellIdentity(); if (identity.getMcc() == Integer.MAX_VALUE) return null; CellSignalStrengthWcdma strength = ((CellInfoWcdma) info).getCellSignalStrength(); return new Cell(Cell.CellType.UMTS, identity.getMcc(), identity.getMnc(), identity.getLac(), identity.getCid(), identity.getPsc(), strength.getDbm()); } else if (info instanceof CellInfoLte) { CellIdentityLte identity = ((CellInfoLte) info).getCellIdentity(); if (identity.getMcc() == Integer.MAX_VALUE) return null; CellSignalStrengthLte strength = ((CellInfoLte) info).getCellSignalStrength(); return new Cell(Cell.CellType.LTE, identity.getMcc(), identity.getMnc(), identity.getTac(), identity.getCi(), identity.getPci(), strength.getDbm()); } return null; }
@SuppressWarnings("ChainOfInstanceofChecks") private Cell parseCellInfo(CellInfo info) { try { if (info instanceof CellInfoGsm) { CellIdentityGsm identity = ((CellInfoGsm) info).getCellIdentity(); if (identity.getMcc() == Integer.MAX_VALUE) return null; CellSignalStrengthGsm strength = ((CellInfoGsm) info).getCellSignalStrength(); return new Cell(Cell.CellType.GSM, identity.getMcc(), identity.getMnc(), identity.getLac(), identity.getCid(), -1, strength.getDbm()); } else if (info instanceof CellInfoCdma) { CellIdentityCdma identity = ((CellInfoCdma) info).getCellIdentity(); CellSignalStrengthCdma strength = ((CellInfoCdma) info).getCellSignalStrength(); return new Cell(Cell.CellType.CDMA, getMcc(), identity.getSystemId(), identity.getNetworkId(), identity.getBasestationId(), -1, strength.getDbm()); } else { return parceCellInfo18(info); } } catch (Exception ignored) { } return null; }
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; }