android.telephony.CellInfo Java Examples
The following examples show how to use
android.telephony.CellInfo.
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: Api17PlusMeasurementParser.java From TowerCollector with Mozilla Public License 2.0 | 7 votes |
private void removeDuplicatedCells(List<CellInfo> cells) { List<CellInfo> cellsToRemove = new ArrayList<CellInfo>(); Set<String> uniqueCellKeys = new HashSet<String>(); for (CellInfo cell : cells) { String key = cellIdentityConverter.createCellKey(cell); if (uniqueCellKeys.contains(key)) { Timber.d("removeDuplicatedCells(): Remove duplicated cell: %s", key); cellsToRemove.add(cell); } else { uniqueCellKeys.add(key); } } cells.removeAll(cellsToRemove); }
Example #2
Source File: PlatformNetworksManager.java From 365browser with Apache License 2.0 | 6 votes |
/** * Returns a CellInfo object representing the currently registered base stations, containing * its identity fields and signal strength. Null if no base station is active. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @Nullable private static CellInfo getActiveCellInfo(TelephonyManager telephonyManager) { int numRegisteredCellInfo = 0; List<CellInfo> cellInfos = telephonyManager.getAllCellInfo(); if (cellInfos == null) { return null; } CellInfo result = null; for (int i = 0; i < cellInfos.size(); i++) { CellInfo cellInfo = cellInfos.get(i); if (cellInfo.isRegistered()) { numRegisteredCellInfo++; if (numRegisteredCellInfo > 1) { return null; } result = cellInfo; } } // Only found one registered cellinfo, so we know which base station was used to measure // network quality return result; }
Example #3
Source File: LauncherActivity.java From Android-Plugin-Framework with MIT License | 6 votes |
private void requestPermission() { if (Build.VERSION.SDK_INT >= 17) { boolean isGranted = true; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { if (checkSelfPermission("android.permission.ACCESS_COARSE_LOCATION") == PackageManager.PERMISSION_DENIED) { isGranted = false; requestPermissions(new String[]{"android.permission.ACCESS_COARSE_LOCATION"}, 10086); } } if (isGranted) { TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); try { @SuppressLint("MissingPermission") List<CellInfo> list = telephonyManager.getAllCellInfo(); if (list != null) { LogUtil.v(list); } } catch (Exception e) { e.printStackTrace(); } } } }
Example #4
Source File: PlatformNetworksManager.java From 365browser with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private static Set<VisibleCell> getAllVisibleCellsPostJellyBeanMr1( TelephonyManager telephonyManager) { Set<VisibleCell> visibleCells = new HashSet<>(); // Retrieve visible cell networks List<CellInfo> cellInfos = telephonyManager.getAllCellInfo(); if (cellInfos == null) { return visibleCells; } long elapsedTime = sTimeProvider.getElapsedRealtime(); long currentTime = sTimeProvider.getCurrentTime(); for (int i = 0; i < cellInfos.size(); i++) { CellInfo cellInfo = cellInfos.get(i); VisibleCell visibleCell = getVisibleCellPostJellyBeanMr1(cellInfo, elapsedTime, currentTime); if (visibleCell.radioType() != VisibleCell.UNKNOWN_RADIO_TYPE) { visibleCells.add(visibleCell); } } return visibleCells; }
Example #5
Source File: AndroidCellularSignalStrength.java From 365browser with Apache License 2.0 | 6 votes |
/** * @return Signal strength (in dbM) from {@link cellInfo}. Returns {@link * CellularSignalStrengthError#ERROR_NOT_SUPPORTED} if the signal strength is unavailable. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private static int getSignalStrengthDbm(CellInfo cellInfo) { if (cellInfo instanceof CellInfoCdma) { return ((CellInfoCdma) cellInfo).getCellSignalStrength().getDbm(); } if (cellInfo instanceof CellInfoGsm) { return ((CellInfoGsm) cellInfo).getCellSignalStrength().getDbm(); } if (cellInfo instanceof CellInfoLte) { return ((CellInfoLte) cellInfo).getCellSignalStrength().getDbm(); } if (cellInfo instanceof CellInfoWcdma) { return ((CellInfoWcdma) cellInfo).getCellSignalStrength().getDbm(); } return CellularSignalStrengthError.ERROR_NOT_SUPPORTED; }
Example #6
Source File: AndroidCellularSignalStrength.java From 365browser with Apache License 2.0 | 6 votes |
/** * @return the signal level from {@link cellInfo}. Returns {@link * CellularSignalStrengthError#ERROR_NOT_SUPPORTED} if the signal * level is unavailable with lower value indicating lower signal strength. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private static int getSignalStrengthLevel(CellInfo cellInfo) { if (cellInfo instanceof CellInfoCdma) { return ((CellInfoCdma) cellInfo).getCellSignalStrength().getLevel(); } if (cellInfo instanceof CellInfoGsm) { return ((CellInfoGsm) cellInfo).getCellSignalStrength().getLevel(); } if (cellInfo instanceof CellInfoLte) { return ((CellInfoLte) cellInfo).getCellSignalStrength().getLevel(); } if (cellInfo instanceof CellInfoWcdma) { return ((CellInfoWcdma) cellInfo).getCellSignalStrength().getLevel(); } return CellularSignalStrengthError.ERROR_NOT_SUPPORTED; }
Example #7
Source File: RadioInfo.java From CellularSignal with GNU General Public License v3.0 | 6 votes |
private void getWcdmaSignalStrength() { List<CellInfo> cellInfoList = mTM.getAllCellInfo(); if (cellInfoList == null) { //Log.e(Tag,"getAllCellInfo is null"); return; } //Log.e(Tag,"getAllCellInfo size "+cellInfoList.size()); for (CellInfo cellInfo : cellInfoList) { if (!cellInfo.isRegistered()) continue; if (cellInfo instanceof CellInfoWcdma) { CellInfoWcdma wcdmaInfo = (CellInfoWcdma) cellInfo; wcdma_RSSI = wcdmaInfo.getCellSignalStrength().getDbm(); } } }
Example #8
Source File: CellLocationScannerDialogFragment.java From Easer with GNU General Public License v3.0 | 6 votes |
@Override protected Void doInBackground(Void... voids) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { List<CellInfo> cellInfoList = telephonyManager.getAllCellInfo(); if (cellInfoList != null) { for (CellInfo cellInfo : cellInfoList) { if (cellInfo.isRegistered()) { publishProgress(CellLocationSingleData.fromCellInfo(cellInfo)); } } } } else { CellLocation cellLocation = telephonyManager.getCellLocation(); publishProgress(CellLocationSingleData.fromCellLocation(cellLocation)); } return null; }
Example #9
Source File: MobileUtils.java From TowerCollector with Mozilla Public License 2.0 | 6 votes |
private static boolean isApi17CellInfoAvailable(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); List<CellInfo> cells; try { cells = telephonyManager.getAllCellInfo(); } catch (SecurityException ex) { Timber.d(ex, "isApi17CellInfoAvailable(): Result = coarse location permission is denied"); return false; } if (cells == null || cells.size() == 0) { Timber.d("isApi17CellInfoAvailable(): Result = no cell info"); return false; } CellIdentityValidator validator = new CellIdentityValidator(); for (CellInfo cell : cells) { if (validator.isValid(cell)) { Timber.d("isApi17CellInfoAvailable(): Result = true"); return true; } } Timber.d("isApi17CellInfoAvailable(): Result = false"); return false; }
Example #10
Source File: CellsInfoDataCollector.java From DataLogger with MIT License | 5 votes |
private void logCellInfo(List<CellInfo> cellInfo){ if (logger != null) { String message = getCellInfoString(cellInfo); logger.log(message); Log.d(TAG, message); logger.log(System.lineSeparator()); } }
Example #11
Source File: CellIdentityValidator.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public boolean isValid(CellInfo cellInfo) { if (cellInfo instanceof CellInfoGsm) { CellInfoGsm gsmCellInfo = (CellInfoGsm) cellInfo; // If is compatible with API 17 hack (PSC on GSM) return true boolean wcdmaApi17Valid = getWcdmaValidator().isValid(gsmCellInfo.getCellIdentity()); if (wcdmaApi17Valid) return true; return getGsmValidator().isValid(gsmCellInfo.getCellIdentity()); } if (cellInfo instanceof CellInfoWcdma) { CellInfoWcdma wcdmaCellInfo = (CellInfoWcdma) cellInfo; return getWcdmaValidator().isValid(wcdmaCellInfo.getCellIdentity()); } if (cellInfo instanceof CellInfoLte) { CellInfoLte lteCellInfo = (CellInfoLte) cellInfo; return getLteValidator().isValid(lteCellInfo.getCellIdentity()); } if (cellInfo instanceof CellInfoCdma) { CellInfoCdma cdmaCellInfo = (CellInfoCdma) cellInfo; return getCdmaValidator().isValid(cdmaCellInfo.getCellIdentity()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && cellInfo instanceof CellInfoNr) { CellInfoNr nrCellInfo = (CellInfoNr) cellInfo; return getNrValidator().isValid((CellIdentityNr) nrCellInfo.getCellIdentity()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && cellInfo instanceof CellInfoTdscdma) { CellInfoTdscdma tdscdmaCellInfo = (CellInfoTdscdma) cellInfo; return getTdscdmaValidator().isValid(tdscdmaCellInfo.getCellIdentity()); } throw new UnsupportedOperationException("Cell identity type not supported `" + cellInfo.getClass().getName() + "`"); }
Example #12
Source File: CellTowerListGsm.java From satstat with GNU General Public License v3.0 | 5 votes |
/** * Adds or updates a list of cell towers. * <p> * This method first calls {@link #removeSource(int)} with * {@link com.vonglasow.michael.satstat.data.CellTower#SOURCE_CELL_INFO} as * its argument. Then it iterates through all entries in {@code cells} and * updates each entry that is of type {@link android.telephony.CellInfoGsm} * or {@link android.telephony.CellInfoWcdma} by calling * {@link #update(CellInfoGsm)} or {@link #update(CellInfoWcdma)} * (depending on type), passing that entry as the argument. */ public void updateAll(List<CellInfo> cells) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return; this.removeSource(CellTower.SOURCE_CELL_INFO); if (cells == null) return; for (CellInfo cell : cells) if (cell instanceof CellInfoGsm) this.update((CellInfoGsm) cell); else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) if (cell instanceof CellInfoWcdma) this.update((CellInfoWcdma) cell); }
Example #13
Source File: CellsInfoDataCollector.java From DataLogger with MIT License | 5 votes |
@Override public void onCellInfoChanged(List<CellInfo> cellInfo) { super.onCellInfoChanged(cellInfo); if (cellInfo == null) return; logCellInfo(cellInfo); }
Example #14
Source File: CellLocationController.java From cordova-plugin-advanced-geolocation with Apache License 2.0 | 5 votes |
/** * Returns all observed cell information from all radios on the device including the primary and * neighboring cells. Calling this method does not trigger a call to onCellInfoChanged(), or change * the rate at which onCellInfoChanged() is called. */ private void getAllCellInfos(){ if(_telephonyManager != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { final List<CellInfo> cellInfos = _telephonyManager.getAllCellInfo(); processCellInfos(cellInfos); } else { Log.w(TAG, "Unable to provide cell info due to version restriction"); } }
Example #15
Source File: CellTowerListCdma.java From satstat with GNU General Public License v3.0 | 5 votes |
/** * Adds or updates a list of cell towers. * <p> * This method first calls {@link #removeSource(int)} with * {@link com.vonglasow.michael.satstat.data.CellTower#SOURCE_CELL_INFO} as * its argument. Then it iterates through all entries in {@code cells} and * updates each entry that is of type {@link android.telephony.CellInfoCdma} * by calling {@link #update(CellInfoCdma)}, passing that entry as the * argument. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void updateAll(List<CellInfo> cells) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return; this.removeSource(CellTower.SOURCE_CELL_INFO); if (cells == null) return; for (CellInfo cell : cells) if (cell instanceof CellInfoCdma) this.update((CellInfoCdma) cell); }
Example #16
Source File: CellBackendHelper.java From android_external_UnifiedNlpApi with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") private synchronized void fallbackScan() { if (lastScan + MIN_UPDATE_INTERVAL > System.currentTimeMillis()) return; List<CellInfo> allCellInfo = telephonyManager.getAllCellInfo(); if ((allCellInfo == null || allCellInfo.isEmpty()) && telephonyManager.getNetworkType() > 0) { allCellInfo = new ArrayList<CellInfo>(); CellLocation cellLocation = telephonyManager.getCellLocation(); CellInfo cellInfo = fromCellLocation(cellLocation); if (cellInfo != null) allCellInfo.add(cellInfo); } onCellsChanged(allCellInfo); }
Example #17
Source File: MainActivity.java From satstat with GNU General Public License v3.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void onCellInfoChanged(List<CellInfo> cellInfo) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return; if (radioSectionFragment != null) radioSectionFragment.updateCellData(null, null, cellInfo); }
Example #18
Source File: TelephonyRegistry.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) { if (!checkNotifyPermission("notifyCellInfo()")) { return; } if (VDBG) { log("notifyCellInfoForSubscriber: subId=" + subId + " cellInfo=" + cellInfo); } int phoneId = SubscriptionManager.getPhoneId(subId); synchronized (mRecords) { if (validatePhoneId(phoneId)) { mCellInfo.set(phoneId, cellInfo); for (Record r : mRecords) { if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) && idMatch(r.subId, subId, phoneId) && checkLocationAccess(r)) { try { if (DBG_LOC) { log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r); } r.callback.onCellInfoChanged(cellInfo); } catch (RemoteException ex) { mRemoveList.add(r.binder); } } } } handleRemoveListLocked(); } }
Example #19
Source File: ScanService.java From spidey with GNU General Public License v3.0 | 5 votes |
private void shareCellInfo(com.spideyapp.sqlite.model.CellInfo cellInfo) { Intent intent = new Intent(NOTIFICATION); intent.putExtra("cid",cellInfo.getCID()); intent.putExtra("dbm",cellInfo.getDBM()); sendBroadcast(intent); }
Example #20
Source File: EmergencyAffordanceService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private boolean handleUpdateCellInfo() { List<CellInfo> cellInfos = mTelephonyManager.getAllCellInfo(); if (cellInfos == null) { return false; } boolean stopScanningAfterScan = false; for (CellInfo cellInfo : cellInfos) { int mcc = 0; if (cellInfo instanceof CellInfoGsm) { mcc = ((CellInfoGsm) cellInfo).getCellIdentity().getMcc(); } else if (cellInfo instanceof CellInfoLte) { mcc = ((CellInfoLte) cellInfo).getCellIdentity().getMcc(); } else if (cellInfo instanceof CellInfoWcdma) { mcc = ((CellInfoWcdma) cellInfo).getCellIdentity().getMcc(); } if (mccRequiresEmergencyAffordance(mcc)) { setNetworkNeedsEmergencyAffordance(true); return true; } else if (mcc != 0 && mcc != Integer.MAX_VALUE) { // we found an mcc that isn't in the list, abort stopScanningAfterScan = true; } } if (stopScanningAfterScan) { stopScanning(); } else { onCellScanFinishedUnsuccessful(); } setNetworkNeedsEmergencyAffordance(false); return false; }
Example #21
Source File: CellTowerListLte.java From satstat with GNU General Public License v3.0 | 5 votes |
/** * Adds or updates a list of cell towers. * <p> * This method first calls {@link #removeSource(int)} with * {@link com.vonglasow.michael.satstat.data.CellTower#SOURCE_CELL_INFO} as * its argument. Then it iterates through all entries in {@code cells} and * updates each entry that is of type {@link android.telephony.CellInfoLte} * by calling {@link #update(CellInfoLte)}, passing that entry as the * argument. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public void updateAll(List<CellInfo> cells) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return; this.removeSource(CellTower.SOURCE_CELL_INFO); if (cells == null) return; for (CellInfo cell : cells) if (cell instanceof CellInfoLte) this.update((CellInfoLte) cell); }
Example #22
Source File: TelephonyHooker.java From DoraemonKit with Apache License 2.0 | 5 votes |
@Override public Object onInvoke(Object originObject, Object proxyObject, Method method, Object[] args) throws InvocationTargetException, IllegalAccessException { if (!GpsMockManager.getInstance().isMocking()) { return method.invoke(originObject, args); } return new ArrayList<CellInfo>(); }
Example #23
Source File: PhoneStateScanner.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
@SuppressLint("MissingPermission") private void getAllCellInfo() { if (telephonyManager != null) { List<CellInfo> cellInfo = null; if (Permissions.checkLocation(context.getApplicationContext())) cellInfo = telephonyManager.getAllCellInfo(); //PPApplication.logE("PhoneStateScanner.getAllCellInfo.2", "cellInfo="+cellInfo); getAllCellInfo(cellInfo); } }
Example #24
Source File: CellLocationController.java From cordova-plugin-advanced-geolocation with Apache License 2.0 | 5 votes |
private static void processCellInfos(List<CellInfo> cellInfos){ if(cellInfos != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ for(CellInfo cellInfo : cellInfos){ if(cellInfo instanceof CellInfoWcdma){ final CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo; sendCallback(PluginResult.Status.OK, JSONHelper.cellInfoWCDMAJSON(cellInfoWcdma, _returnSignalStrength)); } if(cellInfo instanceof CellInfoGsm){ final CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo; sendCallback(PluginResult.Status.OK, JSONHelper.cellInfoGSMJSON(cellInfoGsm, _returnSignalStrength)); } if(cellInfo instanceof CellInfoCdma){ final CellInfoCdma cellIdentityCdma = (CellInfoCdma) cellInfo; sendCallback(PluginResult.Status.OK, JSONHelper.cellInfoCDMAJSON(cellIdentityCdma, _returnSignalStrength)); } if(cellInfo instanceof CellInfoLte){ final CellInfoLte cellInfoLte = (CellInfoLte) cellInfo; sendCallback(PluginResult.Status.OK, JSONHelper.cellInfoLTEJSON(cellInfoLte, _returnSignalStrength)); } Log.d(TAG,cellInfo.toString()); } } else { Log.e(TAG, "CellInfoLocation returning null. Is it supported on this phone?"); // There are several reasons as to why cell location data would be null. // * could be an older device running an unsupported version of the Android OS // * could be a device that doesn't support this capability. // * could be incorrect permissions: ACCESS_COARSE_LOCATION sendCallback(PluginResult.Status.ERROR, JSONHelper.errorJSON(CELLINFO_PROVIDER, ErrorMessages.CELL_DATA_IS_NULL())); } }
Example #25
Source File: MeasurementUpdater.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public synchronized void setLastCellInfo(List<CellInfo> cellInfo) { Timber.d("setLastCellInfo(): Cell info updated: %s ", cellInfo); this.lastCellInfo = cellInfo; this.lastNetworkType = NetworkGroup.Unknown; this.lastOperatorName = null; notifyIfReadyToProcess(); }
Example #26
Source File: CellBackendHelper.java From android_external_UnifiedNlpApi with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") private synchronized void fallbackScan() { if (lastScan + MIN_UPDATE_INTERVAL > System.currentTimeMillis()) return; List<CellInfo> allCellInfo = telephonyManager.getAllCellInfo(); if ((allCellInfo == null || allCellInfo.isEmpty()) && telephonyManager.getNetworkType() > 0) { allCellInfo = new ArrayList<CellInfo>(); CellLocation cellLocation = telephonyManager.getCellLocation(); CellInfo cellInfo = fromCellLocation(cellLocation); if (cellInfo != null) allCellInfo.add(cellInfo); } onCellsChanged(allCellInfo); }
Example #27
Source File: AndroidCellularSignalStrength.java From 365browser with Apache License 2.0 | 5 votes |
/** * Returns all observed cell information from all radios on the device including the primary * and neighboring cells. Returns only the information of cells that are registered to a * mobile network. May return {@code null}. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private static List<CellInfo> getRegisteredCellInfo() { if (!isAPIAvailable()) { return null; } TelephonyManager telephonyManager = (TelephonyManager) ContextUtils.getApplicationContext().getSystemService( Context.TELEPHONY_SERVICE); if (telephonyManager == null) { return null; } List<CellInfo> cellInfos = telephonyManager.getAllCellInfo(); if (cellInfos == null) { return null; } Iterator<CellInfo> iter = cellInfos.iterator(); while (iter.hasNext()) { if (!iter.next().isRegistered()) { iter.remove(); } } return cellInfos; }
Example #28
Source File: PlatformNetworksManager.java From 365browser with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private static VisibleCell getConnectedCellPostJellyBeanMr1( Context context, TelephonyManager telephonyManager) { if (!hasLocationPermission(context)) { return VisibleCell.UNKNOWN_MISSING_LOCATION_PERMISSION_VISIBLE_CELL; } CellInfo cellInfo = getActiveCellInfo(telephonyManager); return getVisibleCellPostJellyBeanMr1( cellInfo, sTimeProvider.getElapsedRealtime(), sTimeProvider.getCurrentTime()); }
Example #29
Source File: AndroidCellularSignalStrength.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return the signal strength level (between 0 and 4, both inclusive) for the currently * registered cellular network with lower value indicating lower signal strength. Returns * {@link CellularSignalStrengthError#ERROR_NOT_SUPPORTED} if the signal strength level is * unavailable or if there are multiple cellular radios on the device. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) @CalledByNative public static int getSignalStrengthLevel() { List<CellInfo> cellInfos = getRegisteredCellInfo(); return cellInfos == null || cellInfos.size() != 1 ? CellularSignalStrengthError.ERROR_NOT_SUPPORTED : getSignalStrengthLevel(cellInfos.get(0)); }
Example #30
Source File: AndroidCellularSignalStrength.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return Signal strength (in dbM) for the currently registered cellular network. Returns * {@link CellularSignalStrengthError#ERROR_NOT_SUPPORTED} if the signal strength is * unavailable or if there are multiple cellular radios on the device. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) @CalledByNative public static int getSignalStrengthDbm() { List<CellInfo> cellInfos = getRegisteredCellInfo(); return cellInfos == null || cellInfos.size() != 1 ? CellularSignalStrengthError.ERROR_NOT_SUPPORTED : getSignalStrengthDbm(cellInfos.get(0)); }