android.telephony.SignalStrength Java Examples
The following examples show how to use
android.telephony.SignalStrength.
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: TelephonyRegistry.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int phoneId, int subId) { long ident = Binder.clearCallingIdentity(); try { mBatteryStats.notePhoneSignalStrength(signalStrength); } catch (RemoteException e) { /* The remote entity disappeared, we can safely ignore the exception. */ } finally { Binder.restoreCallingIdentity(ident); } Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED); Bundle data = new Bundle(); signalStrength.fillInNotifierBundle(data); intent.putExtras(data); intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); intent.putExtra(PhoneConstants.SLOT_KEY, phoneId); mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); }
Example #2
Source File: CellularBatteryStats.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void initialize() { mLoggingDurationMs = 0; mKernelActiveTimeMs = 0; mNumPacketsTx = 0; mNumBytesTx = 0; mNumPacketsRx = 0; mNumBytesRx = 0; mSleepTimeMs = 0; mIdleTimeMs = 0; mRxTimeMs = 0; mEnergyConsumedMaMs = 0; mTimeInRatMs = new long[BatteryStats.NUM_DATA_CONNECTION_TYPES]; Arrays.fill(mTimeInRatMs, 0); mTimeInRxSignalStrengthLevelMs = new long[SignalStrength.NUM_SIGNAL_STRENGTH_BINS]; Arrays.fill(mTimeInRxSignalStrengthLevelMs, 0); mTxTimeMs = new long[ModemActivityInfo.TX_POWER_LEVELS]; Arrays.fill(mTxTimeMs, 0); return; }
Example #3
Source File: SignalStrengthPresenter.java From microbit with Apache License 2.0 | 6 votes |
private int getCdmaLevel(SignalStrength signalStrength) { final int cdmaDbm = signalStrength.getCdmaDbm(); final int cdmaEcio = signalStrength.getCdmaEcio(); final int levelDbm; if(cdmaDbm >= -75) levelDbm = 4; else if(cdmaDbm >= -85) levelDbm = 3; else if(cdmaDbm >= -95) levelDbm = 2; else if(cdmaDbm >= -100) levelDbm = 1; else levelDbm = 0; final int levelEcio; // Ec/Io are in dB*10 if(cdmaEcio >= -90) levelEcio = 4; else if(cdmaEcio >= -110) levelEcio = 3; else if(cdmaEcio >= -130) levelEcio = 2; else if(cdmaEcio >= -150) levelEcio = 1; else levelEcio = 0; return (levelDbm < levelEcio) ? levelDbm : levelEcio; }
Example #4
Source File: SignalStrengths.java From SignalStrengths with Apache License 2.0 | 6 votes |
public static double getFirstValid(SignalStrength signalStrength) { for (SignalMethod method : methods) { if (method.isExcluded()) continue; double level; try { level = method.getLevel(signalStrength); } catch (Exception e) { continue; } if (SignalUtils.isValidLevel(level) && level > 0) return level; } return 0; }
Example #5
Source File: DeviceInfoActivty.java From PracticeDemo with Apache License 2.0 | 6 votes |
/** * signalStrength.isGsm() 是否GSM信号 2G or 3G * signalStrength.getCdmaDbm(); 联通3G 信号强度 * signalStrength.getCdmaEcio(); 联通3G 载干比 * signalStrength.getEvdoDbm(); 电信3G 信号强度 * signalStrength.getEvdoEcio(); 电信3G 载干比 * signalStrength.getEvdoSnr(); 电信3G 信噪比 * signalStrength.getGsmSignalStrength(); 2G 信号强度 * signalStrength.getGsmBitErrorRate(); 2G 误码率 * 载干比 ,它是指空中模拟电波中的信号与噪声的比值 */ @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); Log.d(TAG, "onSignalStrengthsChanged() called with " + "signalStrength :"+signalStrength+";\n gsmSignalStrength = [" + signalStrength.getGsmSignalStrength() + "]"); // if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) { // mTvSignalInfo.setText("GSM Strength" + signalStrength.getGsmSignalStrength()); // } else if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) { // mTvSignalInfo.setText("CDMA Strength" + signalStrength.getCdmaDbm() + " dBm"); // } else { // mTvSignalInfo.setText("Unknown PhoneType: " + mTelephonyManager.getPhoneType()); // } mTvSignalInfo.setText("IsGsm : " + signalStrength.isGsm() + "\nCDMA Dbm : " + signalStrength.getCdmaDbm() + " Dbm" + "\nCDMA Ecio : " + signalStrength.getCdmaEcio() + " dB*10" + "\nEvdo Dbm : " + signalStrength.getEvdoDbm() + " Dbm" + "\nEvdo Ecio : " + signalStrength.getEvdoEcio() + " dB*10" + "\nGsm SignalStrength : " + signalStrength.getGsmSignalStrength() + "\nGsm BitErrorRate : " + signalStrength.getGsmBitErrorRate()); }
Example #6
Source File: AndroidCellularSignalStrength.java From cronet with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override @TargetApi(Build.VERSION_CODES.M) public void onSignalStrengthsChanged(SignalStrength signalStrength) { if (ApplicationStatus.getStateForApplication() != ApplicationState.HAS_RUNNING_ACTIVITIES) { return; } try { mSignalLevel = signalStrength.getLevel(); } catch (SecurityException e) { // Catch any exceptions thrown due to unavailability of permissions on certain // Android devices. See https://crbug.com/820564 for details. mSignalLevel = CellularSignalStrengthError.ERROR_NOT_SUPPORTED; assert false; } }
Example #7
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 #8
Source File: TelephonyModule.java From react-native-telephony with MIT License | 6 votes |
@Override public void phoneSignalStrengthsUpdated(SignalStrength signalStrength) { WritableMap map = Arguments.createMap(); map.putInt("cdmaDbm", signalStrength.getCdmaDbm()); map.putInt("cdmaEcio()", signalStrength.getCdmaEcio()); map.putInt("evdoDbm", signalStrength.getEvdoDbm()); map.putInt("evdoEcio", signalStrength.getEvdoEcio()); map.putInt("evdoSnr", signalStrength.getEvdoSnr()); map.putInt("gsmBitErrorRate", signalStrength.getGsmBitErrorRate()); map.putInt("gsmSignalStrength", signalStrength.getGsmSignalStrength()); map.putBoolean("gsm", signalStrength.isGsm()); WritableMap result = Arguments.createMap(); result.putString("type", "LISTEN_SIGNAL_STRENGTHS"); result.putMap("data", map); sendEvent(PHONE_STATE_LISTENER, result); }
Example #9
Source File: DualNetworkIconData.java From Status with Apache License 2.0 | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); if (isRegistered) { int level = signalStrength.getGsmSignalStrength(); if (level > 4) level /= 7.75; else if (level < 1) { int strength = signalStrength.getCdmaDbm(); if (strength < -100) level = 0; else if (strength < -95) level = 1; else if (strength < -85) level = 2; else if (strength < -75) level = 3; else if (strength != 0) level = 4; else { strength = signalStrength.getEvdoDbm(); if (strength == 0 || strength < -100) level = 0; else if (strength < -95) level = 1; else if (strength < -85) level = 2; else if (strength < -75) level = 3; else level = 4; } } onIconUpdate(level); } }
Example #10
Source File: NetworkIconData.java From Status with Apache License 2.0 | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); NetworkIconData icon = null; if (reference != null) icon = reference.get(); if (icon != null && icon.isRegistered) icon.onIconUpdate((int) Math.round(SignalStrengths.getFirstValid(signalStrength))); }
Example #11
Source File: JSONHelper.java From cordova-plugin-advanced-geolocation with Apache License 2.0 | 5 votes |
/** * Originates from a change in signal strength * @param signalStrength SignalStrength * @return JSON */ public static String signalStrengthJSON(SignalStrength signalStrength){ final Calendar calendar = Calendar.getInstance(); final JSONObject json = new JSONObject(); try { json.put("provider", SIGNAL_STRENGTH); // Yep provider and type are same values json.put("type", SIGNAL_STRENGTH); json.put("timestamp", calendar.getTimeInMillis()); json.put("cdmaDbm", signalStrength.getCdmaDbm()); json.put("cdmaEcio", signalStrength.getCdmaEcio()); json.put("evdoDbm", signalStrength.getEvdoDbm()); json.put("evdoEcio", signalStrength.getEvdoEcio()); json.put("evdoSnr", signalStrength.getEvdoSnr()); json.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate()); json.put("gsmSignalStrength", signalStrength.getGsmSignalStrength()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ json.put("level", signalStrength.getLevel()); } json.put("isGSM", signalStrength.isGsm()); } catch(JSONException exc) { logJSONException(exc); } return json.toString(); }
Example #12
Source File: RadioInfo.java From CellularSignal with GNU General Public License v3.0 | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); //Log.e(Tag, signalStrength.toString()); get_Reflection_Method(signalStrength); try { Method getLteRsrp = signalStrength.getClass().getDeclaredMethod("getLteRsrp"); getLteRsrp.setAccessible(true); lte_RSRP = (int) getLteRsrp.invoke(signalStrength); Method getLteRsrq = signalStrength.getClass().getDeclaredMethod("getLteRsrq"); getLteRsrq.setAccessible(true); lte_RSRQ = (int) getLteRsrq.invoke(signalStrength); Method getLteRssnr = signalStrength.getClass().getDeclaredMethod("getLteRssnr"); getLteRssnr.setAccessible(true); lte_SINR = (int) getLteRssnr.invoke(signalStrength); cdma_RxPwr = signalStrength.getCdmaDbm(); cdma_EcIo = signalStrength.getCdmaEcio(); gsm_RSSI = signalStrength.getGsmSignalStrength(); getWcdmaSignalStrength(); ((MainActivity)mcontext).mSectionsPagerAdapter.notifyDataSetChanged(); } catch (Exception e) { e.printStackTrace(); } getCellIdentity(); }
Example #13
Source File: SignalStrengthPresenter.java From microbit with Apache License 2.0 | 5 votes |
private void updateSignalStrength(SignalStrength signalStrength) { final int level; Log.i(TAG, "updateSignalStrength: "); if(!isCdma(signalStrength)) { int asu = signalStrength.getGsmSignalStrength(); // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5 // asu = 0 (-113dB or less) is very weak // signal, its better to show 0 bars to the user in such cases. // asu = 99 is a special case, where the signal strength is unknown. if(asu <= 2 || asu == 99) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_NO_BAR; else if(asu >= 12) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_FOUR_BAR; else if(asu >= 8) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_THREE_BAR; else if(asu >= 5) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_TWO_BAR; else level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_ONE_BAR; } else { level = getCdmaLevel(signalStrength); } if(level != sCurrentSignalStrength) { sCurrentSignalStrength = level; MBApp application = MBApp.getApp(); Intent intent = new Intent(application, IPCService.class); intent.putExtra(IPCConstants.INTENT_TYPE, EventCategories.IPC_BLE_NOTIFICATION_CHARACTERISTIC_CHANGED); intent.putExtra(IPCConstants.INTENT_CHARACTERISTIC_MESSAGE, Utils.makeMicroBitValue (EventCategories.SAMSUNG_SIGNAL_STRENGTH_ID, level)); application.startService(intent); } }
Example #14
Source File: SignalStrengths.java From SignalStrengths with Apache License 2.0 | 5 votes |
public static double get(String methodName, SignalStrength signalStrength) { for (SignalMethod method : methods) { if (methodName.equals(method.getName())) try { return method.getLevel(signalStrength); } catch (Exception e) { e.printStackTrace(); break; } } return 0; }
Example #15
Source File: SignalListener.java From batteryhub with Apache License 2.0 | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { // TODO Auto-generated method stub super.onSignalStrengthsChanged(signalStrength); mGsmSignal = signalStrength.getGsmSignalStrength(); mCdmaDbm = signalStrength.getCdmaDbm(); mEvdoDbm = signalStrength.getEvdoDbm(); }
Example #16
Source File: TaskbarController.java From Taskbar with Apache License 2.0 | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { try { cellStrength = signalStrength.getLevel(); } catch (SecurityException e) { cellStrength = -1; } }
Example #17
Source File: DeviceNetworkStatus.java From product-emm with Apache License 2.0 | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); if (signalStrength.isGsm()) { if (signalStrength.getGsmSignalStrength() != 99) { // this is the equation used to convert a valid gsm signal to dbm. setCellSignalStrength(signalStrength.getGsmSignalStrength() * 2 - 113); } else { setCellSignalStrength(signalStrength.getGsmSignalStrength()); } } else { setCellSignalStrength(signalStrength.getCdmaDbm()); } }
Example #18
Source File: CellsInfoDataCollector.java From DataLogger with MIT License | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); // getAllCellInfo() returns all observed cell information from all radios on the device including the primary and neighboring cells // This is preferred over using getCellLocation although for older devices this may return null in which case getCellLocation should be called. logCellInfo(mTelephonyManager.getAllCellInfo()); }
Example #19
Source File: AndroidSignalStrength.java From QtAndroidTools with MIT License | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); mSignalStrength = signalStrength.getGsmSignalStrength(); signalStrengthChanged(); }
Example #20
Source File: UENavigationActivity.java From Auie with GNU General Public License v2.0 | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); String sim = UEDevice.getSimType(activity); mNavigationView.setSingalText(sim); if (sim.equals("无服务")) { mNavigationView.setSingalStatus(UISingalView.STATUS_NONE); return; } mNavigationView.setSingalStatus(UISingalView.STATUS_NORMAL); int level = 0; if (signalStrength.isGsm()) { level = signalStrength.getGsmSignalStrength(); }else { if (sim.equals("中国电信")) { level = signalStrength.getCdmaDbm(); }else { level = signalStrength.getEvdoDbm(); } } if (level == 0) { mNavigationView.setSignal(5); return; } if (level < -112) { mNavigationView.setSignal(0); }else if (level >= -111 && level < -104) { mNavigationView.setSignal(1); }else if (level >= -104 && level < -97) { mNavigationView.setSignal(2); }else if (level >= -97 && level < -90) { mNavigationView.setSignal(3); }else if (level >= -90 && level < -83) { mNavigationView.setSignal(4); }else { mNavigationView.setSignal(5); } }
Example #21
Source File: UENavigationFragmentActivity.java From Auie with GNU General Public License v2.0 | 5 votes |
@Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); String sim = UEDevice.getSimType(activity); mNavigationView.setSingalText(sim); if (sim.equals("无服务")) { mNavigationView.setSingalStatus(UISingalView.STATUS_NONE); return; } mNavigationView.setSingalStatus(UISingalView.STATUS_NORMAL); int level = 0; if (signalStrength.isGsm()) { level = signalStrength.getGsmSignalStrength(); }else { if (sim.equals("中国电信")) { level = signalStrength.getCdmaDbm(); }else { level = signalStrength.getEvdoDbm(); } } if (level == 0) { mNavigationView.setSignal(5); return; } if (level < -112) { mNavigationView.setSignal(0); }else if (level >= -111 && level < -104) { mNavigationView.setSignal(1); }else if (level >= -104 && level < -97) { mNavigationView.setSignal(2); }else if (level >= -97 && level < -90) { mNavigationView.setSignal(3); }else if (level >= -90 && level < -83) { mNavigationView.setSignal(4); }else { mNavigationView.setSignal(5); } }
Example #22
Source File: CellLocationSignalConverter.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
private Method getLteDbmMethod() throws NoSuchMethodException { if (lteDbmMethod == null) { //getwcdmarscp lteDbmMethod = SignalStrength.class.getMethod("getLteDbm", new Class[0]); } return lteDbmMethod; }
Example #23
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 #24
Source File: LegacyMeasurementProcessingEvent.java From TowerCollector with Mozilla Public License 2.0 | 4 votes |
public SignalStrength getLastSignalStrength() { return lastSignalStrength; }
Example #25
Source File: SignalStrengths.java From SignalStrengths with Apache License 2.0 | 4 votes |
@Override public double getLevel(SignalStrength signalStrength) throws Exception { Method method = signalStrength.getClass().getDeclaredMethod("getTdScdmaDbm"); method.setAccessible(true); return SignalUtils.getDbmLevel((int) method.invoke(signalStrength)); }
Example #26
Source File: SignalStrengths.java From SignalStrengths with Apache License 2.0 | 4 votes |
@Override public double getLevel(SignalStrength signalStrength) { return SignalUtils.getDbmLevel(signalStrength.getCdmaDbm()); }
Example #27
Source File: SignalStrengths.java From SignalStrengths with Apache License 2.0 | 4 votes |
@Override public double getLevel(SignalStrength signalStrength) throws Exception { Method method = signalStrength.getClass().getDeclaredMethod("getAsuLevel"); method.setAccessible(true); return SignalUtils.getAsuLevel((int) method.invoke(signalStrength)); }
Example #28
Source File: SignalStrengths.java From SignalStrengths with Apache License 2.0 | 4 votes |
@Override public double getLevel(SignalStrength signalStrength) throws Exception { Method method = signalStrength.getClass().getDeclaredMethod("getTdScdmaLevel"); method.setAccessible(true); return (int) method.invoke(signalStrength); }
Example #29
Source File: SignalStrengths.java From SignalStrengths with Apache License 2.0 | 4 votes |
@Override public double getLevel(SignalStrength signalStrength) { return SignalUtils.getSnrLevel(signalStrength.getEvdoSnr()); }
Example #30
Source File: SignalStrengths.java From SignalStrengths with Apache License 2.0 | 4 votes |
@Override public double getLevel(SignalStrength signalStrength) throws Exception { Method method = signalStrength.getClass().getDeclaredMethod("getEvdoLevel"); method.setAccessible(true); return (int) method.invoke(signalStrength); }