Java 类android.telephony.SignalStrength 实例源码

项目:TheLearningLock    文件:StatusBar.java   
private void setupSignalStrength() {
    final TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    final ImageView signalIcon = ((ImageView) statusBar.findViewById(R.id.signal_icon));
    phoneListener = new PhoneStateListener() {
        @Override
        public void onSignalStrengthsChanged(SignalStrength signalStrength) {
            if (manager.getNetworkOperator().equals("")) {
                signalIcon.setVisibility(View.GONE);
            } else {
                signalIcon.setVisibility(View.VISIBLE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    // See https://github.com/AlstonLin/TheLearningLock/issues/54
                    Integer imageRes = signalStrengthToIcon.get(signalStrength.getLevel());
                    if (imageRes != null) signalIcon.setImageResource(imageRes);
                    else signalIcon.setImageResource(signalStrengthToIcon.get(4));
                } else {
                    // Just show the full icon
                    signalIcon.setImageResource(signalStrengthToIcon.get(4));
                }
            }
        }
    };
    manager.listen(phoneListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
项目:AIMSICDL    文件:CellTracker.java   
/**
 *  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());
}
项目:react-native-telephony    文件:TelephonyModule.java   
@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);
}
项目:microbit    文件:SignalStrengthPresenter.java   
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);
    }
}
项目:microbit    文件:SignalStrengthPresenter.java   
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;
}
项目:Android-IMSI-Catcher-Detector    文件:CellTracker.java   
/**
 *  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
 */
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();
        }
        device.setSignalDbm(dbm);
    } else {
        int evdoDbm = signalStrength.getEvdoDbm();
        int cdmaDbm = signalStrength.getCdmaDbm();

        // Use lowest signal to be conservative
        device.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
    }
    // Send it to signal tracker
    signalStrengthTracker.registerSignalStrength(device.cell.getCellId(), device.getSignalDBm());
    //signalStrengthTracker.isMysterious(device.cell.getCid(), device.getSignalDBm());
}
项目:SignalStrengths    文件:SignalStrengths.java   
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;
}
项目:PracticeDemo    文件:DeviceInfoActivty.java   
/**
         * 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());



        }
项目:swan-sense-studio    文件:SignalStrengthSensor.java   
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    long now = System.currentTimeMillis();
    if (signalStrength.isGsm()) {
        Log.d(TAG,
                "GSM Signal Strength: "
                        + signalStrength.getGsmSignalStrength() + ", "
                        + signalStrength.getGsmBitErrorRate());
    } else {
        Log.d(TAG,
                "CDMA Signal Strength: " + signalStrength.getCdmaDbm()
                        + ", " + signalStrength.getCdmaEcio());
    }

    putValueTrimSize(IS_GSM_FIELD, null, now, signalStrength.isGsm());
    putValueTrimSize(GSM_SIGNAL_STRENGTH_FIELD, null, now, signalStrength.getGsmSignalStrength());
    putValueTrimSize(GSM_BIT_ERROR_RATE_FIELD, null, now, signalStrength.getGsmBitErrorRate());
    putValueTrimSize(CDMA_DBM_FIELD, null, now, signalStrength.getCdmaDbm());
    putValueTrimSize(CDMA_ECIO_FIELD, null, now, signalStrength.getCdmaEcio());
    putValueTrimSize(EVDO_DBM_FIELD, null, now, signalStrength.getEvdoDbm());
    putValueTrimSize(EVDO_ECIO_FIELD, null, now, signalStrength.getEvdoEcio());
    putValueTrimSize(EVDO_SNR_FIELD, null, now, signalStrength.getEvdoSnr());
}
项目:swan_sense_integration    文件:SignalStrengthSensor.java   
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    long now = System.currentTimeMillis();
    if (signalStrength.isGsm()) {
        Log.d(TAG,
                "GSM Signal Strength: "
                        + signalStrength.getGsmSignalStrength() + ", "
                        + signalStrength.getGsmBitErrorRate());
    } else {
        Log.d(TAG,
                "CDMA Signal Strength: " + signalStrength.getCdmaDbm()
                        + ", " + signalStrength.getCdmaEcio());
    }

    putValueTrimSize(IS_GSM_FIELD, null, now, signalStrength.isGsm());
    putValueTrimSize(GSM_SIGNAL_STRENGTH_FIELD, null, now, signalStrength.getGsmSignalStrength());
    putValueTrimSize(GSM_BIT_ERROR_RATE_FIELD, null, now, signalStrength.getGsmBitErrorRate());
    putValueTrimSize(CDMA_DBM_FIELD, null, now, signalStrength.getCdmaDbm());
    putValueTrimSize(CDMA_ECIO_FIELD, null, now, signalStrength.getCdmaEcio());
    putValueTrimSize(EVDO_DBM_FIELD, null, now, signalStrength.getEvdoDbm());
    putValueTrimSize(EVDO_ECIO_FIELD, null, now, signalStrength.getEvdoEcio());
    putValueTrimSize(EVDO_SNR_FIELD, null, now, signalStrength.getEvdoSnr());
}
项目:Testes    文件:FirstActivity.java   
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    super.onSignalStrengthsChanged(signalStrength);
    Log.i(TAG, "onSignalStrengthsChanged" + signalStrength);
    //          if(Build.VERSION.SDK_INT>=18){
    //              if(signalStrength instanceof SignalStrength){
    //                  Log.i("LOG_TAG", "onSignalStrengthsChanged: getcdaRscp" + signalStrength.getDbm());
    //                  int ttt = signalStrength.getDbm();
    //                  text1.setText(String.valueOf(ttt));
    //              }
    //              else{
    Log.i(TAG, "onSignalStrengthsChanged: getcda dbm: " + signalStrength.getCdmaDbm());
    int ttt = signalStrength.getCdmaDbm();
    text1.setText(String.valueOf(ttt));
    //              }
    //              }
}
项目:skandroid-core    文件:CellTowersDataCollector.java   
synchronized static void sOnSignalStrengthsChanged(SignalStrength signalStrength) {
    mData.setTime(System.currentTimeMillis());
    mData.setSignal(signalStrength);

    if (OtherUtils.isThisDeviceAnEmulator() == true) {
            // The signal will usuaully be null on the Emulator...
    } else {
        // On a real device... there should generally be a signal...
        SKPorting.sAssert(CellTowersDataCollector.class, mData.getSignal() != null);
    }

    try {
        mData.setCellLocation(mTelManager.getCellLocation());
    } catch (SecurityException e) {
        // Seen - rarely - on some Android devices.
        // Neither user 99999 nor current process has android.permission.ACCESS_COARSE_LOCATION.
        SKPorting.sAssert(CellTowersDataCollector.class, false);
    }
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * 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();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * 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();
}
项目:localcloud_fe    文件:JSONHelper.java   
/**
 * 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();
}
项目:microbit    文件:SignalStrengthPresenter.java   
private boolean isCdma(SignalStrength signalStrength) {
    return (signalStrength != null) && !signalStrength.isGsm();
}
项目:boohee_v5.6    文件:t.java   
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    if (this.a.dX == null) {
        return;
    }
    if (this.a.dX.new == 'g') {
        this.a.dX.int = signalStrength.getGsmSignalStrength();
    } else if (this.a.dX.new == 'c') {
        this.a.dX.int = signalStrength.getCdmaDbm();
    }
}
项目:cordova-plugin-advanced-geolocation    文件:JSONHelper.java   
/**
 * 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();
}
项目:Status    文件:DualNetworkIconData.java   
@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;
            }
        }

        onDrawableUpdate(level);
    }
}
项目:Status    文件:NetworkIconData.java   
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    super.onSignalStrengthsChanged(signalStrength);

    NetworkIconData icon = null;
    if (reference != null) icon = reference.get();

    if (icon != null && icon.isRegistered)
        icon.onDrawableUpdate((int) Math.round(SignalStrengths.getFirstValid(signalStrength)));
}
项目:truth-android    文件:SignalStrengthSubject.java   
public static SubjectFactory<SignalStrengthSubject, SignalStrength> type() {
  return new SubjectFactory<SignalStrengthSubject, SignalStrength>() {
    @Override
    public SignalStrengthSubject getSubject(FailureStrategy fs, SignalStrength that) {
      return new SignalStrengthSubject(fs, that);
    }
  };
}
项目:TowerCollector    文件:LegacyMeasurementProcessingEvent.java   
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;
}
项目:SignalStrengths    文件:SignalStrengths.java   
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;
}
项目:dash-api    文件:SignalListener.java   
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    super.onSignalStrengthsChanged(signalStrength);

    int percent = 0;
    if(signalStrength != null && signalStrength.getGsmSignalStrength() != UNKNOWN_CODE) {
        percent = calculateSignalStrengthInPercent(signalStrength.getGsmSignalStrength());
    } else {
        Log.e(TAG, "Unable to get phone signal strength!");
    }

    onPercentKnown(percent);
}
项目:CellularSignal    文件:RadioInfo.java   
@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();
}
项目:mobility-logger    文件:MainActivity.java   
private void updateSignalStrengths(SignalStrength signalStrength){
    /** Current cell */
    TextView cellSignalStrength_Asu_dBm = (TextView)findViewById(R.id.cellsignalstrength_Asu_dBm);
    TextView cellBitErrorRate = (TextView)findViewById(R.id.cellbiterrorrate);
    if (signalStrength!=null){
        int asu = signalStrength.getGsmSignalStrength();
        cellSignalStrength_Asu_dBm.setText(String.valueOf(asu)+"/"+String.valueOf(-113+(2*asu)));
        cellBitErrorRate.setText(String.valueOf(signalStrength.getGsmBitErrorRate()));
    } else {
        cellSignalStrength_Asu_dBm.setText("NA/NA");
        cellBitErrorRate.setText("NA");
    }
}
项目:batteryhub    文件:SignalListener.java   
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    // TODO Auto-generated method stub
    super.onSignalStrengthsChanged(signalStrength);
    gsmSignal = signalStrength.getGsmSignalStrength();
    cdmaDbm  = signalStrength.getCdmaDbm();
    evdoDbm = signalStrength.getEvdoDbm();
}
项目:iTester    文件:MobileNetActivity.java   
private void initUI()
{
    tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);  
    tv_mobile = (TextView)findViewById(R.id.textView_mobile);
    tv_mobile.setTextColor(Color.RED);
    tv_mobile.setTextSize(30);
    findViewById(R.id.button_pass).setOnClickListener(this);
    findViewById(R.id.button_fail).setOnClickListener(this);
    findViewById(R.id.button_pass).setEnabled(false);

       updateViews(tm);  
        //����SIM��״̬��������Ϣ��ʱ�����ܷ����仯�������Ҫע��PhoneStateListener   
        //��ʵʱ���½�����ʾ����Ϣ��������������¼���LISTEN_SERVICE_STATE��LISTEN_DATA_CONNECTION_STATE   
        //���Ƿֱ��Ӧ�ص�����onServiceStateChanged��onDataConnectionStateChanged   
        tm.listen(new PhoneStateListener() {  

            @Override  
            public void onDataConnectionStateChanged(int state, int networkType) {  
                //��������״̬�ı���ܵ����������͵ĸı�   
                updateViews(tm);  
            }  

            @Override  
            public void onServiceStateChanged(ServiceState serviceState) {  
                updateViews(tm);  
            }

            @Override
            public void onSignalStrengthsChanged(SignalStrength signalStrength) {
                // TODO Auto-generated method stub
                Stren=String.valueOf(-113+2*signalStrength.getGsmSignalStrength())+" dBm  "+String.valueOf(signalStrength.getGsmSignalStrength())+" asu";
                updateViews(tm);
                super.onSignalStrengthsChanged(signalStrength);
            } 


        }, PhoneStateListener.LISTEN_SERVICE_STATE   
                | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE|PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); 
 }
