Example usage for android.telephony CellIdentityLte getTac

List of usage examples for android.telephony CellIdentityLte getTac

Introduction

In this page you can find the example usage for android.telephony CellIdentityLte getTac.

Prototype

public int getTac() 

Source Link

Usage

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

/**
 * Converts CellInfoLte into JSON/*from w  ww  .j a v  a 2  s . co  m*/
 * @param cellInfo CellInfoLte
 * @return JSON
 */
public static String cellInfoLTEJSON(CellInfoLte 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", LTE);
            json.put("timestamp", calendar.getTimeInMillis());

            final CellIdentityLte identityLte = cellInfo.getCellIdentity();

            json.put("ci", identityLte.getCi());
            json.put("mcc", identityLte.getMcc());
            json.put("mnc", identityLte.getMnc());
            json.put("pci", identityLte.getPci());
            json.put("tac", identityLte.getTac());

            if (returnSignalStrength) {
                final JSONObject jsonSignalStrength = new JSONObject();
                final CellSignalStrengthLte cellSignalStrengthLte = cellInfo.getCellSignalStrength();
                jsonSignalStrength.put("asuLevel", cellSignalStrengthLte.getAsuLevel());
                jsonSignalStrength.put("dbm", cellSignalStrengthLte.getDbm());
                jsonSignalStrength.put("level", cellSignalStrengthLte.getLevel());
                jsonSignalStrength.put("timingAdvance", cellSignalStrengthLte.getTimingAdvance());

                json.put("cellSignalStrengthLte", jsonSignalStrength);
            }
        } catch (JSONException exc) {
            logJSONException(exc);
        }
    }
    return json.toString();
}

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

@TargetApi(17)
public String updateLteNeighborHistory(List<CellInfo> cellinfos) {
    if (cellinfos == null || cellinfos.size() == 0) {
        if (lastLTECell != null) {
            CellidSample smp = new CellidSample("L", 0, 0, 0);
            neighbor_history.add(smp);//  w  ww.  j  ava  2  s . c  om
            lastLTECell = null;
        }
        return null;
    }
    for (int i = 0; i < cellinfos.size(); i++) {
        // All we're interested in here is getting new Lte cell identity with this new API. Otherwise ignore and use CellLocation updates
        if (cellinfos.get(i) instanceof CellInfoLte) {
            CellIdentityLte cellIDLte = ((CellInfoLte) cellinfos.get(i)).getCellIdentity();
            if (cellIDLte.getTac() > 0 && cellIDLte.getTac() < 100000) {
                int tac = cellIDLte.getTac(), pci = cellIDLte.getPci(), ci = cellIDLte.getCi();
                return updateLteNeighborHistory(tac, ci, pci);
            }
        } else // Lte CellIdentity contains bogus ids, treat like its null
        {
            CellidSample smp = new CellidSample("L", 0, 0, 0);
            neighbor_history.add(smp);
            lastLTECell = null;

        }
    }
    return null;
}