Example usage for android.telephony TelephonyManager PHONE_TYPE_CDMA

List of usage examples for android.telephony TelephonyManager PHONE_TYPE_CDMA

Introduction

In this page you can find the example usage for android.telephony TelephonyManager PHONE_TYPE_CDMA.

Prototype

int PHONE_TYPE_CDMA

To view the source code for android.telephony TelephonyManager PHONE_TYPE_CDMA.

Click Source Link

Document

Phone radio is CDMA.

Usage

From source file:pk.development.sms.detection.CellSniffer.java

@Override
public void onCellLocationChanged(CellLocation location) {

    switch (teleManager.getPhoneType()) {
    case TelephonyManager.PHONE_TYPE_GSM:
        GsmCellLocation gsmCellData = (GsmCellLocation) teleManager.getCellLocation();
        if (gsmCellData != null) {
            btsData.setLac(gsmCellData.getLac());
            btsData.setCid(gsmCellData.getCid());
            btsData.setRoaming(teleManager.isNetworkRoaming());
            btsData.setBtsType(BtsType.GSM);

            String networkProvider = teleManager.getNetworkOperator();
            if (!TextUtils.isEmpty(networkProvider)) {
                btsData.setMcc(Integer.parseInt(networkProvider.substring(0, 3)));
                btsData.setMnc(Integer.parseInt(networkProvider.substring(3)));
            }//w  w  w.j a v a 2  s . c  o  m
        }
        break;
    case TelephonyManager.PHONE_TYPE_CDMA:
        CdmaCellLocation cdmaCellData = (CdmaCellLocation) teleManager.getCellLocation();
        if (cdmaCellData != null) {
            btsData.setLac(cdmaCellData.getNetworkId());
            btsData.setCid(cdmaCellData.getBaseStationId());
            btsData.setBtsType(BtsType.CDMA);
        }
        break;
    }
}

From source file:org.mozilla.mozstumbler.service.datahandling.StumblerBundle.java

public JSONObject toMLSJSON() throws JSONException {
    JSONObject item = new JSONObject();

    item.put(DatabaseContract.Reports.TIME, mGpsPosition.getTime());
    item.put(DatabaseContract.Reports.LAT, Math.floor(mGpsPosition.getLatitude() * 1.0E6) / 1.0E6);
    item.put(DatabaseContract.Reports.LON, Math.floor(mGpsPosition.getLongitude() * 1.0E6) / 1.0E6);

    if (mGpsPosition.hasAccuracy()) {
        item.put(DatabaseContract.Reports.ACCURACY, (int) Math.ceil(mGpsPosition.getAccuracy()));
    }//from   www  .ja  v a  2  s  .c  om

    if (mGpsPosition.hasAltitude()) {
        item.put(DatabaseContract.Reports.ALTITUDE, Math.round(mGpsPosition.getAltitude()));
    }

    if (mPhoneType == TelephonyManager.PHONE_TYPE_GSM) {
        item.put(DatabaseContract.Reports.RADIO, "gsm");
    } else if (mPhoneType == TelephonyManager.PHONE_TYPE_CDMA) {
        item.put(DatabaseContract.Reports.RADIO, "cdma");
    } else {
        // issue #598. investigate this case further in future
        item.put(DatabaseContract.Reports.RADIO, "");
    }

    JSONArray cellJSON = new JSONArray();
    for (CellInfo c : mCellData.values()) {
        JSONObject obj = c.toJSONObject();
        cellJSON.put(obj);
    }
    item.put(DatabaseContract.Reports.CELL, cellJSON);
    item.put(DatabaseContract.Reports.CELL_COUNT, cellJSON.length());

    JSONArray wifis = new JSONArray();
    item.put(DatabaseContract.Reports.WIFI, wifis);
    for (ScanResult s : mWifiData.values()) {
        JSONObject wifiEntry = new JSONObject();
        wifiEntry.put("key", s.BSSID);
        wifiEntry.put("frequency", s.frequency);
        wifiEntry.put("signal", s.level);
        wifis.put(wifiEntry);
    }

    return item;
}

From source file:org.restcomm.app.qoslib.UtilsOld.CellHistory.java