项目:android_external_UnifiedNlpApi    文件:CellBackendHelper.java   
/**
 * Call this in {@link org.microg.nlp.api.LocationBackendService#onOpen()}.
 */
@Override
public synchronized void onOpen() {
    super.onOpen();

    if (phoneStateListener == null) {
        Handler mainHandler = new Handler(context.getMainLooper());
        mainHandler.post(new Runnable() {
            @Override
            public void run() {
                phoneStateListener = new PhoneStateListener() {

                    @Override
                    public void onCellInfoChanged(List<CellInfo> cellInfo) {
                        if (cellInfo != null && !cellInfo.isEmpty()) {
                            onCellsChanged(cellInfo);
                        } else if (supportsCellInfoChanged) {
                            supportsCellInfoChanged = false;
                            onSignalStrengthsChanged(null);
                        }
                    }

                    @Override
                    public void onSignalStrengthsChanged(SignalStrength signalStrength) {
                        if (!supportsCellInfoChanged) {
                            fallbackScan();
                        }
                    }
                };
                registerPhoneStateListener();
            }
        });
    } else {
        registerPhoneStateListener();
    }
}
项目:product-emm    文件:DeviceNetworkStatus.java   
@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());
    }
}
项目:foheart    文件:BreadCrumbs.java   
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength)
{
    super.onSignalStrengthsChanged(signalStrength);
    BreadCrumbs.signal = String.valueOf(signalStrength.getGsmSignalStrength());
    if (BreadCrumbs.signal.trim()=="") BreadCrumbs.signal = "-1";
}
项目:SignalAnalysis    文件:PhoneStateHelper.java   
/**
 * Callback invoked when signal strength changed
 */
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    super.onSignalStrengthsChanged(signalStrength);

    String temp = signalStrength.toString();
    String[] parts = temp.split(" ");

    mGsm_SignalStrength = String
            .valueOf((Integer.parseInt(parts[1]) * 2 - 113));
    mGsm_bitErrorRate = parts[2];
    mCdma_Dbm = parts[3];
    mCdma_Ecio = parts[4];
    mEvdo_Dbm = parts[5];
    mEvdo_Ecio = parts[6];
    mEvdo_Snr = parts[7];
    mLTE_RSSI = String.valueOf(Integer.parseInt(parts[8]) * 2 - 113);
    mLTE_RSRP = parts[9];
    mLTE_RSRQ = parts[10];
    mLTE_RSSNR = parts[11];
    mLTE_CQI = parts[12];

    if (parts[14].equals("gsm|lte"))
        isGsm = true;

    // Set the network info
    setNetworkInfo();

    Log.d(Config.TAG, TAG + "signal: " + signalStrength.toString());

    // Update the UI
    MainActivity.updateView();
}
项目:myStress    文件:CellHandler.java   
/**
 * Called when the signal strength has changed
 * 
 * @param signalStrength
 *            strength of the newly detected signal. First, we get the ASU
 *            by calling getGsmSignalStrength(), then we calculate the dBm
 *            through dBm = -113 + 2* ASU
 * @see android.telephony.PhoneStateListener#onSignalStrengthsChanged(android.telephony.SignalStrength)
 */
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    int strength, signal;

    // signal strength in ASU
    strength = signalStrength.getGsmSignalStrength();

    // convert ASU in dBm
    signal = -113 + 2 * strength;

    // has anything changed?
    if (signal != oldcellStrength) {
        // convert ASU into bars
        if (strength <= 2 || strength == 99)
            oldcellStrength_bar = 0;
        else if (strength >= 12)
            oldcellStrength_bar = 4;
        else if (strength >= 8)
            oldcellStrength_bar = 3;
        else if (strength >= 5)
            oldcellStrength_bar = 2;
        else
            oldcellStrength_bar = 1;

        oldcellStrength = signal;

        // stuff can be read now
        signal_read = true;
        bar_read = true;

        // release semaphores
        signal_semaphore.release();
        bar_semaphore.release();
    }
}
项目:VoLTE_Dialer    文件:CallMonitorReceiver.java   
@Override
   public void onSignalStrengthsChanged(SignalStrength strength) {
    super.onSignalStrengthsChanged(strength);
    if(strength.isGsm()) {
        mCmIf.csmif_SignalStrength(strength.getGsmSignalStrength());
    }
}
项目:nextgislogger    文件:CellEngine.java   
private int getSignalStrengthLTE(SignalStrength signalStrength)
{
    try {
        Method[] methods = android.telephony.SignalStrength.class.getMethods();

        for (Method mthd : methods)
            if (mthd.getName().equals(LTE_SIGNAL_STRENGTH))
                return (Integer) mthd.invoke(signalStrength);
    } catch (Exception ignored) { }

    return 0;
}
项目:nextgislogger    文件:CellEngine.java   
@Override
     public void onSignalStrengthsChanged(SignalStrength signal) {
         super.onSignalStrengthsChanged(signal);

int signalStrength = signal.getGsmSignalStrength();
if (mTelephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE && 0 <= signalStrength && signalStrength <= 97)
    signalStrength = getSignalStrengthLTE(signal);

         setSignalStrength(signalStrengthAsuToDbm(signalStrength, mTelephonyManager.getNetworkType()));
         updateItems();
         notifyListeners();
     }
