本文整理汇总了Java中android.telephony.CellInfoWcdma.getCellIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java CellInfoWcdma.getCellIdentity方法的具体用法?Java CellInfoWcdma.getCellIdentity怎么用?Java CellInfoWcdma.getCellIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.CellInfoWcdma
的用法示例。
在下文中一共展示了CellInfoWcdma.getCellIdentity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toCellularInfo
import android.telephony.CellInfoWcdma; //导入方法依赖的package包/类
private static CommonCellInfo toCellularInfo(CellInfoWcdma cellInfo) {
CommonCellInfo res = new CommonCellInfo();
CellIdentityWcdma identityWcdma = cellInfo.getCellIdentity();
CellSignalStrength signalStrength = cellInfo.getCellSignalStrength();
res.setType(WCDMA);
res.setCid(identityWcdma.getCid());
res.setLac(identityWcdma.getLac());
res.setMcc(identityWcdma.getMcc());
res.setMnc(identityWcdma.getMnc());
res.setDbm(valdiateDbm(signalStrength.getDbm()));
res.setLevel(signalStrength.getLevel());
return res;
}
示例2: cellInfoWCDMAJSON
import android.telephony.CellInfoWcdma; //导入方法依赖的package包/类
/**
* Converts CellInfoWcdma into JSON
* Some devices may not work correctly:
* - Reference 1: https://code.google.com/p/android/issues/detail?id=191492
* - Reference 2: http://stackoverflow.com/questions/17815062/cellidentitygsm-on-android
* @param cellInfo CellInfoWcdma
* @return JSON
*/
public static String cellInfoWCDMAJSON(CellInfoWcdma 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", WCDMA);
json.put("timestamp", calendar.getTimeInMillis());
final CellIdentityWcdma identityWcdma = cellInfo.getCellIdentity();
json.put("cid", identityWcdma.getCid());
json.put("lac", identityWcdma.getLac());
json.put("mcc", identityWcdma.getMcc());
json.put("mnc", identityWcdma.getMnc());
json.put("psc", identityWcdma.getPsc());
if (returnSignalStrength){
final JSONObject jsonSignalStrength = new JSONObject();
final CellSignalStrengthWcdma cellSignalStrengthWcdma = cellInfo.getCellSignalStrength();
jsonSignalStrength.put("asuLevel", cellSignalStrengthWcdma.getAsuLevel());
jsonSignalStrength.put("dbm", cellSignalStrengthWcdma.getDbm());
jsonSignalStrength.put("level", cellSignalStrengthWcdma.getLevel());
json.put("cellSignalStrengthWcdma", jsonSignalStrength);
}
}
catch(JSONException exc) {
logJSONException(exc);
}
}
return json.toString();
}
示例3: update
import android.telephony.CellInfoWcdma; //导入方法依赖的package包/类
/**
* Adds or updates a cell tower.
* <p>
* If the cell tower is already in the list, its data is updated; if not, a
* new entry is created.
* <p>
* This method will set the cell's identity data and generation, its signal
* strength and whether it is the currently serving cell.
* @return The new or updated entry.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public CellTowerGsm update(CellInfoWcdma cell) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
return null;
CellIdentityWcdma cid = cell.getCellIdentity();
CellTowerGsm result = null;
CellTowerGsm cand = this.get(cid.getMcc(), cid.getMnc(), cid.getLac(), cid.getCid());
if ((cand != null) && CellTower.matches(cid.getPsc(), cand.getPsc()))
result = cand;
if (result == null) {
cand = this.get(cid.getPsc());
if ((cand != null)
&& ((cid.getMcc() == Integer.MAX_VALUE) || CellTower.matches(cid.getMcc(), cand.getMcc()))
&& ((cid.getMnc() == Integer.MAX_VALUE) || CellTower.matches(cid.getMnc(), cand.getMnc()))
&& ((cid.getLac() == Integer.MAX_VALUE) || CellTower.matches(cid.getLac(), cand.getLac()))
&& ((cid.getCid() == Integer.MAX_VALUE) ||CellTower.matches(cid.getCid(), cand.getCid())))
result = cand;
}
if (result == null)
result = new CellTowerGsm(cid.getMcc(), cid.getMnc(), cid.getLac(), cid.getCid(), cid.getPsc());
if (result.getMcc() == CellTower.UNKNOWN)
result.setMcc(cid.getMcc());
if (result.getMnc() == CellTower.UNKNOWN)
result.setMnc(cid.getMnc());
if (result.getLac() == CellTower.UNKNOWN)
result.setLac(cid.getLac());
if (result.getCid() == CellTower.UNKNOWN)
result.setCid(cid.getCid());
if (result.getPsc() == CellTower.UNKNOWN)
result.setPsc(cid.getPsc());
this.put(result.getText(), result);
this.put(result.getAltText(), result);
result.setCellInfo(true);
result.setDbm(cell.getCellSignalStrength().getDbm());
result.setGeneration(3);
result.setServing(cell.isRegistered());
if ((result.getText() == null) && (result.getAltText() == null))
Log.d(this.getClass().getSimpleName(), String.format("Added %d G cell with no data from CellInfoWcdma", result.getGeneration()));
return result;
}