/**
* Converts CellInfoLte into JSON
* @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();
}
JSONHelper.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:localcloud_fe
作者:
评论列表
文章目录