android.telephony.CellIdentityLte Java Examples
The following examples show how to use
android.telephony.CellIdentityLte.
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: TelephonyModule.java From react-native-telephony with MIT License | 5 votes |
@TargetApi(24) public void getEarfcn(WritableMap mapCellIdentity, CellIdentityLte cellIdentity) { if (android.os.Build.VERSION.SDK_INT >= 24){ // Do something for nougat and above versions mapCellIdentity.putInt("earfcn", cellIdentity.getEarfcn()); } else{ // do something for phones running an SDK before lollipop mapCellIdentity.putInt("earfcn", 0); } }
Example #2
Source File: JSONHelper.java From cordova-plugin-advanced-geolocation with Apache License 2.0 | 5 votes |
/** * Converts CellInfoLte into JSON * @param cellInfo CellInfoLte * @return JSON */ public static String cellInfoLTEJSON(CellInfoLte cellInfo, boolean returnSignalStrength){ final Calendar calendar = Calendar.getInstance(); final JSONObject json = new JSONObject(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo != null) { try { json.put("provider", CELLINFO_PROVIDER); json.put("type", LTE); json.put("timestamp", calendar.getTimeInMillis()); final CellIdentityLte identityLte = cellInfo.getCellIdentity(); json.put("ci", identityLte.getCi()); json.put("mcc", identityLte.getMcc()); json.put("mnc", identityLte.getMnc()); json.put("pci", identityLte.getPci()); json.put("tac", identityLte.getTac()); if (returnSignalStrength){ final JSONObject jsonSignalStrength = new JSONObject(); final CellSignalStrengthLte cellSignalStrengthLte = cellInfo.getCellSignalStrength(); jsonSignalStrength.put("asuLevel", cellSignalStrengthLte.getAsuLevel()); jsonSignalStrength.put("dbm", cellSignalStrengthLte.getDbm()); jsonSignalStrength.put("level", cellSignalStrengthLte.getLevel()); jsonSignalStrength.put("timingAdvance", cellSignalStrengthLte.getTimingAdvance()); json.put("cellSignalStrengthLte", jsonSignalStrength); } } catch(JSONException exc) { logJSONException(exc); } } return json.toString(); }
Example #3
Source File: LteCellIdentityValidator.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public boolean isValid(CellIdentityLte cell) { boolean valid = (isCiInRange(cell.getCi()) && isTacInRange(cell.getTac()) && isMncInRange(cell.getMnc()) && isMccInRange(cell.getMcc()) && isPciInRange(cell.getPci())); if (!valid) { Timber.w("isValid(): Invalid CellIdentityLte [mcc=%s, mnc=%s, lac=%s, cid=%s, psc=%s]", cell.getMcc(), cell.getMnc(), cell.getTac(), cell.getCi(), cell.getPci()); Timber.w("isValid(): Invalid CellIdentityLte %s", cell); } return valid; }
Example #4
Source File: CellInfoLteAssert.java From assertj-android with Apache License 2.0 | 5 votes |
public CellInfoLteAssert hasCellIdentity(CellIdentityLte cellIdentity) { isNotNull(); CellIdentityLte actualCellIdentity = actual.getCellIdentity(); assertThat(actualCellIdentity) // .overridingErrorMessage("Expected cell identity <%s> but was <%s>.", cellIdentity, actualCellIdentity) // .isEqualTo(cellIdentity); return this; }
Example #5
Source File: DeviceApi17.java From AIMSICDL with GNU General Public License v3.0 | 4 votes |
public static void loadCellInfo(TelephonyManager tm, Device pDevice) { int lCurrentApiVersion = android.os.Build.VERSION.SDK_INT; try { if (pDevice.mCell == null) { pDevice.mCell = new Cell(); } List<CellInfo> cellInfoList = tm.getAllCellInfo(); if (cellInfoList != null) { for (final CellInfo info : cellInfoList) { //Network Type pDevice.mCell.setNetType(tm.getNetworkType()); if (info instanceof CellInfoGsm) { final CellSignalStrengthGsm gsm = ((CellInfoGsm) info) .getCellSignalStrength(); final CellIdentityGsm identityGsm = ((CellInfoGsm) info) .getCellIdentity(); //Signal Strength pDevice.mCell.setDBM(gsm.getDbm()); // [dBm] //Cell Identity pDevice.mCell.setCID(identityGsm.getCid()); pDevice.mCell.setMCC(identityGsm.getMcc()); pDevice.mCell.setMNC(identityGsm.getMnc()); pDevice.mCell.setLAC(identityGsm.getLac()); } else if (info instanceof CellInfoCdma) { final CellSignalStrengthCdma cdma = ((CellInfoCdma) info) .getCellSignalStrength(); final CellIdentityCdma identityCdma = ((CellInfoCdma) info) .getCellIdentity(); //Signal Strength pDevice.mCell.setDBM(cdma.getDbm()); //Cell Identity pDevice.mCell.setCID(identityCdma.getBasestationId()); pDevice.mCell.setMNC(identityCdma.getSystemId()); pDevice.mCell.setLAC(identityCdma.getNetworkId()); pDevice.mCell.setSID(identityCdma.getSystemId()); } else if (info instanceof CellInfoLte) { final CellSignalStrengthLte lte = ((CellInfoLte) info) .getCellSignalStrength(); final CellIdentityLte identityLte = ((CellInfoLte) info) .getCellIdentity(); //Signal Strength pDevice.mCell.setDBM(lte.getDbm()); pDevice.mCell.setTimingAdvance(lte.getTimingAdvance()); //Cell Identity pDevice.mCell.setMCC(identityLte.getMcc()); pDevice.mCell.setMNC(identityLte.getMnc()); pDevice.mCell.setCID(identityLte.getCi()); } else if (lCurrentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2 && info instanceof CellInfoWcdma) { final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info) .getCellSignalStrength(); final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info) .getCellIdentity(); //Signal Strength pDevice.mCell.setDBM(wcdma.getDbm()); //Cell Identity pDevice.mCell.setLAC(identityWcdma.getLac()); pDevice.mCell.setMCC(identityWcdma.getMcc()); pDevice.mCell.setMNC(identityWcdma.getMnc()); pDevice.mCell.setCID(identityWcdma.getCid()); pDevice.mCell.setPSC(identityWcdma.getPsc()); } else { Log.i(TAG, mTAG + "Unknown type of cell signal! " + "ClassName: " + info.getClass().getSimpleName() + " ToString: " + info.toString()); } if (pDevice.mCell.isValid()) { break; } } } } catch (NullPointerException npe) { Log.e(TAG, mTAG + "loadCellInfo: Unable to obtain cell signal information: ", npe); } }
Example #6
Source File: DeviceApi18.java From AIMSICDL with GNU General Public License v3.0 | 4 votes |
public static void loadCellInfo(TelephonyManager tm, Device pDevice) { int lCurrentApiVersion = android.os.Build.VERSION.SDK_INT; try { if (pDevice.mCell == null) { pDevice.mCell = new Cell(); } List<CellInfo> cellInfoList = tm.getAllCellInfo(); if (cellInfoList != null) { for (final CellInfo info : cellInfoList) { //Network Type pDevice.mCell.setNetType(tm.getNetworkType()); if (info instanceof CellInfoGsm) { final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength(); final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity(); // Signal Strength pDevice.mCell.setDBM(gsm.getDbm()); // [dBm] // Cell Identity pDevice.mCell.setCID(identityGsm.getCid()); pDevice.mCell.setMCC(identityGsm.getMcc()); pDevice.mCell.setMNC(identityGsm.getMnc()); pDevice.mCell.setLAC(identityGsm.getLac()); } else if (info instanceof CellInfoCdma) { final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength(); final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity(); // Signal Strength pDevice.mCell.setDBM(cdma.getDbm()); // Cell Identity pDevice.mCell.setCID(identityCdma.getBasestationId()); pDevice.mCell.setMNC(identityCdma.getSystemId()); pDevice.mCell.setLAC(identityCdma.getNetworkId()); pDevice.mCell.setSID(identityCdma.getSystemId()); } else if (info instanceof CellInfoLte) { final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength(); final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity(); // Signal Strength pDevice.mCell.setDBM(lte.getDbm()); pDevice.mCell.setTimingAdvance(lte.getTimingAdvance()); // Cell Identity pDevice.mCell.setMCC(identityLte.getMcc()); pDevice.mCell.setMNC(identityLte.getMnc()); pDevice.mCell.setCID(identityLte.getCi()); } else if (lCurrentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2 && info instanceof CellInfoWcdma) { final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength(); final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info).getCellIdentity(); // Signal Strength pDevice.mCell.setDBM(wcdma.getDbm()); // Cell Identity pDevice.mCell.setLAC(identityWcdma.getLac()); pDevice.mCell.setMCC(identityWcdma.getMcc()); pDevice.mCell.setMNC(identityWcdma.getMnc()); pDevice.mCell.setCID(identityWcdma.getCid()); pDevice.mCell.setPSC(identityWcdma.getPsc()); } else { Log.i(TAG, mTAG + "Unknown type of cell signal!" + "\n ClassName: " + info.getClass().getSimpleName() + "\n ToString: " + info.toString()); } if (pDevice.mCell.isValid()) { break; } } } } catch (NullPointerException npe) { Log.e(TAG, mTAG + "loadCellInfo: Unable to obtain cell signal information: ", npe); } }
Example #7
Source File: DeviceInfo.java From proofmode with GNU General Public License v3.0 | 4 votes |
public static String getCellInfo(Context ctx) throws SecurityException { TelephonyManager tel = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); JSONArray cellList = new JSONArray(); // Type of the network int phoneTypeInt = tel.getPhoneType(); String phoneType = null; phoneType = phoneTypeInt == TelephonyManager.PHONE_TYPE_GSM ? "gsm" : phoneType; phoneType = phoneTypeInt == TelephonyManager.PHONE_TYPE_CDMA ? "cdma" : phoneType; //from Android M up must use getAllCellInfo if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { List<CellInfo> infos = null; infos = tel.getAllCellInfo(); for (int i = 0; i < infos.size(); ++i) { try { JSONObject cellObj = new JSONObject(); CellInfo info = infos.get(i); if (info instanceof CellInfoGsm) { CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength(); CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity(); cellObj.put("cellId", identityGsm.getCid()); cellObj.put("lac", identityGsm.getLac()); cellObj.put("dbm", gsm.getDbm()); cellList.put(cellObj); } else if (info instanceof CellInfoLte) { CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength(); CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity(); cellObj.put("cellId", identityLte.getCi()); cellObj.put("tac", identityLte.getTac()); cellObj.put("dbm", lte.getDbm()); cellList.put(cellObj); } } catch (Exception ex) { } } } return cellList.toString(); }
Example #8
Source File: PlatformNetworksManager.java From 365browser with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private static VisibleCell getVisibleCellPostJellyBeanMr1( @Nullable CellInfo cellInfo, long elapsedTime, long currentTime) { if (cellInfo == null) { return VisibleCell.UNKNOWN_VISIBLE_CELL; } long cellInfoAge = elapsedTime - TimeUnit.NANOSECONDS.toMillis(cellInfo.getTimeStamp()); long cellTimestamp = currentTime - cellInfoAge; if (cellInfo instanceof CellInfoCdma) { CellIdentityCdma cellIdentityCdma = ((CellInfoCdma) cellInfo).getCellIdentity(); return VisibleCell.builder(VisibleCell.CDMA_RADIO_TYPE) .setCellId(cellIdentityCdma.getBasestationId()) .setLocationAreaCode(cellIdentityCdma.getNetworkId()) .setMobileNetworkCode(cellIdentityCdma.getSystemId()) .setTimestamp(cellTimestamp) .build(); } if (cellInfo instanceof CellInfoGsm) { CellIdentityGsm cellIdentityGsm = ((CellInfoGsm) cellInfo).getCellIdentity(); return VisibleCell.builder(VisibleCell.GSM_RADIO_TYPE) .setCellId(cellIdentityGsm.getCid()) .setLocationAreaCode(cellIdentityGsm.getLac()) .setMobileCountryCode(cellIdentityGsm.getMcc()) .setMobileNetworkCode(cellIdentityGsm.getMnc()) .setTimestamp(cellTimestamp) .build(); } if (cellInfo instanceof CellInfoLte) { CellIdentityLte cellIdLte = ((CellInfoLte) cellInfo).getCellIdentity(); return VisibleCell.builder(VisibleCell.LTE_RADIO_TYPE) .setCellId(cellIdLte.getCi()) .setMobileCountryCode(cellIdLte.getMcc()) .setMobileNetworkCode(cellIdLte.getMnc()) .setPhysicalCellId(cellIdLte.getPci()) .setTrackingAreaCode(cellIdLte.getTac()) .setTimestamp(cellTimestamp) .build(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo instanceof CellInfoWcdma) { // CellInfoWcdma is only usable JB MR2 upwards. CellIdentityWcdma cellIdentityWcdma = ((CellInfoWcdma) cellInfo).getCellIdentity(); return VisibleCell.builder(VisibleCell.WCDMA_RADIO_TYPE) .setCellId(cellIdentityWcdma.getCid()) .setLocationAreaCode(cellIdentityWcdma.getLac()) .setMobileCountryCode(cellIdentityWcdma.getMcc()) .setMobileNetworkCode(cellIdentityWcdma.getMnc()) .setPrimaryScramblingCode(cellIdentityWcdma.getPsc()) .setTimestamp(cellTimestamp) .build(); } return VisibleCell.UNKNOWN_VISIBLE_CELL; }
Example #9
Source File: PhoneStateScanner.java From PhoneProfilesPlus with Apache License 2.0 | 4 votes |
private void getAllCellInfo(List<CellInfo> cellInfo) { // only for registered cells is returned identify // SlimKat in Galaxy Nexus - returns null :-/ // Honor 7 - returns empty list (not null), Dual SIM? //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cellInfo="+cellInfo); if (cellInfo!=null) { if (Permissions.checkLocation(context.getApplicationContext())) { //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "---- start ----------------------------"); boolean anyRegistered = false; for (CellInfo _cellInfo : cellInfo) { //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "registered="+_cellInfo.isRegistered()); boolean isRegistered = false; if (_cellInfo instanceof CellInfoGsm) { //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm info="+_cellInfo); CellIdentityGsm identityGsm = ((CellInfoGsm) _cellInfo).getCellIdentity(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm cid="+identityGsm.getCid()); if (isValidCellId(identityGsm.getCid())) { if (_cellInfo.isRegistered()) { registeredCell = identityGsm.getCid(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm registeredCell="+registeredCell); lastConnectedTime = Calendar.getInstance().getTimeInMillis(); isRegistered = true; } } } else if (_cellInfo instanceof CellInfoLte) { //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte info="+_cellInfo); CellIdentityLte identityLte = ((CellInfoLte) _cellInfo).getCellIdentity(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte cid="+identityLte.getCi()); if (isValidCellId(identityLte.getCi())) { if (_cellInfo.isRegistered()) { registeredCell = identityLte.getCi(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte registeredCell="+registeredCell); lastConnectedTime = Calendar.getInstance().getTimeInMillis(); isRegistered = true; } } } else if (_cellInfo instanceof CellInfoWcdma) { //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma info="+_cellInfo); CellIdentityWcdma identityWcdma = ((CellInfoWcdma) _cellInfo).getCellIdentity(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma cid=" + identityWcdma.getCid()); if (isValidCellId(identityWcdma.getCid())) { if (_cellInfo.isRegistered()) { registeredCell = identityWcdma.getCid(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma registeredCell="+registeredCell); lastConnectedTime = Calendar.getInstance().getTimeInMillis(); isRegistered = true; } } } else if (_cellInfo instanceof CellInfoCdma) { //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cdma info="+_cellInfo); CellIdentityCdma identityCdma = ((CellInfoCdma) _cellInfo).getCellIdentity(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma cid="+identityCdma.getBasestationId()); if (isValidCellId(identityCdma.getBasestationId())) { if (_cellInfo.isRegistered()) { registeredCell = identityCdma.getBasestationId(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cdma registeredCell="+registeredCell); lastConnectedTime = Calendar.getInstance().getTimeInMillis(); isRegistered = true; } } } /*else { PPApplication.logE("PhoneStateScanner.getAllCellInfo", "unknown info="+_cellInfo); }*/ if (isRegistered) { anyRegistered = true; /*if (PPApplication.logEnabled()) { PPApplication.logE("PhoneStateScanner.getAllCellInfo", "registeredCell=" + registeredCell); PPApplication.logE("PhoneStateScanner.getAllCellInfo", "is registered, save it"); }*/ DatabaseHandler db = DatabaseHandler.getInstance(context); db.updateMobileCellLastConnectedTime(registeredCell, lastConnectedTime); doAutoRegistration(registeredCell); } } if (!anyRegistered) { //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "empty cellInfo"); registeredCell = Integer.MAX_VALUE; doAutoRegistration(registeredCell); } //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "---- end ----------------------------"); } } //else // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cell info is null"); }
Example #10
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. * <p> * This method will set the cell's identity data, its signal strength and * whether it is the currently serving cell. * @return The new or updated entry. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public CellTowerLte update(CellInfoLte cell) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return null; CellIdentityLte cid = cell.getCellIdentity(); CellTowerLte result = null; CellTowerLte cand = this.get(cid.getMcc(), cid.getMnc(), cid.getTac(), cid.getCi()); if ((cand != null) && CellTower.matches(cid.getPci(), cand.getPci())) result = cand; if (result == null) { cand = this.get(cid.getPci()); if ((cand != null) && ((cid.getMcc() == Integer.MAX_VALUE) || CellTower.matches(cid.getMcc(), cand.getMcc())) && ((cid.getMnc() == Integer.MAX_VALUE) || CellTower.matches(cid.getMnc(), cand.getMnc())) && ((cid.getTac() == Integer.MAX_VALUE) || CellTower.matches(cid.getTac(), cand.getTac())) && ((cid.getCi() == Integer.MAX_VALUE) ||CellTower.matches(cid.getCi(), cand.getCi()))) result = cand; } if (result == null) result = new CellTowerLte(cid.getMcc(), cid.getMnc(), cid.getTac(), cid.getCi(), cid.getPci()); if (result.getMcc() == CellTower.UNKNOWN) result.setMcc(cid.getMcc()); if (result.getMnc() == CellTower.UNKNOWN) result.setMnc(cid.getMnc()); if (result.getTac() == CellTower.UNKNOWN) result.setTac(cid.getTac()); if (result.getCi() == CellTower.UNKNOWN) result.setCi(cid.getCi()); if (result.getPci() == CellTower.UNKNOWN) result.setPci(cid.getPci()); this.put(result.getText(), result); this.put(result.getAltText(), result); result.setCellInfo(true); result.setDbm(cell.getCellSignalStrength().getDbm()); result.setServing(cell.isRegistered()); Log.d(this.getClass().getSimpleName(), String.format("Added CellInfoLte for %s, %d G, %d dBm", result.getText(), result.getGeneration(), result.getDbm())); return result; }
Example #11
Source File: CellIdentityLteAssert.java From assertj-android with Apache License 2.0 | 4 votes |
public CellIdentityLteAssert(CellIdentityLte actual) { super(actual, CellIdentityLteAssert.class); }