當前位置: 首頁>>代碼示例>>Java>>正文


Java NeighboringCellInfo.getLac方法代碼示例

本文整理匯總了Java中android.telephony.NeighboringCellInfo.getLac方法的典型用法代碼示例。如果您正苦於以下問題:Java NeighboringCellInfo.getLac方法的具體用法?Java NeighboringCellInfo.getLac怎麽用?Java NeighboringCellInfo.getLac使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.telephony.NeighboringCellInfo的用法示例。


在下文中一共展示了NeighboringCellInfo.getLac方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fill

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
public void fill(TheDictionary map, NeighboringCellInfo value) throws Exception {
	if (value != null) {
		map.put("mcc", mcc);
		map.put("mnc", mnc);
		int i;
		i = value.getPsc();
		if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("psc", i);
		i = value.getRssi();
		if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("rssi", i);
		i = value.getLac();
		if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("lac", i);
		i = value.getCid();
		if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("cid", i);
		map.put("registered", false);
		determine_type(map);
	}
}
 
開發者ID:emdete,項目名稱:tabulae,代碼行數:18,代碼來源:CellIdPre17API.java

示例2: addNeighbours

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
/**
 * Add neighbouring cells as generated by the getNeighboringCells API.
 * @param neighbours The list of neighbouring cells.
 */
public void addNeighbours(List<NeighboringCellInfo> neighbours) {
    if (neighbours == null || neighbours.isEmpty()) return;
    for (NeighboringCellInfo neighbour : neighbours) {
        List<CellInfo> cellInfos = db.query(neighbour.getCid(), neighbour.getLac());
        if (cellInfos != null && !cellInfos.isEmpty()) {
            for (CellInfo cellInfo : cellInfos) {
                pushRecentCells(cellInfo);
            }
        } else {
            CellInfo ci = new CellInfo();
            ci.lng = 0d;
            ci.lat = 0d;
            ci.CID = neighbour.getCid();
            ci.LAC = neighbour.getLac();
            ci.MCC = -1;
            ci.MNC = -1;
            pushUnusedCells(ci);
        }
    }
}
 
開發者ID:rtreffer,項目名稱:LocalGSMLocationProvider,代碼行數:25,代碼來源:CellbasedLocationProvider.java

示例3: getCellInfo

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
/**
 * Returns the information about cell towers in range. Returns null if the information is 
 * not available 
 * 
 * TODO(wenjiezeng): As folklore has it and Wenjie has confirmed, we cannot get cell info from
 * Samsung phones.
 */
public String getCellInfo(boolean cidOnly) {
  initNetwork();
  List<NeighboringCellInfo> infos = telephonyManager.getNeighboringCellInfo();
  StringBuffer buf = new StringBuffer();
  String tempResult = "";
  if (infos.size() > 0) {
    for (NeighboringCellInfo info : infos) {
      tempResult = cidOnly ? info.getCid() + ";" : info.getLac() + "," 
                             + info.getCid() + "," + info.getRssi() + ";";
      buf.append(tempResult);
    }
    // Removes the trailing semicolon
    buf.deleteCharAt(buf.length() - 1);
    return buf.toString();
  } else {
    return null;
  }
}
 
開發者ID:laoyaosniper,項目名稱:Mobilyzer,代碼行數:26,代碼來源:PhoneUtils.java

示例4: isValidNeigbor

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
/**
 * @param ci
 * @return
 */
private boolean isValidNeigbor(final NeighboringCellInfo ci) {
	if (ci == null) {
		return false;
	}
	return (ci.getCid() !=  NeighboringCellInfo.UNKNOWN_CID || ci.getLac() != NeighboringCellInfo.UNKNOWN_CID || ci.getPsc() !=  NeighboringCellInfo.UNKNOWN_CID);
}
 
開發者ID:saintbyte,項目名稱:openbmap,代碼行數:11,代碼來源:WirelessLoggerService.java

示例5: parseCellInfo

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
private Cell parseCellInfo(NeighboringCellInfo info) {
    try {
        if (getCellType(info.getNetworkType()) != Cell.CellType.GSM) return null;
        return new Cell(Cell.CellType.GSM, getMcc(), getMnc(), info.getLac(), info.getCid(),
                info.getPsc(), info.getRssi());
    } catch (Exception ignored) {
    }
    return null;
}
 
