本文整理汇总了Java中android.telephony.CellIdentityLte类的典型用法代码示例。如果您正苦于以下问题:Java CellIdentityLte类的具体用法?Java CellIdentityLte怎么用?Java CellIdentityLte使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CellIdentityLte类属于android.telephony包,在下文中一共展示了CellIdentityLte类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCellInfo
import android.telephony.CellIdentityLte; //导入依赖的package包/类
public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
int lCurrentApiVersion = android.os.Build.VERSION.SDK_INT;
try {
if (pDevice.mCell == null) {
pDevice.mCell = new Cell();
}
List<CellInfo> cellInfoList = tm.getAllCellInfo();
if (cellInfoList != null) {
for (final CellInfo info : cellInfoList) {
//Network Type
pDevice.mCell.setNetType(tm.getNetworkType());
if (info instanceof CellInfoGsm) {
final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
// Signal Strength
pDevice.mCell.setDBM(gsm.getDbm()); // [dBm]
// Cell Identity
pDevice.mCell.setCID(identityGsm.getCid());
pDevice.mCell.setMCC(identityGsm.getMcc());
pDevice.mCell.setMNC(identityGsm.getMnc());
pDevice.mCell.setLAC(identityGsm.getLac());
} else if (info instanceof CellInfoCdma) {
final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity();
// Signal Strength
pDevice.mCell.setDBM(cdma.getDbm());
// Cell Identity
pDevice.mCell.setCID(identityCdma.getBasestationId());
pDevice.mCell.setMNC(identityCdma.getSystemId());
pDevice.mCell.setLAC(identityCdma.getNetworkId());
pDevice.mCell.setSID(identityCdma.getSystemId());
} else if (info instanceof CellInfoLte) {
final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
// Signal Strength
pDevice.mCell.setDBM(lte.getDbm());
pDevice.mCell.setTimingAdvance(lte.getTimingAdvance());
// Cell Identity
pDevice.mCell.setMCC(identityLte.getMcc());
pDevice.mCell.setMNC(identityLte.getMnc());
pDevice.mCell.setCID(identityLte.getCi());
} else if (lCurrentApiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2 && info instanceof CellInfoWcdma) {
final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength();
final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info).getCellIdentity();
// Signal Strength
pDevice.mCell.setDBM(wcdma.getDbm());
// Cell Identity
pDevice.mCell.setLAC(identityWcdma.getLac());
pDevice.mCell.setMCC(identityWcdma.getMcc());
pDevice.mCell.setMNC(identityWcdma.getMnc());
pDevice.mCell.setCID(identityWcdma.getCid());
pDevice.mCell.setPSC(identityWcdma.getPsc());
} else {
Log.i(TAG, mTAG + "Unknown type of cell signal!"
+ "\n ClassName: " + info.getClass().getSimpleName()
+ "\n ToString: " + info.toString());
}
if (pDevice.mCell.isValid()) {
break;
}
}
}
} catch (NullPointerException npe) {
Log.e(TAG, mTAG + "loadCellInfo: Unable to obtain cell signal information: ", npe);
}
}
示例2: toCellularInfo
import android.telephony.CellIdentityLte; //导入依赖的package包/类
private static CommonCellInfo toCellularInfo(CellInfoLte cellInfo) {
CommonCellInfo res = new CommonCellInfo();
CellIdentityLte identityLte = cellInfo.getCellIdentity();
CellSignalStrength signalStrength = cellInfo.getCellSignalStrength();
res.setType(LTE);
res.setCid(identityLte.getCi());
res.setLac(identityLte.getTac());
res.setMcc(identityLte.getMcc());
res.setMnc(identityLte.getMnc());
res.setDbm(valdiateDbm(signalStrength.getDbm()));
res.setLevel(signalStrength.getLevel());
return res;
}
示例3: fill
import android.telephony.CellIdentityLte; //导入依赖的package包/类
public static void fill(TheDictionary map, CellIdentityLte value) throws Exception {
if (value != null) {
map.put("type", "4");
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.getTac();
if (i != Integer.MAX_VALUE && i > 0) map.put("tac", i);
i = value.getPci();
if (i != Integer.MAX_VALUE && i > 0) map.put("pci", i);
i = value.getCi();
if (i != Integer.MAX_VALUE && i > 0) map.put("cid", i);
}
}
示例4: getCellInfo
import android.telephony.CellIdentityLte; //导入依赖的package包/类
/**
* Get current cell info
*
* @return cell information format as {@link String}
*/
public String getCellInfo() {
if (DBG)
Log.d(Config.TAG, TAG + "getCellInfo called");
String ret = null;
List<CellInfo> listCellInfo = mTelMgr.getAllCellInfo();
if (listCellInfo != null)
for (CellInfo a_Info : listCellInfo) {
if (CellInfoCdma.class.isInstance(a_Info))
ret = ret + "\n Cell info cdma: " + a_Info.toString();
else if (CellInfoGsm.class.isInstance(a_Info))
ret = ret + "\n Cell info gsm: " + a_Info.toString();
else if (CellInfoLte.class.isInstance(a_Info)) {
ret = ret + "\n Cell info lte: " + a_Info.toString();
CellInfoLte cellInfoLte = (CellInfoLte) a_Info;
CellIdentityLte cellIdentity = cellInfoLte
.getCellIdentity();
Log.d(Config.TAG, TAG + " LTE - " + cellIdentity.getCi()
+ cellIdentity.getTac() + cellIdentity.getPci());
} else if (CellInfoWcdma.class.isInstance(a_Info))
ret = ret + "\n Cell info : wcdma" + a_Info.toString();
}
return ret;
}
示例5: CellIdentity
import android.telephony.CellIdentityLte; //导入依赖的package包/类
public CellIdentity(CellIdentityLte cellIdentity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
this.setChannelNumber(cellIdentity.getEarfcn());
}
this.setMnc(cellIdentity.getMnc());
this.setMcc(cellIdentity.getMcc());
this.setLocationId(cellIdentity.getTac());
this.setAreaCode(cellIdentity.getCi());
this.setScramblingCode(cellIdentity.getPci());
}
示例6: getEarfcn
import android.telephony.CellIdentityLte; //导入依赖的package包/类
@TargetApi(24)
public void getEarfcn(WritableMap mapCellIdentity, CellIdentityLte cellIdentity) {
if (android.os.Build.VERSION.SDK_INT >= 24){
// Do something for nougat and above versions
mapCellIdentity.putInt("earfcn", cellIdentity.getEarfcn());
} else{
// do something for phones running an SDK before lollipop
mapCellIdentity.putInt("earfcn", 0);
}
}
示例7: cellInfoLTEJSON
import android.telephony.CellIdentityLte; //导入依赖的package包/类
/**
* Converts CellInfoLte into JSON
* @param cellInfo CellInfoLte
* @return JSON
*/
public static String cellInfoLTEJSON(CellInfoLte cellInfo, boolean returnSignalStrength){
final Calendar calendar = Calendar.getInstance();
final JSONObject json = new JSONObject();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo != null) {
try {
json.put("provider", CELLINFO_PROVIDER);
json.put("type", LTE);
json.put("timestamp", calendar.getTimeInMillis());
final CellIdentityLte identityLte = cellInfo.getCellIdentity();
json.put("ci", identityLte.getCi());
json.put("mcc", identityLte.getMcc());
json.put("mnc", identityLte.getMnc());
json.put("pci", identityLte.getPci());
json.put("tac", identityLte.getTac());
if (returnSignalStrength){
final JSONObject jsonSignalStrength = new JSONObject();
final CellSignalStrengthLte cellSignalStrengthLte = cellInfo.getCellSignalStrength();
jsonSignalStrength.put("asuLevel", cellSignalStrengthLte.getAsuLevel());
jsonSignalStrength.put("dbm", cellSignalStrengthLte.getDbm());
jsonSignalStrength.put("level", cellSignalStrengthLte.getLevel());
jsonSignalStrength.put("timingAdvance", cellSignalStrengthLte.getTimingAdvance());
json.put("cellSignalStrengthLte", jsonSignalStrength);
}
}
catch(JSONException exc) {
logJSONException(exc);
}
}
return json.toString();
}
示例8: type
import android.telephony.CellIdentityLte; //导入依赖的package包/类
public static SubjectFactory<CellIdentityLteSubject, CellIdentityLte> type() {
return new SubjectFactory<CellIdentityLteSubject, CellIdentityLte>() {
@Override
public CellIdentityLteSubject getSubject(FailureStrategy fs, CellIdentityLte that) {
return new CellIdentityLteSubject(fs, that);
}
};
}
示例9: isValid
import android.telephony.CellIdentityLte; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public boolean isValid(CellIdentityLte cell) {
boolean valid = (isCiInRange(cell.getCi()) && isTacInRange(cell.getTac())
&& isMncInRange(cell.getMnc()) && isMccInRange(cell.getMcc())
&& isPciInRange(cell.getPci()));
if (!valid) {
Log.w("isValid(): Invalid CellIdentityLte [mcc=%s, mnc=%s, lac=%s, cid=%s, psc=%s]", cell.getMcc(), cell.getMnc(), cell.getTac(), cell.getCi(), cell.getPci());
Log.w("isValid(): Invalid CellIdentityLte %s", cell);
}
return valid;
}
示例10: getCellularInfo
import android.telephony.CellIdentityLte; //导入依赖的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;
}
示例11: isValidLteCell
import android.telephony.CellIdentityLte; //导入依赖的package包/类
/**
* A valid LTE cell must have cell id set
* @param cdmaLocation {@link CdmaCellLocation}
* @return true if valid cdma id
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private boolean isValidLteCell(final CellIdentityLte lteInfo) {
if (lteInfo == null) {
return false;
}
final Integer cid = lteInfo.getCi();
return ((cid > -1) && (cid < Integer.MAX_VALUE));
}
示例12: isValidLteCell
import android.telephony.CellIdentityLte; //导入依赖的package包/类
/**
* A valid LTE cell must have cell id set
*
* @param lteInfo {@link CellIdentityLte}
* @return true if valid cdma id
*/
@TargetApi(JELLY_BEAN_MR2)
private boolean isValidLteCell(final CellIdentityLte lteInfo) {
if (lteInfo == null) {
return false;
}
final Integer cid = lteInfo.getCi();
return ((cid > -1) && (cid < Integer.MAX_VALUE));
}
示例13: fill
import android.telephony.CellIdentityLte; //导入依赖的package包/类
public static void fill(TheDictionary map, CellIdentityLte value) throws Exception {
if (value != null) {
map.put("type", "4");
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.getTac(); if (i != Integer.MAX_VALUE && i > 0) map.put("tac", i);
i = value.getPci(); if (i != Integer.MAX_VALUE && i > 0) map.put("pci", i);
i = value.getCi(); if (i != Integer.MAX_VALUE && i > 0) map.put("ci", i);
}
}
示例14: hasCellIdentity
import android.telephony.CellIdentityLte; //导入依赖的package包/类
public CellInfoLteAssert hasCellIdentity(CellIdentityLte cellIdentity) {
isNotNull();
CellIdentityLte actualCellIdentity = actual.getCellIdentity();
assertThat(actualCellIdentity) //
.overridingErrorMessage("Expected cell identity <%s> but was <%s>.", cellIdentity, actualCellIdentity) //
.isEqualTo(cellIdentity);
return this;
}
示例15: hasCellIdentity
import android.telephony.CellIdentityLte; //导入依赖的package包/类
public CellInfoLteSubject hasCellIdentity(CellIdentityLte cellIdentity) {
assertThat(actual().getCellIdentity())
.named("cell identity")
.isEqualTo(cellIdentity);
return this;
}