Example usage for android.telephony SignalStrength getGsmBitErrorRate

List of usage examples for android.telephony SignalStrength getGsmBitErrorRate

Introduction

In this page you can find the example usage for android.telephony SignalStrength getGsmBitErrorRate.

Prototype

@Deprecated
public int getGsmBitErrorRate() 

Source Link

Document

Get the GSM bit error rate (0-7, 99) as defined in TS 27.007 8.5

Usage

From source file:com.esri.cordova.geolocation.utils.JSONHelper.java

/**
 * Originates from a change in signal strength
 * @param signalStrength SignalStrength/*from w ww . java 2s  .  c om*/
 * @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();
}

From source file:com.karpenstein.signalmon.NetServerService.java

@Override
public void onCreate() {
    super.onCreate();
    try {//from   w  w  w  .j a  v a  2s.c o m
        jsonState = new JSONObject();
        jsonState.put("dataActivity", TelephonyManager.DATA_ACTIVITY_NONE);
    } catch (JSONException ex) {
        Log.d("NetServerService", "Failed to put data activity in the JSONObject");
    }

    // Get the telephony manager
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager == null)
        Log.d("NetServerService", "TelephonyManager was null.");
    Log.d("NetServerService", "about to create PhoneStateListener");
    // Create a new PhoneStateListener
    psListener = new PhoneStateListener() {
        @Override
        public void onDataActivity(int direction) {
            Log.d("NetServerService", "received onDataActivity message");
            try {
                jsonState.put("dataActivity", direction);
            } catch (JSONException ex) {
            }
            notifyListeners();
        }

        @Override
        public void onSignalStrengthsChanged(SignalStrength signalStrength) {
            Log.d("NetServerService", "received onSignalStrength message");
            try {
                jsonState.put("cdmaDbm", signalStrength.getCdmaDbm());
                jsonState.put("cdmaEcio", signalStrength.getCdmaEcio());
                jsonState.put("evdoDbm", signalStrength.getEvdoDbm());
                jsonState.put("evdoEcio", signalStrength.getEvdoEcio());
                jsonState.put("evdoSnr", signalStrength.getEvdoSnr());
                jsonState.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
                jsonState.put("gsmSignalStrength", signalStrength.getGsmSignalStrength());
                jsonState.put("isGsm", signalStrength.isGsm());
            } catch (JSONException ex) {
            }
            notifyListeners();
        }

        @Override
        public void onDataConnectionStateChanged(int state, int networkType) {
            Log.d("NetServerService", "received onDataConnectionStateChanged message");
            try {
                jsonState.put("connState", state);
                jsonState.put("netType", networkType);
            } catch (JSONException ex) {
            }
            notifyListeners();
        }
    };

    Log.d("NetServerService", "about to call telephonyManager.listen");
    // Register the listener with the telephony manager
    telephonyManager.listen(psListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
            | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_DATA_ACTIVITY);
    Log.d("NetServerService", "done calling telephonyManager.listen -- exiting onCreate");
}

From source file:com.google.android.apps.mytracks.services.TrackRecordingService.java

@Override
public void onSignalStrengthSampled(SignalStrength signal) {
    if (signal.isGsm()) {
        signalStrength = signal;/*from ww  w  .j a va 2s  .co  m*/
        gsmBitErrorRate = signal.getGsmBitErrorRate();
        if (signal.getGsmSignalStrength() < 2 || signal.getGsmSignalStrength() > 30) {
            switch (signal.getGsmSignalStrength()) {
            case 0:
                gsmSignal = -113;
            case 1:
                gsmSignal = -111;
            case 31:
                gsmSignal = -51; // or better 100%
            case 99:
                gsmSignal = Constants.UNKNOWN_SIGNAL;
            }
        } else {
            gsmSignal = -109 + (signal.getGsmSignalStrength() - 2) * 2;
        }
    }
}

From source file:uk.ac.horizon.ubihelper.service.channel.CellStrengthChannel.java

protected void update(CellLocation loc, SignalStrength ss) {
    if (loc == null && telephony != null)
        loc = telephony.getCellLocation();
    // TODO Auto-generated method stub
    JSONObject value = new JSONObject();
    try {//from w ww. j  a v  a2 s . c  o m
        value.put("timestamp", System.currentTimeMillis());
        if (loc instanceof GsmCellLocation) {
            GsmCellLocation gsm = (GsmCellLocation) loc;
            if (gsm.getCid() != (-1))
                value.put("cid", gsm.getCid());
            if (gsm.getLac() != (-1))
                value.put("lac", gsm.getLac());
            value.put("type", "gsm");
        } else if (loc instanceof CdmaCellLocation) {
            CdmaCellLocation cdma = (CdmaCellLocation) loc;
            if (cdma.getBaseStationId() != (-1))
                value.put("baseStationId", cdma.getBaseStationId());
            if (cdma.getBaseStationLatitude() != Integer.MAX_VALUE)
                value.put("baseStationLat", cdma.getBaseStationLatitude());
            if (cdma.getBaseStationLongitude() != Integer.MAX_VALUE)
                value.put("baseStationLon", cdma.getBaseStationLongitude());
            if (cdma.getNetworkId() != (-1))
                value.put("baseStationId", cdma.getNetworkId());
            if (cdma.getNetworkId() != (-1))
                value.put("networkId", cdma.getNetworkId());
            if (cdma.getSystemId() != (-1))
                value.put("systemId", cdma.getSystemId());
            value.put("type", "cdma");
        } else if (loc != null) {
            value.put("type", loc.getClass().getName());
        }

        if (ss != null) {
            if (ss.getCdmaDbm() != (-1))
                value.put("cdmsDbm", ss.getCdmaDbm());
            if (ss.getCdmaEcio() != (-1))
                value.put("cdmaEcio", ss.getCdmaEcio());
            if (ss.getEvdoDbm() != (-1))
                value.put("evdoDbm", ss.getEvdoDbm());
            if (ss.getEvdoEcio() != (-1))
                value.put("evdiEcio", ss.getEvdoEcio());
            if (ss.getEvdoSnr() != (-1))
                value.put("evdoSnr", ss.getEvdoSnr());
            if (ss.getGsmBitErrorRate() != (-1))
                value.put("gsmBER", ss.getGsmBitErrorRate());
            if (ss.getGsmSignalStrength() != (-1))
                value.put("gsmSS", ss.getGsmSignalStrength());
            value.put("gsm", ss.isGsm());
        }
    } catch (JSONException e) {
        // shouldn't
    }
    onNewValue(value);
}