開發者ID:microg,項目名稱:android_external_UnifiedNlpApi,代碼行數:10,代碼來源:CellBackendHelper.java

示例6: m

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
protected final List m()
{
    ArrayList arraylist = new ArrayList();
    if (b == null)
    {
        return arraylist;
    }
    if (!c())
    {
        return arraylist;
    }
    Iterator iterator = b.getNeighboringCellInfo().iterator();
    int i1 = 0;
    do
    {
        if (!iterator.hasNext())
        {
            break;
        }
        NeighboringCellInfo neighboringcellinfo = (NeighboringCellInfo)iterator.next();
        if (i1 > 15)
        {
            break;
        }
        if (neighboringcellinfo.getLac() != 0 && neighboringcellinfo.getLac() != 65535 && neighboringcellinfo.getCid() != 65535 && neighboringcellinfo.getCid() != 0xfffffff)
        {
            arraylist.add(neighboringcellinfo);
            i1++;
        }
    } while (true);
    return arraylist;
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:33,代碼來源:ai.java

示例7: fill

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
public void fill(TheDictionary map, NeighboringCellInfo value) throws Exception {
	if (value != null) {
		map.put("mcc", mcc);
		map.put("mnc", mnc);
		int i;
		i = value.getPsc(); if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("psc", i);
		i = value.getRssi(); if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("rssi", i);
		i = value.getLac(); if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("lac", i);
		i = value.getCid(); if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("cid", i);
		map.put("registered", false);
		determine_type(map);
	}
}
 
開發者ID:emdete,項目名稱:Simplicissimus,代碼行數:14,代碼來源:CellIdPre17API.java

示例8: updateNeighbouringCells

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
/**
 *  Description:    Updates Neighbouring Cell details
 *
 *                  TODO: add more details...
 *
 *
 */
public List<Cell> updateNeighbouringCells() {
    List<Cell> neighboringCells = new ArrayList<>();
    List<NeighboringCellInfo> neighboringCellInfo = tm.getNeighboringCellInfo();

    if (neighboringCellInfo == null) {
        neighboringCellInfo = new ArrayList<>();
    }

    Boolean nclp = tinydb.getBoolean("nc_list_present"); // Is NC list present? (default is false)

    //if nclp = true then check for neighboringCellInfo
    //if (neighboringCellInfo != null && neighboringCellInfo.size() == 0 && nclp) {
    //if (!neighboringCellInfo.isEmpty() && neighboringCellInfo.size() == 0 && nclp) {
    if (neighboringCellInfo.size() == 0 && nclp) {

        Log.i(TAG, mTAG + "NeighbouringCellInfo is empty: start polling...");

        // Try to poll the neighboring cells for a few seconds
        neighboringCellBlockingQueue = new LinkedBlockingQueue<>(100); // Max 100 NC's before blocking (?)

        // ToDo: rename... (We don't use API's <18 anymore.)
        DeviceApi18.startListening(tm, phoneStatelistener);

        // ToDo: Move or remove. This should now be done by getAllCellInfo() in new RadioAPI "collector" module.
        for (int i = 0; i < 10 && neighboringCellInfo.size() == 0; i++) {
            try {
                Log.d(TAG, mTAG + "NeighbouringCellInfo empty: trying " + i);
                NeighboringCellInfo info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS);
                if (info == null) {
                    neighboringCellInfo = tm.getNeighboringCellInfo();
                    if (neighboringCellInfo != null) {
                        if (neighboringCellInfo.size() > 0) {
                            // Can we think of a better log message here?
                            Log.d(TAG, mTAG + "NeighbouringCellInfo found on " + i + " try. (time based)");
                            break;
                        } else {
                            continue;
                        }
                    }
                }
                List<NeighboringCellInfo> cellInfoList =
                        new ArrayList<>(neighboringCellBlockingQueue.size() + 1);
                while (info != null) {
                    cellInfoList.add(info);
                    info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS);
                }
                neighboringCellInfo = cellInfoList;
            } catch (InterruptedException e) {
                Log.e(TAG, mTAG + "Interrupted BlockingQueue Exception: " + e);
            }
        }
    }

    //log.debug(mTAG + ": neighbouringCellInfo size: " + neighboringCellInfo.size());

    // Add NC list to DBi_measure:nc_list
    for (NeighboringCellInfo neighbourCell : neighboringCellInfo) {
        Log.i(TAG, mTAG + "NeighbouringCellInfo -" +
                " LAC:" + neighbourCell.getLac() +
                " CID:" + neighbourCell.getCid() +
                " PSC:" + neighbourCell.getPsc() +
                " RSSI:" + neighbourCell.getRssi());

        final Cell cell = new Cell(
                neighbourCell.getCid(),
                neighbourCell.getLac(),
                neighbourCell.getRssi(),
                neighbourCell.getPsc(),
                neighbourCell.getNetworkType(), false);
        neighboringCells.add(cell);
    }
    return neighboringCells;
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:81,代碼來源:CellTracker.java

