Example usage for android.telephony.cdma CdmaCellLocation convertQuartSecToDecDegrees

List of usage examples for android.telephony.cdma CdmaCellLocation convertQuartSecToDecDegrees

Introduction

In this page you can find the example usage for android.telephony.cdma CdmaCellLocation convertQuartSecToDecDegrees.

Prototype

public static double convertQuartSecToDecDegrees(int quartSec) 

Source Link

Document

Converts latitude or longitude from 0.25 seconds (as defined in the 3GPP2 C.S0005-A v6.0 standard) to decimal degrees

Usage

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

/**
 * Converts CellInfoCdma into JSON//ww  w.j av a2s.c  o m
 * @param cellInfo CellInfoCdma
 * @return JSON
 */
public static String cellInfoCDMAJSON(CellInfoCdma cellInfo, boolean returnSignalStrength) {

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo != null) {
        try {
            json.put("provider", CELLINFO_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityCdma identityCdma = cellInfo.getCellIdentity();

            json.put("latitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLatitude()));
            json.put("longitude", CdmaCellLocation.convertQuartSecToDecDegrees(identityCdma.getLongitude()));
            json.put("basestationId", identityCdma.getBasestationId());
            json.put("networkId", identityCdma.getNetworkId());
            json.put("systemId", identityCdma.getSystemId());

            if (returnSignalStrength) {
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthCdma cellSignalStrengthCdma = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthCdma.getAsuLevel());
                jsonSignalStrength.put("cdmaDbm", cellSignalStrengthCdma.getCdmaDbm());
                jsonSignalStrength.put("cdmaEcio", cellSignalStrengthCdma.getCdmaEcio());
                jsonSignalStrength.put("cdmaLevel", cellSignalStrengthCdma.getCdmaLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthCdma.getDbm());
                jsonSignalStrength.put("evdoDbm", cellSignalStrengthCdma.getEvdoDbm());
                jsonSignalStrength.put("evdoEcio", cellSignalStrengthCdma.getEvdoEcio());
                jsonSignalStrength.put("evdoLevel", cellSignalStrengthCdma.getEvdoLevel());
                jsonSignalStrength.put("evdoSnr", cellSignalStrengthCdma.getEvdoSnr());
                jsonSignalStrength.put("level", cellSignalStrengthCdma.getLevel());

                json.put("cellSignalStrengthCdma", jsonSignalStrength);
            }
        } catch (JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}

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

/**
 * Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
 * http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
 * @param location CdmaCellLocation/*from   w  w  w  .ja v a2  s  .  c o m*/
 * @return JSON
 */
public static String cdmaCellLocationJSON(CdmaCellLocation location) {

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && location != null) {
        try {
            json.put("provider", CELLLOCATION_PROVIDER);
            json.put("type", CDMA);
            json.put("timestamp", calendar.getTimeInMillis());
            json.put("baseStationId", location.getBaseStationId()); // -1 if unknown
            json.put("networkId", location.getNetworkId()); // -1 if unknown
            json.put("systemId", location.getSystemId()); // -1 if unknown
            json.put("baseStationLatitude",
                    CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLatitude()));
            json.put("baseStationLongitude",
                    CdmaCellLocation.convertQuartSecToDecDegrees(location.getBaseStationLongitude()));
        } catch (JSONException exc) {
            logJSONException(exc);
        }
    }

    return json.toString();
}