项目:Rejsekort-Reminder    文件:CellSensor.java   
protected int getSignalStrength(SignalStrength signal) {

        String ssignal = signal.toString();
        String[] parts = ssignal.split(" ");

        int dB = -120; // No Signal Measured when returning -120 dB

        // If LTE 
        if (telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_LTE){

            int ltesignal = Integer.parseInt(parts[9]);

            // check to see if it get's the right signal in dB, a signal below -2
            if(ltesignal < -2) {
                dB = ltesignal;
            }
        }
        // Else 3G
        else {

            if (signal.getGsmSignalStrength() != 99) {

                int strengthInteger = -113 + 2 * signal.getGsmSignalStrength();
                dB = strengthInteger;   
            }
        }

        return dB;
    }
项目:Mobilog    文件:MainActivity.java   
private void updateSignalStrengths(SignalStrength signalStrength){
    /** Current cell */
    TextView cellSignalStrength_Asu_dBm = (TextView)findViewById(R.id.cellsignalstrength_Asu_dBm);
    TextView cellBitErrorRate = (TextView)findViewById(R.id.cellbiterrorrate);
    if (signalStrength!=null){
        int asu = signalStrength.getGsmSignalStrength();
        cellSignalStrength_Asu_dBm.setText(String.valueOf(asu)+"/"+String.valueOf(-113+(2*asu)));
        cellBitErrorRate.setText(String.valueOf(signalStrength.getGsmBitErrorRate()));
    } else {
        cellSignalStrength_Asu_dBm.setText("NA/NA");
        cellBitErrorRate.setText("NA");
    }
}
项目:Auie    文件:UENavigationActivity.java   
@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);
    }
}
项目:Auie    文件:UENavigationFragmentActivity.java   
@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);
    }
}