示例9: update

import android.telephony.NeighboringCellInfo; //導入方法依賴的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. Cells whose network type is not LTE will be
 * rejected.
 * <p>
 * This method will set the cell's identity data, generation and its signal
 * strength.
 * @return The new or updated entry, or {@code null} if the cell was rejected
 */
public CellTowerLte update(String networkOperator, NeighboringCellInfo cell) {
	int mcc = CellTower.UNKNOWN;
	int mnc = CellTower.UNKNOWN;
	if (networkOperator.length() > 3) {
		mcc = Integer.parseInt(networkOperator.substring(0, 3));
		mnc = Integer.parseInt(networkOperator.substring(3));
	}
	CellTowerLte result = null;
	CellTowerLte cand = this.get(mcc, mnc, cell.getLac(), cell.getCid());
	if ((cand != null) && CellTower.matches(cell.getPsc(), cand.getPci()))
		result = cand;

	if (result == null) {
		cand = this.get(cell.getPsc());
		if ((cand != null)
				&& CellTower.matches(mcc, cand.getMcc())
				&& CellTower.matches(mnc, cand.getMnc())
				&& CellTower.matches(cell.getLac(), cand.getTac())
				&& CellTower.matches(cell.getCid(), cand.getCi()))
			result = cand;
	}
	if (result == null)
		result = new CellTowerLte(mcc, mnc, cell.getLac(), cell.getCid(), cell.getPsc());
	result.setNeighboringCellInfo(true);
	int networkType = cell.getNetworkType();
	switch (networkType) {
	case TelephonyManager.NETWORK_TYPE_LTE:
			result.setAsu(cell.getRssi());
			break;
		default:
			// not an LTE cell, return
			return null;
	}
	result.setNetworkType(networkType);
	if (result.getMcc() == CellTower.UNKNOWN)
		result.setMcc(mcc);
	if (result.getMnc() == CellTower.UNKNOWN)
		result.setMnc(mnc);
	if (result.getTac() == CellTower.UNKNOWN)
		result.setTac(cell.getLac());
	if (result.getCi() == CellTower.UNKNOWN)
		result.setCi(cell.getCid());
	if (result.getPci() == CellTower.UNKNOWN)
		result.setPci(cell.getPsc());
	this.put(result.getText(), result);
	this.put(result.getAltText(), result);
	Log.d(this.getClass().getSimpleName(), String.format("Added NeighboringCellInfo for %s, %d G, %d dBm",
			result.getText(),
			result.getGeneration(),
			result.getDbm()));
	return result;
}
 
開發者ID:mvglasow,項目名稱:satstat,代碼行數:64,代碼來源:CellTowerListLte.java

示例10: update

import android.telephony.NeighboringCellInfo; //導入方法依賴的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. Cells whose network type is not a flavor of GSM or
 * UMTS will be rejected.
 * <p>
 * This method will set the cell's identity data, generation and its signal
 * strength. 
 * @return The new or updated entry, or {@code null} if the cell was rejected
 */
