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


Java CellIdentityGsm.getCid方法代码示例

本文整理汇总了Java中android.telephony.CellIdentityGsm.getCid方法的典型用法代码示例。如果您正苦于以下问题:Java CellIdentityGsm.getCid方法的具体用法?Java CellIdentityGsm.getCid怎么用?Java CellIdentityGsm.getCid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.telephony.CellIdentityGsm的用法示例。


在下文中一共展示了CellIdentityGsm.getCid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCellularInfo

import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
public String getCellularInfo(TelephonyManager telephonyManager)
{
    String cellularInfo = "";
    String log = "";
    if(telephonyManager.getAllCellInfo()==null) {
        Log.v(TAG, "getAllCellInfo returned null");
    }
    else {
        for (final CellInfo info : telephonyManager.getAllCellInfo()) {
            if (info instanceof CellInfoGsm) {
                log += "[email protected]";
                CellIdentityGsm gsm_cell = ((CellInfoGsm) info).getCellIdentity();
                log += gsm_cell.getCid() + "#" + gsm_cell.getLac() + "#" + gsm_cell.getMcc() + "#" + gsm_cell.getMnc() + "_";

                final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
                log += gsm.getDbm() + "#" + gsm.getLevel()+"#"+gsm.getAsuLevel()+":";
            } else if (info instanceof CellInfoCdma) {
                log += "[email protected]";
                CellIdentityCdma cdma_cell = ((CellInfoCdma) info).getCellIdentity();
                log += cdma_cell.getBasestationId() + "#" + cdma_cell.getNetworkId() + "#" + cdma_cell.getSystemId() + "#" + cdma_cell.getSystemId() + "_";

                final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
                log += cdma.getDbm() + "#" + cdma.getLevel()+"#"+cdma.getAsuLevel()+":";
            } else if (info instanceof CellInfoLte) {
                log += "[email protected]";
                CellIdentityLte lte_cell = ((CellInfoLte) info).getCellIdentity();
                log += lte_cell.getCi() + "#" + lte_cell.getPci() + "#" + lte_cell.getMcc() + "#" + lte_cell.getMnc() + "_";

                final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
                log += lte.getDbm() + "#" + lte.getLevel()+"#"+lte.getAsuLevel()+":";
            } else if (info instanceof CellInfoWcdma) {
                log += "[email protected]";
                CellIdentityWcdma wcdma_cell = ((CellInfoWcdma) info).getCellIdentity();
                log += wcdma_cell.getCid() + "#" + wcdma_cell.getLac() + "#" + wcdma_cell.getMcc() + "#" + wcdma_cell.getMnc() + "_";

                final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength();
                log += wcdma.getDbm() + "#" + wcdma.getLevel()+"#"+wcdma.getAsuLevel()+":";
            } else {
                Log.v(TAG, "Unknown Network Type");
            }
        }
    }
    cellularInfo = log;
    return cellularInfo;
}
 
开发者ID:gautamgitspace,项目名称:CellularNetworkMonitor,代码行数:46,代码来源:CellularDataRecorder.java

示例2: isValidGsmCell

import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
/**
 * A valid gsm cell must have cell id != -1
 * Note: cells with cid > max value 0xffff are accepted (typically UMTS cells. We handle them separately
 * @param gsmIdentity {@link CellIdentityGsm}
 * @return true if valid gsm cell
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private boolean isValidGsmCell(final CellIdentityGsm gsmIdentity) {
	if (gsmIdentity == null) {
		return false;
	}

	final Integer cid = gsmIdentity.getCid();
	return (cid > 0 && cid != Integer.MAX_VALUE);
}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:16,代码来源:WirelessLoggerService.java

示例3: getAllCellInfo

import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void getAllCellInfo(List<CellInfo> cellInfo) {
    // only for registered cells is returned identify
    // SlimKat in Galaxy Nexus - returns null :-/
    // Honor 7 - returns empty list (not null), Dual SIM?

    if (cellInfo!=null) {

        if (Permissions.checkLocation(context.getApplicationContext())) {

            //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "---- start ----------------------------");

            for (CellInfo _cellInfo : cellInfo) {
                //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "registered="+_cellInfo.isRegistered());

                if (_cellInfo instanceof CellInfoGsm) {
                    //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm info="+_cellInfo);
                    CellIdentityGsm identityGsm = ((CellInfoGsm) _cellInfo).getCellIdentity();
                    if (identityGsm.getCid() != Integer.MAX_VALUE) {
                        //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm mCid="+identityGsm.getCid());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityGsm.getCid();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                } else if (_cellInfo instanceof CellInfoLte) {
                    //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte info="+_cellInfo);
                    CellIdentityLte identityLte = ((CellInfoLte) _cellInfo).getCellIdentity();
                    if (identityLte.getCi() != Integer.MAX_VALUE) {
                        //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte mCi="+identityLte.getCi());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityLte.getCi();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                } else if (_cellInfo instanceof CellInfoWcdma) {
                    //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma info="+_cellInfo);
                    //if (android.os.Build.VERSION.SDK_INT >= 18) {
                        CellIdentityWcdma identityWcdma = ((CellInfoWcdma) _cellInfo).getCellIdentity();
                        if (identityWcdma.getCid() != Integer.MAX_VALUE) {
                            //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid=" + identityWcdma.getCid());
                            if (_cellInfo.isRegistered()) {
                                registeredCell = identityWcdma.getCid();
                                lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                            }
                        }
                    //}
                    //else {
                    //    PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid=not supported for API level < 18");
                    //}
                } else if (_cellInfo instanceof CellInfoCdma) {
                    //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cdma info="+_cellInfo);
                    CellIdentityCdma identityCdma = ((CellInfoCdma) _cellInfo).getCellIdentity();
                    if (identityCdma.getBasestationId() != Integer.MAX_VALUE) {
                        //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid="+identityCdma.getBasestationId());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityCdma.getBasestationId();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                }
                //else {
                //    PPApplication.logE("PhoneStateScanner.getAllCellInfo", "unknown info="+_cellInfo);
                //}
            }

            //PPApplication.logE("PhoneStateScanner.getAllCellInfo", "---- end ----------------------------");

            PPApplication.logE("PhoneStateScanner.getAllCellInfo", "registeredCell=" + registeredCell);
        }

    }
    else
        PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cell info is null");
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:76,代码来源:PhoneStateScanner.java

示例4: fill

import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
public static void fill(TheDictionary map, CellIdentityGsm value) throws Exception {
	if (value != null) {
		map.put("type", "2");
		int i;
		i = value.getMcc();
		if (i != Integer.MAX_VALUE && i > 0 && i < 1000) map.put("mcc", i);
		i = value.getMnc();
		if (i != Integer.MAX_VALUE && i > 0 && i < 1000) map.put("mnc", i);
		i = value.getLac();
		if (i != Integer.MAX_VALUE && i > 0) map.put("lac", i);
		i = value.getCid();
		if (i != Integer.MAX_VALUE && i > 0) map.put("cid", i);
		//map.put("psc", value.getPsc()); // depricated
	}
}
 
开发者ID:emdete,项目名称:tabulae,代码行数:16,代码来源:CellId.java

示例5: isValidGsmCell

import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
/**
 * A valid gsm cell must have cell id != -1
 * Note: cells with cid > max value 0xffff are accepted (typically UMTS cells. We handle them separately
 *
 * @param gsmIdentity {@link CellIdentityGsm}
 * @return true if valid gsm cell
 */
