本文整理汇总了Java中android.telephony.gsm.GsmCellLocation.getCid方法的典型用法代码示例。如果您正苦于以下问题:Java GsmCellLocation.getCid方法的具体用法?Java GsmCellLocation.getCid怎么用?Java GsmCellLocation.getCid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.gsm.GsmCellLocation
的用法示例。
在下文中一共展示了GsmCellLocation.getCid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIpBaseStation
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
public static String getIpBaseStation() {
TelephonyManager telMgr = (TelephonyManager) FDApplication
.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
int cid = 0;
int lac = 0;
try {
if (telMgr != null) {
GsmCellLocation gc = (GsmCellLocation) telMgr.getCellLocation();
if (null == gc) {
return "0_0";
}
cid = gc.getCid();
lac = gc.getLac();
}
} catch (Exception e) {
if (telMgr != null) {
CdmaCellLocation location = (CdmaCellLocation) telMgr
.getCellLocation();
if (null == location) {
return "0_0";
}
lac = location.getNetworkId();
cid = location.getBaseStationId();
cid /= 16;
}
}
return lac + "_" + cid;
}
示例2: getNewCellInfo
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
public CellInfo getNewCellInfo() {
try {
TelephonyManager tm = (TelephonyManager) CellService.get().getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();
/* Why I use this Bitmask:
* https://stackoverflow.com/questions/9808396/android-cellid-not-available-on-all-carriers#12969638
*/
int cellID = location.getCid();// & 0xffff;
int lac = location.getLac();
String networkOperator = tm.getNetworkOperator();
int mcc = Integer.parseInt(networkOperator.substring(0, 3));
int mnc = Integer.parseInt(networkOperator.substring(3));
return new CellInfo(cellID, lac, mnc, mcc, tm.getNetworkType());
} catch (Exception e) {
return new FakeCellInfo();
}
}
示例3: isCellLocationEqual
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的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.gsm.GsmCellLocation; //导入方法依赖的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: ay
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的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;
}
}
}
示例6: sendGsmBrodcat
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的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);
}
}
示例7: getCellId
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
/**
* {link http://www.devx.com/wireless/Article/40524/0/page/2}
*/
private int[] getCellId() {
int[] cellId = new int[0];
CellLocation cellLoc = telephonyManager.getCellLocation();
if (cellLoc != null && (cellLoc instanceof GsmCellLocation)) {
GsmCellLocation gsmLoc = (GsmCellLocation) cellLoc;
gsmLoc.getPsc();
// gsm cell id
int cid = gsmLoc.getCid();
// gsm location area code
int lac = gsmLoc.getLac();
// On a UMTS network, returns the primary scrambling code of the
// serving cell.
int psc = gsmLoc.getPsc();
Log.d(TAG, String.format("Cell Id : %s / Lac : %s / Psc : %s", cid, lac, psc));
if (psc > -1) {
cellId = new int[3];
cellId[2] = psc;
} else {
cellId = new int[2];
}
cellId[0] = cid;
cellId[1] = lac;
}
return cellId;
}
示例8: getCurrentLocation
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
public static void getCurrentLocation(Context context) {
TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// 返回值MCC + MNC
String operator = mTelephonyManager.getNetworkOperator();
int mcc = Integer.parseInt(operator.substring(0, 3));
int mnc = Integer.parseInt(operator.substring(3));
Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t");
// 中国移动和中国联通获取LAC、CID的方式
GsmCellLocation location = (GsmCellLocation) mTelephonyManager.getCellLocation();
int lac = location.getLac();
int cellId = location.getCid();
// 中国电信获取LAC、CID的方式
CdmaCellLocation location1 = (CdmaCellLocation) mTelephonyManager.getCellLocation();
lac = location1.getNetworkId();
cellId = location1.getBaseStationId();
cellId /= 16;
Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t LAC = " + lac + "\t CID = " + cellId);
// 获取邻区基站信息
List<NeighboringCellInfo> infos = mTelephonyManager.getNeighboringCellInfo();
StringBuffer sb = new StringBuffer("总数 : " + infos.size() + "\n");
for (NeighboringCellInfo info1 : infos) { // 根据邻区总数进行循环
sb.append(" LAC : " + info1.getLac()); // 取出当前邻区的LAC
sb.append(" CID : " + info1.getCid()); // 取出当前邻区的CID
sb.append(" BSSS : " + (-113 + 2 * info1.getRssi()) + "\n"); // 获取邻区基站信号强度
}
Log.i(TAG, " 获取邻区基站信息:" + sb.toString());
}
示例9: getCellInfo
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
public static CellInfo getCellInfo(Context context) {
CellInfo cellInfo = new CellInfo();
TelephonyManager manager = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
String netOperator = manager.getNetworkOperator();
// Fix crash when not connected to network (airplane mode, underground,
// etc)
if (netOperator == null || netOperator.length() < 3) {
return cellInfo;
}
/*
* FIXME: Actually check for mobile network status == connected before
* doing this stuff.
*/
if (Phone.getType(context).equals(PHONE_TYPE_CDMA)) {
CdmaCellLocation cdmaLocation = (CdmaCellLocation) manager.getCellLocation();
cellInfo.cid = cdmaLocation.getBaseStationId();
cellInfo.lac = cdmaLocation.getNetworkId();
cellInfo.mnc = cdmaLocation.getSystemId();
cellInfo.mcc = Integer.parseInt(netOperator.substring(0, 3));
cellInfo.radioType = Network.getMobileNetworkType(context);
} else if (Phone.getType(context).equals(PHONE_TYPE_GSM)) {
GsmCellLocation gsmLocation = (GsmCellLocation) manager.getCellLocation();
cellInfo.mcc = Integer.parseInt(netOperator.substring(0, 3));
cellInfo.mnc = Integer.parseInt(netOperator.substring(3));
cellInfo.lac = gsmLocation.getLac();
cellInfo.cid = gsmLocation.getCid();
cellInfo.radioType = Network.getMobileNetworkType(context);
}
return cellInfo;
}
示例10: isValidGsmCell
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的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 gsmLocation {@link GsmCellLocation}
* @return true if valid gsm cell
*/
private boolean isValidGsmCell(final GsmCellLocation gsmLocation) {
if (gsmLocation == null) {
return false;
}
final Integer cid = gsmLocation.getCid();
return (cid > 0 && cid != Integer.MAX_VALUE);
}
示例11: getCellID
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
public static int getCellID(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager
.getCellLocation();
int cellID = cellLocation.getCid();
return cellID;
}
示例12: getCellLocation
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
private void getCellLocation(CellLocation location) {
if (location!=null) {
if (Permissions.checkLocation(context.getApplicationContext())) {
if (location instanceof GsmCellLocation) {
GsmCellLocation gcLoc = (GsmCellLocation) location;
//PPApplication.logE("PhoneStateScanner.getCellLocation", "gsm location="+gcLoc);
if (gcLoc.getCid() != -1) {
//PPApplication.logE("PhoneStateScanner.getCellLocation", "gsm mCid="+gcLoc.getCid());
registeredCell = gcLoc.getCid();
lastConnectedTime = Calendar.getInstance().getTimeInMillis();
}
} else if (location instanceof CdmaCellLocation) {
CdmaCellLocation ccLoc = (CdmaCellLocation) location;
//PPApplication.logE("PhoneStateScanner.getCellLocation", "cdma location="+ccLoc);
if (ccLoc.getBaseStationId() != -1) {
//PPApplication.logE("PhoneStateScanner.getCellLocation", "cdma mCid="+ccLoc.getBaseStationId());
registeredCell = ccLoc.getBaseStationId();
lastConnectedTime = Calendar.getInstance().getTimeInMillis();
}
}
//else {
// PPApplication.logE("PhoneStateScanner.getCellLocation", "unknown location="+location);
//}
PPApplication.logE("PhoneStateScanner.getCellLocation", "registeredCell=" + registeredCell);
}
}
else
PPApplication.logE("PhoneStateScanner.getCellLocation", "location is null");
}
示例13: isValidGsmCell
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的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 gsmLocation {@link GsmCellLocation}
* @return true if valid gsm cell
*/
private boolean isValidGsmCell(final GsmCellLocation gsmLocation) {
if (gsmLocation == null) {
return false;
}
final Integer cid = gsmLocation.getCid();
return (cid > 0 && cid != Integer.MAX_VALUE);
}
示例14: getNetworkState
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
/**
* Retrieves network info data. *
*
* @return Current network info data.
*/
public static NetworkState getNetworkState(Context context) {
NetworkState callInfoData = null;
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation location = (GsmCellLocation) telephonyManager.getCellLocation();
String mcc = "0";
String mnc = "0";
String networkOperator = telephonyManager.getNetworkOperator();
if (networkOperator != null && networkOperator.length() > 0) {
mcc = telephonyManager.getNetworkOperator().substring(0, 3);
mnc = telephonyManager.getNetworkOperator().substring(3);
}
int[] neighborCellId;
int[] neighborCellRssi;
List<NeighboringCellInfo> neighboringList = telephonyManager.getNeighboringCellInfo();
if (neighboringList != null && !neighboringList.isEmpty()) {
neighborCellId = new int[neighboringList.size()];
neighborCellRssi = new int[neighboringList.size()];
for (int i = 0; i < neighboringList.size(); i++) {
neighborCellRssi[i] = neighboringList.get(i).getRssi();
neighborCellId[i] = neighboringList.get(i).getCid();
}
} else {
neighborCellId = new int[] { -1 };
neighborCellRssi = new int[] { -1 };
}
callInfoData = new NetworkState(System.currentTimeMillis(), (location != null) ? location.getCid() : 0, /* rssi, dbm, asu, */0, 0, 0,
mcc, mnc, (location != null) ? location.getLac() : 0, NetworkUtils.isInRoaming(context),
NetworkUtils.getDataConnectionState(context), NetworkUtils.getSimState(context), NetworkUtils.getNetworkType(context),
NetworkUtils.isWiFiEnabled(context), neighborCellId, neighborCellRssi);
} catch (final Exception e) {
Logger.logApplicationException(e, NetworkUtils.class.getSimpleName() + ".getNetworkInfoData(): Failed.");
e.printStackTrace();
}
return callInfoData;
}
示例15: y
import android.telephony.gsm.GsmCellLocation; //导入方法依赖的package包/类
protected static String y(Context paramContext)
{
TelephonyManager localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
if (localTelephonyManager.getPhoneType() == 1)
{
GsmCellLocation localGsmCellLocation = (GsmCellLocation)localTelephonyManager.getCellLocation();
if (localGsmCellLocation != null)
return localGsmCellLocation.getCid() + "";
}
return "-1";
}