public long getLastCellSeen(CellLocation cellLoc) // MMCCellLocationOld cellInfo)
{
    if (cellLoc == null)
        return -1;
    if (tmLastCellUpdate + 60000 > System.currentTimeMillis() && cellLoc.toString().equals(lastCellString))
        return -1;
    long timelastSeen = 0;
    tmLastCellUpdate = System.currentTimeMillis();

    // Is it reporting an unknown cell id? ignore those
    //        int cellId = 0;//cellInfo.getBSLow(); //low
    //        if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM && cellLoc instanceof GsmCellLocation)
    //         cellId = ((GsmCellLocation)cellLoc).getCid();
    //      else if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA && cellLoc instanceof CdmaCellLocation)
    //         cellId = ((CdmaCellLocation)cellLoc).getBaseStationId();
    //      if (cellId <= 0)
    //         return -1;

    CellidSample smp = new CellidSample(cellLoc);
    cell_history.add(smp);/*  w  w  w.  j av  a2 s  .  c o m*/

    // How long has it been since we last saw this basestation
    //int bs_high = cellInfo.getBSHigh(), bs_mid = cellInfo.getBSMid(), bs_low = cellInfo.getBSLow();
    int bs_high = 0, bs_mid = 0, bs_low = 0;
    if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM
            && cellLoc instanceof GsmCellLocation) {
        GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLoc;
        bs_high = gsmCellLocation.getLac();
        bs_mid = gsmCellLocation.getCid() >> 16;
        bs_low = gsmCellLocation.getCid() & 0xffff;
    } else if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA
            && cellLoc instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLoc;
        bs_high = cdmaCellLocation.getSystemId();
        bs_mid = cdmaCellLocation.getNetworkId();
        bs_low = cdmaCellLocation.getBaseStationId();
    }
    if (bs_low <= 0)
        return -1;
    int j;
    int histlen = cell_history.size();
    // How long has it been since we last saw this basestation
    long timestamp = System.currentTimeMillis();
    for (j = histlen - 2; j >= 0; j--) {
        if (cell_history.get(j).val2 == bs_low) //  && cell_history.get(j).val1 == bs_high)
        {
            // time last seen is the first timestamp after the cell was last seen
            // (the time this cell handed off to another cell)
            // (if the last known cell was this same cell, then the time last seen is now)
            timelastSeen = timestamp;
            break;
        } else
            timestamp = cell_history.get(j).timestamp;

    }

    return timelastSeen;
}

From source file:com.fallahpoor.infocenter.fragments.SimFragment.java

private String getPhoneType(TelephonyManager telephonyManager) {

    int phoneTypeInt = telephonyManager.getPhoneType();
    String phoneTypeStr;//from   w ww .j  a  va2s. c  o m

    switch (phoneTypeInt) {
    case TelephonyManager.PHONE_TYPE_CDMA:
        phoneTypeStr = getString(R.string.sim_sub_item_cdma);
        break;
    case TelephonyManager.PHONE_TYPE_GSM:
        phoneTypeStr = getString(R.string.sim_sub_item_gsm);
        break;
    case TelephonyManager.PHONE_TYPE_SIP:
        phoneTypeStr = getString(R.string.sim_sub_item_sip);
        break;
    default:
        phoneTypeStr = getString(R.string.unknown);
    }

    return phoneTypeStr;

}

From source file:com.secupwn.aimsicd.ui.fragments.DeviceFragment.java

