当前位置: 首页>>代码示例>>Java>>正文


Java CellInfoWcdma.getCellIdentity方法代码示例

本文整理汇总了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;
}
 
开发者ID:ANFR-France,项目名称:proto-collecte,代码行数:16,代码来源:CellInfoUtil.java

示例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();
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:44,代码来源:JSONHelper.java

示例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;
}
 
开发者ID:mvglasow,项目名称:satstat,代码行数:51,代码来源:CellTowerListGsm.java


注:本文中的android.telephony.CellInfoWcdma.getCellIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。