public CellTowerGsm update(String networkOperator, NeighboringCellInfo cell) {
	int mcc = CellTower.UNKNOWN;
	int mnc = CellTower.UNKNOWN;
	if (networkOperator.length() > 3) {
		mcc = Integer.parseInt(networkOperator.substring(0, 3));
		mnc = Integer.parseInt(networkOperator.substring(3));
	}
	CellTowerGsm result = null;
	CellTowerGsm cand = this.get(mcc, mnc, cell.getLac(), cell.getCid());
	if ((cand != null) && CellTower.matches(cell.getPsc(), cand.getPsc()))
		result = cand;

	if (result == null) {
		cand = this.get(cell.getPsc());
		if ((cand != null)
				&& CellTower.matches(mcc, cand.getMcc())
				&& CellTower.matches(mnc, cand.getMnc())
				&& CellTower.matches(cell.getLac(), cand.getLac())
				&& CellTower.matches(cell.getCid(), cand.getCid()))
			result = cand;
	}
	if (result == null)
		result = new CellTowerGsm(mcc, mnc, cell.getLac(), cell.getCid(), cell.getPsc());
	result.setNeighboringCellInfo(true);
	int networkType = cell.getNetworkType();
	switch (networkType) {
		case TelephonyManager.NETWORK_TYPE_UMTS:
		case TelephonyManager.NETWORK_TYPE_HSDPA:
		case TelephonyManager.NETWORK_TYPE_HSUPA:
		case TelephonyManager.NETWORK_TYPE_HSPA:
			/*
			 * for details see TS 25.133 section 9.1.1.3
			 * http://www.3gpp.org/DynaReport/25133.htm
			 */
			result.setCpichRscp(cell.getRssi());
			break;
		case TelephonyManager.NETWORK_TYPE_EDGE:
		case TelephonyManager.NETWORK_TYPE_GPRS:
			result.setAsu(cell.getRssi());
			break;
		default:
			// not a GSM or UMTS cell, return
			return null;
			// result.setDbm(CellTower.DBM_UNKNOWN);
			// not needed because this is the default value; setting it
			// here might overwrite valid data obtained from a different
			// source
	}
	result.setNetworkType(networkType);
	if (result.getMcc() == CellTower.UNKNOWN)
		result.setMcc(mcc);
	if (result.getMnc() == CellTower.UNKNOWN)
		result.setMnc(mnc);
	if (result.getLac() == CellTower.UNKNOWN)
		result.setLac(cell.getLac());
	if (result.getCid() == CellTower.UNKNOWN)
		result.setCid(cell.getCid());
	if (result.getPsc() == CellTower.UNKNOWN)
		result.setPsc(cell.getPsc());
	this.put(result.getText(), result);
	this.put(result.getAltText(), result);
	if ((result.getText() == null) && (result.getAltText() == null))
		Log.d(this.getClass().getSimpleName(), String.format("Added %d G cell with no data from NeighboringCellInfo", result.getGeneration()));
	return result;
}
 
開發者ID:mvglasow,項目名稱:satstat,代碼行數:77,代碼來源:CellTowerListGsm.java

示例11: isValidNeigbor

import android.telephony.NeighboringCellInfo; //導入方法依賴的package包/類
/**
 * Tests whether a given neighboring cell is valid
 * Check is required as some modems only return dummy values for neighboring cells
 *
 * Note: PSC is not checked, as PSC may be -1 on GSM networks
 * see https://developer.android.com/reference/android/telephony/gsm/GsmCellLocation.html#getPsc()
 *
 * @param c cell
 * @return true if cell has a valid cell id and lac
 */
private boolean isValidNeigbor(final NeighboringCellInfo c) {
    if (c == null) {
        return false;
    }
    return (
            (c.getCid() != NeighboringCellInfo.UNKNOWN_CID && c.getCid() < 0xffff) &&
            (c.getLac() != NeighboringCellInfo.UNKNOWN_CID && c.getLac() < 0xffff));
}
 
開發者ID:openbmap,項目名稱:radiocells-scanner-android,代碼行數:19,代碼來源:WirelessLoggerService.java


注:本文中的android.telephony.NeighboringCellInfo.getLac方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。