private void updateUI() {
    HighlightTextView content;//from  w ww  . j  a v a 2 s .  co m
    TableRow tr;
    if (mBound) {
        final AnimationManager ani = new AnimationManager();

        mAimsicdService.getCellTracker().refreshDevice();
        Device mDevice = mAimsicdService.getCellTracker().getDevice();
        switch (mDevice.getPhoneId()) {

        case TelephonyManager.PHONE_TYPE_NONE: // Maybe bad!
        case TelephonyManager.PHONE_TYPE_SIP: // Maybe bad!
        case TelephonyManager.PHONE_TYPE_GSM: {
            content = (HighlightTextView) getView().findViewById(R.id.network_lac);
            content.updateText(String.valueOf(mAimsicdService.getCell().getLocationAreaCode()), ani);
            tr = (TableRow) getView().findViewById(R.id.gsm_cellid);
            tr.setVisibility(View.VISIBLE);
            content = (HighlightTextView) getView().findViewById(R.id.network_cellid);
            content.updateText(String.valueOf(mAimsicdService.getCell().getCellId()), ani);
            break;
        }

        case TelephonyManager.PHONE_TYPE_CDMA: {
            tr = (TableRow) getView().findViewById(R.id.cdma_netid);
            tr.setVisibility(View.VISIBLE);
            content = (HighlightTextView) getView().findViewById(R.id.network_netid);
            content.updateText(String.valueOf(mAimsicdService.getCell().getLocationAreaCode()), ani);
            tr = (TableRow) getView().findViewById(R.id.cdma_sysid);
            tr.setVisibility(View.VISIBLE);
            content = (HighlightTextView) getView().findViewById(R.id.network_sysid);
            content.updateText(String.valueOf(mAimsicdService.getCell().getSid()), ani);
            tr = (TableRow) getView().findViewById(R.id.cdma_baseid);
            tr.setVisibility(View.VISIBLE);
            content = (HighlightTextView) getView().findViewById(R.id.network_baseid);
            content.updateText(String.valueOf(mAimsicdService.getCell().getCellId()), ani);
            break;
        }
        }

        if (mAimsicdService.getCell().getTimingAdvance() != Integer.MAX_VALUE) {
            tr = (TableRow) getView().findViewById(R.id.lte_timing_advance);
            tr.setVisibility(View.VISIBLE);
            content = (HighlightTextView) getView().findViewById(R.id.network_lte_timing_advance);
            content.updateText(String.valueOf(mAimsicdService.getCell().getTimingAdvance()), ani);
        } else {
            tr = (TableRow) getView().findViewById(R.id.lte_timing_advance);
            tr.setVisibility(View.GONE);
        }

        if (mAimsicdService.getCell().getPrimaryScramblingCode() != Integer.MAX_VALUE) {
            content = (HighlightTextView) getView().findViewById(R.id.network_psc);
            content.updateText(String.valueOf(mAimsicdService.getCell().getPrimaryScramblingCode()), ani);
            tr = (TableRow) getView().findViewById(R.id.primary_scrambling_code);
            tr.setVisibility(View.VISIBLE);
        }

        String notAvailable = getString(R.string.n_a);

        content = (HighlightTextView) getView().findViewById(R.id.sim_country);
        content.updateText(mDevice.getSimCountry().orElse(notAvailable), ani);
        content = (HighlightTextView) getView().findViewById(R.id.sim_operator_id);
        content.updateText(mDevice.getSimOperator().orElse(notAvailable), ani);
        content = (HighlightTextView) getView().findViewById(R.id.sim_operator_name);
        content.updateText(mDevice.getSimOperatorName().orElse(notAvailable), ani);
        content = (HighlightTextView) getView().findViewById(R.id.sim_imsi);
        content.updateText(mDevice.getSimSubs().orElse(notAvailable), ani);
        content = (HighlightTextView) getView().findViewById(R.id.sim_serial);
        content.updateText(mDevice.getSimSerial().orElse(notAvailable), ani);

        content = (HighlightTextView) getView().findViewById(R.id.device_type);
        content.updateText(mDevice.getPhoneType(), ani);
        content = (HighlightTextView) getView().findViewById(R.id.device_imei);
        content.updateText(mDevice.getIMEI(), ani);
        content = (HighlightTextView) getView().findViewById(R.id.device_version);
        content.updateText(mDevice.getIMEIv(), ani);
        content = (HighlightTextView) getView().findViewById(R.id.network_name);
        content.updateText(mDevice.getNetworkName(), ani);
        content = (HighlightTextView) getView().findViewById(R.id.network_code);
        content.updateText(mDevice.getMncMcc(), ani);
        content = (HighlightTextView) getView().findViewById(R.id.network_type);
        content.updateText(mDevice.getNetworkTypeName(), ani);

        content = (HighlightTextView) getView().findViewById(R.id.data_activity);
        content.updateText(mDevice.getDataActivityType(), ani);
        content = (HighlightTextView) getView().findViewById(R.id.data_status);
        content.updateText(mDevice.getDataState(), ani);
        content = (HighlightTextView) getView().findViewById(R.id.network_roaming);
        content.updateText(String.valueOf(mDevice.isRoaming()), ani);

        ani.startAnimation(5000);
    }
}