@TargetApi(JELLY_BEAN_MR1)
private boolean isValidGsmCell(final CellIdentityGsm gsmIdentity) {
    if (gsmIdentity == null) {
        return false;
    }

    final Integer cid = gsmIdentity.getCid();
    return (cid > 0 && cid != Integer.MAX_VALUE);
}
 
开发者ID:openbmap,项目名称:radiocells-scanner-android,代码行数:17,代码来源:WirelessLoggerService.java

示例6: fill

import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
public static void fill(TheDictionary map, CellIdentityGsm value) throws Exception {
	if (value != null) {
		map.put("type", "2");
		int i;
		i = value.getMcc(); if (i != Integer.MAX_VALUE && i > 0 && i < 1000) map.put("mcc", i);
		i = value.getMnc(); if (i != Integer.MAX_VALUE && i > 0 && i < 1000) map.put("mnc", i);
		i = value.getLac(); if (i != Integer.MAX_VALUE && i > 0) map.put("lac", i);
		i = value.getCid(); if (i != Integer.MAX_VALUE && i > 0) map.put("cid", i);
		//map.put("psc", value.getPsc()); // depricated
	}
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:12,代码来源:CellId.java

示例7: startScan

import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void startScan() {
	
	logMessage("starting tower scan... ");
	Scan scan = new Scan();

	// TODO: Get location from user?
	scan.setLocation(lastScanName);

	// TODO: use actual GPS Coordinates
	scan.setLatitude(lastScanLat);
	scan.setLongitude(lastScanLon);

	long scan_id = db.createScan(scan);

	List<CellInfo> cellInfos = (List<CellInfo>) this.telephonyManager
			.getAllCellInfo();

	// TODO: better error handling of null cellinfos
	if (cellInfos != null) {
		for (CellInfo cellInfo : cellInfos) {

			if (cellInfo instanceof CellInfoGsm) {
				CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;

				CellIdentityGsm cellIdentity = cellInfoGsm
						.getCellIdentity();
				CellSignalStrengthGsm cellSignalStrengthGsm = cellInfoGsm
						.getCellSignalStrength();

				int dbmLevel = cellSignalStrengthGsm.getDbm();
				
				com.spideyapp.sqlite.model.CellInfo cell = new com.spideyapp.sqlite.model.CellInfo(
						cellIdentity.getCid(), cellIdentity.getLac(),
						cellIdentity.getMcc(), cellIdentity.getMnc(),dbmLevel);

				db.createCell(cell, scan_id);

				shareCellInfo (cell);
				
			}
		}
	}

}
 
开发者ID:jtwarren,项目名称:spidey,代码行数:46,代码来源:ScanService.java

示例8: update

import android.telephony.CellIdentityGsm; //导入方法依赖的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, its signal strength and
 * whether it is the currently serving cell. If the API level is 18 or 
 * higher, it will also set the generation.
 * @return The new or updated entry.
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public CellTowerGsm update(CellInfoGsm cell) {
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) 
		return null;
	CellIdentityGsm 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());
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
		result.setGeneration(2);
	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 CellInfoGsm", result.getGeneration()));
	return result;
}
 
开发者ID:mvglasow,项目名称:satstat,代码行数:53,代码来源:CellTowerListGsm.java


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