本文整理汇总了Java中android.telephony.CellLocation类的典型用法代码示例。如果您正苦于以下问题:Java CellLocation类的具体用法?Java CellLocation怎么用?Java CellLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CellLocation类属于android.telephony包,在下文中一共展示了CellLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: e
import android.telephony.CellLocation; //导入依赖的package包/类
public final void e() {
if (this.p == 1) {
CellLocation.requestLocationUpdate();
this.p = 2;
this.l.sendEmptyMessage(1);
if (this.s.b().isWifiEnabled()) {
this.s.b().startScan();
this.r = false;
} else if (this.e) {
this.o = System.currentTimeMillis();
if (c && this.s.b().setWifiEnabled(true)) {
this.r = true;
} else {
this.l.sendEmptyMessageDelayed(5, 8000);
}
} else {
this.l.sendEmptyMessageDelayed(5, 0);
}
}
}
示例2: setLastCellLocation
import android.telephony.CellLocation; //导入依赖的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();
}
}
示例3: isCellLocationEqual
import android.telephony.CellLocation; //导入依赖的package包/类
private boolean isCellLocationEqual(CellLocation cl1, CellLocation cl2) {
boolean result;
if (cl1 instanceof GsmCellLocation && cl2 instanceof GsmCellLocation) {
GsmCellLocation gsm1 = (GsmCellLocation) cl1;
GsmCellLocation gsm2 = (GsmCellLocation) cl2;
result = (gsm1.getCid() == gsm2.getCid()
&& gsm1.getLac() == gsm2.getLac()
&& gsm1.getPsc() == gsm2.getPsc());
Log.d("isCellLocationEqual(): GSM equals = %s", result);
} else if (cl1 instanceof CdmaCellLocation && cl2 instanceof CdmaCellLocation) {
CdmaCellLocation cdma1 = (CdmaCellLocation) cl1;
CdmaCellLocation cdma2 = (CdmaCellLocation) cl2;
result = (cdma1.getBaseStationId() == cdma2.getBaseStationId()
&& cdma1.getNetworkId() == cdma2.getNetworkId()
&& cdma1.getSystemId() == cdma2.getSystemId());
Log.d("isCellLocationEqual(): CDMA equal = %s", result);
} else {
// different types or nulls
result = false;
Log.d("isCellLocationEqual(): Different types or nulls");
}
return result;
}
示例4: update
import android.telephony.CellLocation; //导入依赖的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() + "`");
}
}
示例5: fromCellLocation
import android.telephony.CellLocation; //导入依赖的package包/类
static CellLocationSingleData fromCellLocation(CellLocation location) {
int cid, lac;
if (location != null) {
if (location instanceof GsmCellLocation) {
cid = ((GsmCellLocation) location).getCid();
lac = ((GsmCellLocation) location).getLac();
}
else if (location instanceof CdmaCellLocation) {
cid = ((CdmaCellLocation) location).getBaseStationId();
lac = ((CdmaCellLocation) location).getSystemId();
} else {
return null;
}
return new CellLocationSingleData(cid, lac);
}
return null;
}
示例6: onCellLocationChanged
import android.telephony.CellLocation; //导入依赖的package包/类
/**
* When the cell location gets changed, the new cellId is added to the cell id buffer in the
* owner. At the same time, the CELLCHANGE event is stored.
*/
@Override
public void onCellLocationChanged(CellLocation location) {
super.onCellLocationChanged(location);
try {
checkCDMACellSID (location);
processNewCellLocation(new CellLocationEx(location));
// See if this cellLocation has inner GsmLocation
checkInnerGsmCellLocation (location);
LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "onCellLocationChanged", location.toString());
} catch (InterruptedException intEx){
LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onCellLocationChanged", "InterruptedException: " + intEx.getMessage());
}
catch (Exception ex){
String err = ex.toString();
LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "onCellLocationChanged", "InterruptedException: " + err);
}
}
示例7: getLastCellLocation
import android.telephony.CellLocation; //导入依赖的package包/类
public CellLocationEx getLastCellLocation(){
if (mPhoneState.lastKnownMMCCellLocation != null)
return mPhoneState.lastKnownMMCCellLocation;
CellLocation cellLoc = telephonyManager.getCellLocation();
if (cellLoc != null)
{
LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "getLastCellLocation", "null cell, getCellLocation() = " + cellLoc.toString());
CellLocationEx mmcCell = new CellLocationEx(cellLoc);
try {
processNewCellLocation(mmcCell);
} catch (InterruptedException e) {
}
return mmcCell;
}
LoggerUtil.logToFile(LoggerUtil.Level.DEBUG, TAG, "getLastCellLocation", "null cell, getCellLocation() = null");
return null;
}
示例8: CellidSample
import android.telephony.CellLocation; //导入依赖的package包/类
public CellidSample (CellLocation cell)
{
CellLocationEx mmcCell = new CellLocationEx(cell);
timestamp = System.currentTimeMillis();
val1 = mmcCell.getBSHigh();
val2 = mmcCell.getBSLow();
//
// if (telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA && mmcCell instanceof CdmaCellLocation)
// {
// lac = ((CdmaCellLocation)mmcCell).getSystemId();
// cid = ((CdmaCellLocation)mmcCell).getBaseStationId();
// }
// else if (mmcCell instanceof GsmCellLocation)
// {
// lac = ((GsmCellLocation)mmcCell).getLac();
// cid = ((GsmCellLocation)mmcCell).getCid();
// }
}
示例9: onCellLocationChanged
import android.telephony.CellLocation; //导入依赖的package包/类
@Override
public void onCellLocationChanged (CellLocation location) {
super.onCellLocationChanged(location);
PPApplication.logE("PhoneStateScanner.onCellLocationChanged", "telephonyManager="+telephonyManager);
CallsCounter.logCounter(context, "PhoneStateScanner.onCellLocationChanged", "PhoneStateScanner_onCellLocationChanged");
if (location == null)
getCellLocation();
else
getCellLocation(location);
if (registeredCell != Integer.MAX_VALUE) {
DatabaseHandler db = DatabaseHandler.getInstance(context);
db.updateMobileCellLastConnectedTime(registeredCell, lastConnectedTime);
}
doAutoRegistration();
sendBroadcast();
}
示例10: CellIdPre17API
import android.telephony.CellLocation; //导入依赖的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);
}
示例11: ay
import android.telephony.CellLocation; //导入依赖的package包/类
ay(CellLocation celllocation)
{
a = 0x7fffffff;
b = 0x7fffffff;
c = 0x7fffffff;
d = 0x7fffffff;
e = 0x7fffffff;
if (celllocation != null)
{
if (celllocation instanceof GsmCellLocation)
{
GsmCellLocation gsmcelllocation = (GsmCellLocation)celllocation;
e = gsmcelllocation.getCid();
d = gsmcelllocation.getLac();
} else
if (celllocation instanceof CdmaCellLocation)
{
CdmaCellLocation cdmacelllocation = (CdmaCellLocation)celllocation;
c = cdmacelllocation.getBaseStationId();
b = cdmacelllocation.getNetworkId();
a = cdmacelllocation.getSystemId();
return;
}
}
}
示例12: CellIdPre17API
import android.telephony.CellLocation; //导入依赖的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);
}
示例13: handle
import android.telephony.CellLocation; //导入依赖的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: startTracking
import android.telephony.CellLocation; //导入依赖的package包/类
public void startTracking() {
mTelephonyManager = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
mListener = new PhoneStateListener() {
public void onCellLocationChanged(CellLocation location) {
Log.d(TAG, "Cell Location changed!");
getCellNetworkInfo();
}
// public void onServiceStateChanged(ServiceState s){
// Log.d(TAG, "Service State changed!");
// getServiceStateInfo(s);
// }
};
mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_CELL_LOCATION);
mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
示例15: sendGsmBrodcat
import android.telephony.CellLocation; //导入依赖的package包/类
private void sendGsmBrodcat(CellLocation location) {
Log.d(TAG, "onCellLocationChanged : " + location);
if (location instanceof GsmCellLocation) {
String networkOperator = telephonyManager.getNetworkOperator();
if (networkOperator != null) {
// Mobile Country Code
int mcc = Integer.parseInt(networkOperator.substring(0, 3));
// Mobile Network Code
int mnc = Integer.parseInt(networkOperator.substring(3));
Log.d(TAG, String.format("networkOperator mcc=%s / mnc=%s", mcc, mnc));
}
GsmCellLocation gsmLocation = (GsmCellLocation)location;
int cid = gsmLocation.getCid();
int lac = gsmLocation.getLac();
sendGsmBrodcat(cid, lac);
}
}