From source file:org.most.input.CellInput.java

@Override
public void workToDo() {
    CellLocation cellLocation = _telephonyManager.getCellLocation();
    _telephonyManager.listen(_phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
    nciList = _telephonyManager.getNeighboringCellInfo();
    DataBundle b = _bundlePool.borrowBundle();
    if (cellLocation instanceof GsmCellLocation) {
        GsmCellLocation gsmLocation = (GsmCellLocation) cellLocation;
        b.putInt(KEY_GSM_CELL_ID, gsmLocation.getCid());
        b.putInt(KEY_GSM_LAC, gsmLocation.getLac());
        b.putInt(KEY_RSSI, _phoneStateListener.signalStrengthValue);
        // gsmLocation.getPsc() require api 9
        // b.putInt(KEY_GSM_PSC, gsmLocation.getPsc());
        b.putInt(KEY_PHONE_TYPE, TelephonyManager.PHONE_TYPE_GSM);
    } else if (cellLocation instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaLocation = (CdmaCellLocation) cellLocation;
        b.putInt(KEY_BASE_STATION_ID, cdmaLocation.getBaseStationId());
        b.putInt(KEY_BASE_STATION_LATITUDE, cdmaLocation.getBaseStationLatitude());
        b.putInt(KEY_BASE_STATION_LONGITUDE, cdmaLocation.getBaseStationLongitude());
        b.putInt(KEY_BASE_NETWORK_ID, cdmaLocation.getNetworkId());
        b.putInt(KEY_BASE_SYSTEM_ID, cdmaLocation.getSystemId());
        b.putInt(KEY_PHONE_TYPE, TelephonyManager.PHONE_TYPE_CDMA);
    } else {//from   w  ww  .  j av  a2  s  .com
        b.putInt(KEY_PHONE_TYPE, TelephonyManager.PHONE_TYPE_NONE);
    }
    b.putLong(Input.KEY_TIMESTAMP, System.currentTimeMillis());
    b.putInt(Input.KEY_TYPE, Input.Type.CELL.toInt());
    post(b);
    postResults(b, nciList);
    scheduleNextStart();
}

From source file:org.restcomm.app.utillib.ContentProvider.ContentValuesGenerator.java

/**
 * This method generates a ContentValues object from the signal object so that it may
 * be stored in the database./*from  w  w w .j  a v  a  2  s  . c o  m*/
 * @param signal
 * @param phoneType This is the phone type and must be one of {@link TelephonyManager#PHONE_TYPE_CDMA}
 * or {@link TelephonyManager#PHONE_TYPE_GSM}.
 * @param stagedEventId This is the id of the event that this signal has to be related to
 * @return
 */
public static ContentValues generateFromSignal(SignalEx signal, int phoneType, int networkType,
        int serviceState, int dataState, long stagedEventId, int wifiSignal, JSONObject serviceMode) {
    ContentValues values = new ContentValues();
    Integer dBm = 0;
    Integer signalDB = null;
    try {
        if (serviceMode != null && serviceMode.getLong("time") + 5000 < System.currentTimeMillis())
            serviceMode = null;
        if (signal == null) // as a result of a service outage
        {
            LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, "ContentValues", "generateFromSignal",
                    "signal == null");
            values.put(Tables.SignalStrengths.SIGNAL, -256);
            //now do the common parameters
            values.put(Tables.SignalStrengths.TIMESTAMP, System.currentTimeMillis());
            values.put(Tables.SignalStrengths.EVENT_ID, stagedEventId);
            values.put(Tables.SignalStrengths.COVERAGE, 0);
            return values;
        }
        if (signal.getSignalStrength() == null) // as a result of a screen off (signal unknown)
            values.put(Tables.SignalStrengths.SIGNAL, (Integer) null);
        //do phone type specific actions first
        else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
            boolean isEvdo = true;

            if (networkType == TelephonyManager.NETWORK_TYPE_1xRTT
                    || networkType == TelephonyManager.NETWORK_TYPE_CDMA) {
                isEvdo = false;
                dBm = signal.getCdmaDbm();
            } else {
                dBm = signal.getEvdoDbm();
                int evdoDbm = signal.getEvdoDbm();
                // If there is no EVDO signal but there is CDMA signal, then use CDMA signal
                if (evdoDbm <= -120 || evdoDbm >= -1) {
                    int cdmaDbm = signal.getCdmaDbm();
                    if (cdmaDbm <= -120 || cdmaDbm >= -1)
                        dBm = evdoDbm; // no cdma signal either, so send the evdo signal afterall
                    else {
                        dBm = cdmaDbm;
                        isEvdo = false; // display and report the CDMA signal if CDMA has signal and EVDO does not
                    }
                }
            }

            //if (dBm == -1) // When Scott had a network outage on CDMA, he got -1, we want -256
            //   dBm = -256;
            if (dBm == -120 && networkType == TelephonyManager.NETWORK_TYPE_LTE)
                dBm = null; // signal not known, this seems to happen with LTE advanced
            values.put(Tables.SignalStrengths.SIGNAL, dBm
            //isEvdo ? signal.getSignalStrength().getEvdoDbm() : signal.getSignalStrength().getCdmaDbm()
            );
            values.put(Tables.SignalStrengths.ECI0,
                    isEvdo ? signal.getEvdoEcio() / 10.0 : signal.getCdmaEcio() / 10.0);
            values.put(Tables.SignalStrengths.SNR, isEvdo ? signal.getEvdoSnr() : null);
            //if (isEvdo)
            values.put(Tables.SignalStrengths.SIGNAL2G, signal.getCdmaDbm()
            //isEvdo ? signal.getSignalStrength().getCdmaDbm() : null
            );
            signalDB = dBm;
        } else if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {

            if (getPlatform() == 1) //On Android device
                signalDB = signal.getGsmSignalStrength();
            else if (getPlatform() == 3) {//On Blackberry device
                signalDB = PreferenceManager.getDefaultSharedPreferences(service.getApplicationContext())
                        .getInt(PreferenceKeys.Miscellaneous.BB_SIGNAL, 99);

            }
            if (signalDB == 99 || signalDB == -1 || signalDB == null) {
                signalDB = null;
                //            Integer signalLte = signal.getLayer3("mLteSignalStrength");
                //            if (signalLte != null && signalLte < 99)
                //            {
                //               if (signalLte == 0)
                //                  signalDB = -120;
                //               else
                //                  signalDB = -113 + signalLte*2;
                //            }

                // If signal is unknown but signal bars are known, send bars
                Integer signalBar = signal.getLayer3("mGsmSignalBar");
                if (signalBar != null && signalBar != -1) {
                    signalDB = getSignalDBFromBars(signalBar);
                    values.put(Tables.SignalStrengths.SIGNALBARS, signalBar);
                }

            } else if (getPlatform() == 1)
                signalDB = signal.getDbmValue(networkType, phoneType);

            Integer ecio = signal.getLayer3("mUmtsEcio");
            if (ecio == null)
                ecio = signal.getLayer3("mgw_ecio");
            if (ecio == null)
                ecio = signal.getLayer3("mGsmEcio");
            //         if (ecio == null)
            //         {
            //            ecio = signal.getLayer3("lastEcIoIndex");
            //            if (ecio != null)
            //               ecio = 2*signal.getLayer3Array("lastEcIoValues", ecio);
            //         }

            Integer ecno = signal.getLayer3("mUmtsEcno");
            if (ecno == null)
                ecno = signal.getLayer3("mGsmEcno");
            Integer rscp = signal.getLayer3("mUmtsRscp");
            if (rscp == null)
                rscp = signal.getLayer3("mGsmRscp");
            if (rscp == null)
                rscp = signal.getLayer3("mWcdmaRscp");
            if ((signalDB == null || signalDB <= -120) && rscp != null && rscp > -120 && rscp < -20)
                signalDB = rscp;

            values.put(Tables.SignalStrengths.ECI0, ecio);
            values.put(Tables.SignalStrengths.RSCP, rscp);
            values.put(Tables.SignalStrengths.ECN0, ecno);
            values.put(Tables.SignalStrengths.SIGNAL, signalDB);
            values.put(Tables.SignalStrengths.BER,
                    signal.getGsmBitErrorRate() == 99 ? null : signal.getGsmBitErrorRate());
        }
        values.put(Tables.SignalStrengths.WIFISIGNAL, wifiSignal);
        // check for LTE signal signal quality parameters only if connected to LTE
        if (networkType == TelephonyManager.NETWORK_TYPE_LTE) {
            Integer lteRsrp = -1, lteRsrq, lteSnr, lteCqi;

            lteRsrp = signal.getLayer3("mLteRsrp");
            lteRsrq = signal.getLayer3("mLteRsrq");
            lteSnr = signal.getLayer3("mLteRssnr");
            if (lteRsrp != null && lteRsrp >= 40 && lteRsrp < 140)
                lteRsrp = -lteRsrp;
            else if (lteRsrp != null && lteRsrp > 0 && lteRsrp <= 32)
                lteRsrp = (lteRsrp - 2) * 2 + -109;
            if (lteSnr == null || lteSnr > 1000)
                lteSnr = signal.getLayer3("mLteSnr");
            if (lteSnr == null || lteSnr < -200 || lteSnr > 1000)
                lteSnr = null;
            if (lteRsrp != null && lteRsrp > 1000)
                lteRsrp = lteRsrq = null;

            lteCqi = signal.getLayer3("mLteCqi");
            values.put(Tables.SignalStrengths.LTE_RSRP, lteRsrp);
            values.put(Tables.SignalStrengths.LTE_RSRQ, lteRsrq);
            values.put(Tables.SignalStrengths.LTE_SNR, lteSnr);
            values.put(Tables.SignalStrengths.LTE_CQI, lteCqi);

        }
        // check for the LTE signal regardless, at least it will indicate of device supports LTE
        Integer lteRssi = signal.getLayer3("mLteRssi");
        if (lteRssi == null)
            lteRssi = signal.getLayer3("mLteSignalStrength");
        if (lteRssi != null) {
            if (lteRssi >= 0 && lteRssi < 32) {
                if (lteRssi == 0)
                    lteRssi = -120; // officially 0 means -113dB or less, but since lowest possible signal on Blackberry = -120, call it -120 for consistency
                else if (lteRssi == 1)
                    lteRssi = -111; // officially 1 = -111 dB
                else if (lteRssi > 1 && lteRssi <= 31)
                    lteRssi = (lteRssi - 2) * 2 + -109;
            }

            // allow for the possibility of sending a 3G signal and LTE signal at the same time
            // but if LTE signal is present, and 3G signal says -120 or worse, ignore regular signal
            if (lteRssi > -120 && (dBm == null || dBm <= -120))
                values.put(Tables.SignalStrengths.SIGNAL, (Integer) lteRssi);

        }
        values.put(Tables.SignalStrengths.LTE_SIGNAL, lteRssi);

        if (serviceMode != null && serviceMode.getLong("time") + 20000 > System.currentTimeMillis()) {
            if (serviceMode.has("ecio") && serviceMode.getString("ecio").length() > 1) {
                int svc_ecio = Integer.parseInt(serviceMode.getString("ecio"), 10);
                if (svc_ecio <= -2 && svc_ecio >= -30) {
                    values.put(Tables.SignalStrengths.ECI0, svc_ecio);
                }
            }
            if (serviceMode.has("rscp") && serviceMode.getString("rscp").length() > 1) {
                int svc_rscp = Integer.parseInt(serviceMode.getString("rscp"), 10);
                if (svc_rscp <= -20 && svc_rscp >= -120) //  && (signalDB == null || signalDB <= -120))
                    values.put(Tables.SignalStrengths.SIGNAL, svc_rscp);
            }

            if (serviceMode.has("snr") && serviceMode.getString("snr").length() > 1) {
                float svc_fsnr = Float.parseFloat(serviceMode.getString("snr"));
                int svc_snr = (int) (svc_fsnr * 10);
                if (svc_snr > -200 && svc_snr < 2000)
                    values.put(Tables.SignalStrengths.LTE_SNR, svc_snr);
            }

            if (serviceMode.has("rsrp") && serviceMode.getString("rsrp").length() > 1) {
                int svc_rsrp = Integer.parseInt(serviceMode.getString("rsrp"), 10);
                if (svc_rsrp <= -20 && svc_rsrp >= -140)
                    values.put(Tables.SignalStrengths.LTE_RSRP, svc_rsrp);
            }

            if (serviceMode.has("rsrq") && serviceMode.getString("rsrq").length() > 1) {
                int svc_rsrq = Integer.parseInt(serviceMode.getString("rsrp"), 10);
                if (svc_rsrq <= -1 && svc_rsrq >= -30)
                    values.put(Tables.SignalStrengths.LTE_RSRQ, svc_rsrq);
            }

        }

        //now do the common parameters
        values.put(Tables.SignalStrengths.TIMESTAMP, signal.getTimestamp());
        values.put(Tables.SignalStrengths.EVENT_ID, stagedEventId);
        int coverage = 0;
        if (networkType == 0) {
            if (serviceState == ServiceState.STATE_IN_SERVICE)
                networkType = 1;
            //else if (serviceState == ServiceState.STATE_POWER_OFF)
            //   networkType = -1;
        }
        int networkTier = PhoneState.getNetworkGeneration(networkType);
        if (networkTier == 0) // dont make it 0 unless truly out of service
            networkTier = 1;
        if (serviceState == ServiceState.STATE_OUT_OF_SERVICE && (dataState != TelephonyManager.DATA_CONNECTED
                || networkType != TelephonyManager.NETWORK_TYPE_LTE)) // Sprint can be connected to LTE and say outofservice
            networkTier = 0;
        else if (serviceState == ServiceState.STATE_POWER_OFF
                || serviceState == ServiceState.STATE_EMERGENCY_ONLY
                || serviceState == ServiceState.STATE_POWER_OFF || serviceState == 9) // 9 = MMCPhoneStateListenerOld.SERVICE_STATE_AIRPLANE)
            networkTier = -1;

        // tier 5 becomes 11111, tier 1 = 00001
        coverage = networkTier; // (1 << networkTier) - 1;

        //String reflect = listSignalFields (signal);

        values.put(Tables.SignalStrengths.COVERAGE, coverage);
        //MMCLogger.logToFile(MMCLogger.Level.DEBUG, "", "onSignal.listSignalFields", reflect);
        //MMCLogger.logToFile(MMCLogger.Level.DEBUG, "", "onSignal.values", values.toString());
    } catch (Exception e) {
        LoggerUtil.logToFile(LoggerUtil.Level.ERROR, "ContentValuesGenerator", "generateFromSignal",
                "exception", e);
    }
    return values;
}

From source file:android_network.hetnet.vpn_service.Util.java

public static String getPhoneTypeName(int phoneType) {
    switch (phoneType) {
    case TelephonyManager.PHONE_TYPE_NONE:
        return "None";
    case TelephonyManager.PHONE_TYPE_GSM:
        return "GSM";
    case TelephonyManager.PHONE_TYPE_CDMA:
        return "CDMA";
    case TelephonyManager.PHONE_TYPE_SIP:
        return "SIP";
    default://  w  w w.  jav a 2 s. c o m
        return "Unknown";
    }
}

From source file:org.mozilla.mozstumbler.service.stumblerthread.scanners.cellscanner.CellInfo.java

@SuppressWarnings("fallthrough")
private static String getRadioTypeName(int phoneType) {
    switch (phoneType) {
    case TelephonyManager.PHONE_TYPE_CDMA:
        return RADIO_CDMA;

    case TelephonyManager.PHONE_TYPE_GSM:
        return RADIO_GSM;

    default:/*from www  . j  av a2  s  .co  m*/
        Log.e(LOG_TAG, "", new IllegalArgumentException("Unexpected phone type: " + phoneType));
        // fallthrough

    case TelephonyManager.PHONE_TYPE_NONE:
    case TelephonyManager.PHONE_TYPE_SIP:
        // These devices have no radio.
        return "";
    }
}

From source file:org.mozilla.mozstumbler.service.scanners.cellscanner.CellInfo.java

@SuppressWarnings("fallthrough")
private static String getRadioTypeName(int phoneType) {
    switch (phoneType) {
    case TelephonyManager.PHONE_TYPE_CDMA:
        return RADIO_CDMA;

    case TelephonyManager.PHONE_TYPE_GSM:
        return RADIO_GSM;

    default://  w  w w .  ja  va 2s  . c o  m
        Log.e(LOGTAG, "", new IllegalArgumentException("Unexpected phone type: " + phoneType));
        // fallthrough

    case TelephonyManager.PHONE_TYPE_NONE:
    case TelephonyManager.PHONE_TYPE_SIP:
        // These devices have no radio.
        return "";
    }
}