本文整理匯總了Java中android.telephony.NeighboringCellInfo類的典型用法代碼示例。如果您正苦於以下問題:Java NeighboringCellInfo類的具體用法?Java NeighboringCellInfo怎麽用?Java NeighboringCellInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NeighboringCellInfo類屬於android.telephony包,在下文中一共展示了NeighboringCellInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSignalStrengthsChanged
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
/**
* Description: TODO: add more info
*
* Issues:
*
* [ ] Getting and comparing signal strengths between different RATs can be very
* tricky, since they all return different ranges of values. AOS doesn't
* specify very clearly what exactly is returned, even though people have
* a good idea, by trial and error.
*
* See note in : SignalStrengthTracker.java
*
* Notes:
*
*
*
*/
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
// Update Signal Strength
if (signalStrength.isGsm()) {
int dbm;
if (signalStrength.getGsmSignalStrength() <= 2 ||
signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
// Unknown signal strength, get it another way
String[] bits = signalStrength.toString().split(" ");
dbm = Integer.parseInt(bits[9]);
} else {
dbm = signalStrength.getGsmSignalStrength();
}
mDevice.setSignalDbm(dbm);
} else {
int evdoDbm = signalStrength.getEvdoDbm();
int cdmaDbm = signalStrength.getCdmaDbm();
// Use lowest signal to be conservative
mDevice.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
}
// Send it to signal tracker
signalStrengthTracker.registerSignalStrength(mDevice.mCell.getCID(), mDevice.getSignalDBm());
//signalStrengthTracker.isMysterious(mDevice.mCell.getCID(), mDevice.getSignalDBm());
}
示例2: d
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
public final int[] d() {
if (this.c == 0) {
return new int[0];
}
List<NeighboringCellInfo> neighboringCellInfo = this.q.getNeighboringCellInfo();
if (neighboringCellInfo == null || neighboringCellInfo.size() == 0) {
return new int[]{this.c};
}
Object obj = new int[((neighboringCellInfo.size() * 2) + 2)];
obj[0] = this.c;
obj[1] = this.a;
int i = 2;
for (NeighboringCellInfo neighboringCellInfo2 : neighboringCellInfo) {
int cid = neighboringCellInfo2.getCid();
if (cid > 0 && cid != SupportMenu.USER_MASK) {
int i2 = i + 1;
obj[i] = cid;
i = i2 + 1;
obj[i2] = neighboringCellInfo2.getRssi();
}
}
Object obj2 = new int[i];
System.arraycopy(obj, 0, obj2, 0, i);
return obj2;
}
示例3: call
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
if (isFakeLocationEnable()) {
List<VCell> cells = VirtualLocationManager.get().getNeighboringCell(getAppUserId(), getAppPkg());
if (cells != null) {
List<NeighboringCellInfo> infos = new ArrayList<>();
for (VCell cell : cells) {
NeighboringCellInfo info = new NeighboringCellInfo();
mirror.android.telephony.NeighboringCellInfo.mLac.set(info, cell.lac);
mirror.android.telephony.NeighboringCellInfo.mCid.set(info, cell.cid);
mirror.android.telephony.NeighboringCellInfo.mRssi.set(info, 6);
infos.add(info);
}
return infos;
}
}
return super.call(who, method, args);
}
示例4: removeDuplicatedNeighbors
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
private void removeDuplicatedNeighbors(List<NeighboringCellInfo> neighboringCells, Measurement measurement) {
List<NeighboringCellInfo> cellsToRemove = new ArrayList<NeighboringCellInfo>();
Set<String> uniqueCellKeys = new HashSet<String>();
uniqueCellKeys.add(createCellKey(measurement));
for (NeighboringCellInfo cell : neighboringCells) {
String key = createCellKey(cell, measurement);
if (uniqueCellKeys.contains(key)) {
Log.d("removeDuplicatedNeighbors(): Remove duplicated cell: %s", key);
cellsToRemove.add(cell);
} else {
uniqueCellKeys.add(key);
}
}
neighboringCells.removeAll(cellsToRemove);
}
示例5: setLastCellLocation
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
public synchronized void setLastCellLocation(CellLocation cellLocation, NetworkGroup networkType,
String operatorCode, String operatorName, List<NeighboringCellInfo> neighboringCells) {
Log.d("setLastCellLocation(): Cell location updated: %s, network type: %s, operator code: %s, operator name: %s", cellLocation, networkType, operatorCode, operatorName);
// check if any changes
boolean cellChanged = (!isCellLocationEqual(lastCellLocation, cellLocation)
|| lastNetworkType != networkType
|| !lastOperatorCode.equals(operatorCode)
|| !lastOperatorName.equals(operatorName));
// update last cell
this.lastCellLocation = cellLocation;
this.lastNetworkType = networkType;
this.lastOperatorCode = operatorCode;
this.lastOperatorName = operatorName;
this.neighboringCells = neighboringCells;
if (this.neighboringCells == null) {
this.neighboringCells = EMPTY_NEIGHBORING_CELL_LIST;
}
if (cellChanged) {
notifyIfReadyToProcess();
}
}
示例6: update
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
public void update(Measurement m, CellLocation cellLocation, int mcc, int mnc, NetworkGroup networkType) {
if (cellLocation instanceof GsmCellLocation) {
GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;
if (gsmCellLocation.getCid() <= 65535 && gsmCellLocation.getPsc() == NeighboringCellInfo.UNKNOWN_CID) {
m.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), NetworkGroup.Gsm);
} else {
// fix invalid network types (unfortunately not possible to distinguish between UMTS and LTE)
if (networkType == NetworkGroup.Gsm || networkType == NetworkGroup.Cdma)
networkType = NetworkGroup.Unknown;
int psc = gsmCellLocation.getPsc();
if (psc == NeighboringCellInfo.UNKNOWN_CID || psc == Measurement.UNKNOWN_CID) {
psc = Measurement.UNKNOWN_CID;
} else if (psc >= 504) {
// only UMTS networks support larger PSC
networkType = NetworkGroup.Wcdma;
}
m.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), psc, networkType);
}
} else if (cellLocation instanceof CdmaCellLocation) {
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;
m.setCdmaCellLocation(cdmaCellLocation.getSystemId(), cdmaCellLocation.getNetworkId(), cdmaCellLocation.getBaseStationId());
} else {
throw new UnsupportedOperationException("Cell location type not supported `" + cellLocation.getClass().getName() + "`");
}
}
示例7: onSignalStrengthsChanged
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
/**
* Description: TODO: add more info
*
* Issues:
*
* [ ] Getting and comparing signal strengths between different RATs can be very
* tricky, since they all return different ranges of values. AOS doesn't
* specify very clearly what exactly is returned, even though people have
* a good idea, by trial and error.
*
* See note in : SignalStrengthTracker.java
*/
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
// Update Signal Strength
if (signalStrength.isGsm()) {
int dbm;
if (signalStrength.getGsmSignalStrength() <= 2 ||
signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
// Unknown signal strength, get it another way
String[] bits = signalStrength.toString().split(" ");
dbm = Integer.parseInt(bits[9]);
} else {
dbm = signalStrength.getGsmSignalStrength();
}
device.setSignalDbm(dbm);
} else {
int evdoDbm = signalStrength.getEvdoDbm();
int cdmaDbm = signalStrength.getCdmaDbm();
// Use lowest signal to be conservative
device.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
}
// Send it to signal tracker
signalStrengthTracker.registerSignalStrength(device.cell.getCellId(), device.getSignalDBm());
//signalStrengthTracker.isMysterious(device.cell.getCid(), device.getSignalDBm());
}
示例8: updateNeighboringCells
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
private void updateNeighboringCells(){
/** Neighboring cells */
List<NeighboringCellInfo> neighboringCellInfo;
neighboringCellInfo = srvcTelephonyManager.getNeighboringCellInfo();
/** Fill the hash tables depending on the network type*/
for (NeighboringCellInfo i : neighboringCellInfo) {
int networktype=i.getNetworkType();
if ((networktype == TelephonyManager.NETWORK_TYPE_UMTS) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSDPA) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSUPA) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSPA))
//neighborsmapUMTS.put(i.getPsc(), i.getRssi()-115);
// Nexus 5 phone gives the actual rsrp instead of index level of CPICH
neighborsmapUMTS.put(i.getPsc(), i.getRssi());
else
neighborsmapGSM.put(i.getLac()+"-"+i.getCid(), (-113+2*(i.getRssi())));
}
}
示例9: CellIdPre17API
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
public CellIdPre17API(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCellInfoList) {
if (DEBUG) Log.d(TAG, "CellIdPre17API:");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
fallback_pre17api = true;
}
this.cellLocation = cellLocation;
this.neighboringCellInfoList = neighboringCellInfoList;
if (cellLocation != null) {
this.i = -1;
} else {
this.i = 0;
}
String mccmnc = telephonyManager.getNetworkOperator();
if (mccmnc != null && mccmnc.length() >= 5 && mccmnc.length() <= 6) {
mcc = Integer.parseInt(mccmnc.substring(0, 3));
mnc = Integer.parseInt(mccmnc.substring(3));
} else {
Log.e(TAG, "CellIdPre17API: wrong legnth (5-6) for mccmnc=" + mccmnc);
}
type = telephonyManager.getNetworkType();
if (DEBUG)
Log.d(TAG, "CellIdPre17API: mcc=" + mcc + ", mnc=" + mnc + ", type=" + type + " cellLocation=" + cellLocation + ", neighboringCellInfoList=" + neighboringCellInfoList);
}
示例10: 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);
}
}
示例11: CellIdPre17API
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
public CellIdPre17API(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCellInfoList) {
if (DEBUG) Log.d(TAG, "CellIdPre17API:");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
this.fallback_pre17api = true;
}
this.cellLocation = cellLocation;
this.neighboringCellInfoList = neighboringCellInfoList;
if (cellLocation != null) {
this.i = -1;
}
else {
this.i = 0;
}
String mccmnc = telephonyManager.getNetworkOperator();
if (mccmnc != null && mccmnc.length() >= 5 && mccmnc.length() <= 6) {
mcc = Integer.parseInt(mccmnc.substring(0, 3));
mnc = Integer.parseInt(mccmnc.substring(3));
}
else {
Log.e(TAG, "CellIdPre17API: wrong legnth (5-6) for mccmnc=" + mccmnc);
}
type = telephonyManager.getNetworkType();
if (DEBUG) Log.d(TAG, "CellIdPre17API: mcc=" + mcc + ", mnc=" + mnc + ", type=" + type + " cellLocation=" + cellLocation + ", neighboringCellInfoList=" + neighboringCellInfoList);
}
示例12: 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);
}
}
}
示例13: handle
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
/**
* Handle a modem event by trying to pull all information. The parameter inc defines if the
* measurement counter should be increased on success.
* @param inc True if the measurement counter should be increased.
*/
private void handle(boolean inc) {
if (telephonyManager == null) return;
final List<android.telephony.CellInfo> cellInfos = telephonyManager.getAllCellInfo();
final List<NeighboringCellInfo> neighbours = telephonyManager.getNeighboringCellInfo();
final CellLocation cellLocation = telephonyManager.getCellLocation();
if (cellInfos == null || cellInfos.isEmpty()) {
if (neighbours == null || neighbours.isEmpty()) {
if (cellLocation == null || !(cellLocation instanceof GsmCellLocation)) return;
}
}
if (inc) measurement.getAndIncrement();
add(cellLocation);
addNeighbours(neighbours);
addCells(cellInfos);
synchronized (recentCells) {
cleanup();
}
}
示例14: updateNeighboringCells
import android.telephony.NeighboringCellInfo; //導入依賴的package包/類
private void updateNeighboringCells(){
/** Neighboring cells */
List<NeighboringCellInfo> neighboringCellInfo;
neighboringCellInfo = srvcTelephonyManager.getNeighboringCellInfo();
/** Fill the hash tables depending on the network type*/
for (NeighboringCellInfo i : neighboringCellInfo) {
int networktype=i.getNetworkType();
if ((networktype == TelephonyManager.NETWORK_TYPE_UMTS) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSDPA) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSUPA) ||
(networktype == TelephonyManager.NETWORK_TYPE_HSPA))
neighborsmapUMTS.put(i.getPsc(), i.getRssi()-115);
else
neighborsmapGSM.put(i.getLac()+"-"+i.getCid(), (-113+2*(i.getRssi())));
}
}
示例15: 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;
}
}