use of android.telephony.CellIdentityGsm in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class DeviceApi18 method loadCellInfo.
public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
int lCurrentApiVersion = Build.VERSION.SDK_INT;
try {
if (pDevice.cell == null) {
pDevice.cell = new Cell();
}
List<CellInfo> cellInfoList = tm.getAllCellInfo();
if (cellInfoList != null) {
for (final CellInfo info : cellInfoList) {
// Network Type
pDevice.cell.setNetType(tm.getNetworkType());
if (info instanceof CellInfoGsm) {
final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
// Signal Strength
// [dBm]
pDevice.cell.setDbm(gsm.getDbm());
// Cell Identity
pDevice.cell.setCellId(identityGsm.getCid());
pDevice.cell.setMobileCountryCode(identityGsm.getMcc());
pDevice.cell.setMobileNetworkCode(identityGsm.getMnc());
pDevice.cell.setLocationAreaCode(identityGsm.getLac());
} else if (info instanceof CellInfoCdma) {
final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity();
// Signal Strength
pDevice.cell.setDbm(cdma.getDbm());
// Cell Identity
pDevice.cell.setCellId(identityCdma.getBasestationId());
pDevice.cell.setMobileNetworkCode(identityCdma.getSystemId());
pDevice.cell.setLocationAreaCode(identityCdma.getNetworkId());
pDevice.cell.setSid(identityCdma.getSystemId());
} else if (info instanceof CellInfoLte) {
final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
// Signal Strength
pDevice.cell.setDbm(lte.getDbm());
pDevice.cell.setTimingAdvance(lte.getTimingAdvance());
// Cell Identity
pDevice.cell.setMobileCountryCode(identityLte.getMcc());
pDevice.cell.setMobileNetworkCode(identityLte.getMnc());
pDevice.cell.setCellId(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.cell.setDbm(wcdma.getDbm());
// Cell Identity
pDevice.cell.setLocationAreaCode(identityWcdma.getLac());
pDevice.cell.setMobileCountryCode(identityWcdma.getMcc());
pDevice.cell.setMobileNetworkCode(identityWcdma.getMnc());
pDevice.cell.setCellId(identityWcdma.getCid());
pDevice.cell.setPrimaryScramblingCode(identityWcdma.getPsc());
} else {
log.info("Unknown type of cell signal!" + "\n ClassName: " + info.getClass().getSimpleName() + "\n ToString: " + info.toString());
}
if (pDevice.cell.isValid()) {
break;
}
}
}
} catch (NullPointerException npe) {
log.error("loadCellInfo: Unable to obtain cell signal information: ", npe);
}
}
use of android.telephony.CellIdentityGsm in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class DeviceApi17 method loadCellInfo.
public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
int lCurrentApiVersion = Build.VERSION.SDK_INT;
try {
if (pDevice.cell == null) {
pDevice.cell = new Cell();
}
List<CellInfo> cellInfoList = tm.getAllCellInfo();
if (cellInfoList != null) {
for (final CellInfo info : cellInfoList) {
// Network Type
pDevice.cell.setNetType(tm.getNetworkType());
if (info instanceof CellInfoGsm) {
final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
// Signal Strength
// [dBm]
pDevice.cell.setDbm(gsm.getDbm());
// Cell Identity
pDevice.cell.setCellId(identityGsm.getCid());
pDevice.cell.setMobileCountryCode(identityGsm.getMcc());
pDevice.cell.setMobileNetworkCode(identityGsm.getMnc());
pDevice.cell.setLocationAreaCode(identityGsm.getLac());
} else if (info instanceof CellInfoCdma) {
final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity();
// Signal Strength
pDevice.cell.setDbm(cdma.getDbm());
// Cell Identity
pDevice.cell.setCellId(identityCdma.getBasestationId());
pDevice.cell.setMobileNetworkCode(identityCdma.getSystemId());
pDevice.cell.setLocationAreaCode(identityCdma.getNetworkId());
pDevice.cell.setSid(identityCdma.getSystemId());
} else if (info instanceof CellInfoLte) {
final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
// Signal Strength
pDevice.cell.setDbm(lte.getDbm());
pDevice.cell.setTimingAdvance(lte.getTimingAdvance());
// Cell Identity
pDevice.cell.setMobileCountryCode(identityLte.getMcc());
pDevice.cell.setMobileNetworkCode(identityLte.getMnc());
pDevice.cell.setCellId(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.cell.setDbm(wcdma.getDbm());
// Cell Identity
pDevice.cell.setLocationAreaCode(identityWcdma.getLac());
pDevice.cell.setMobileCountryCode(identityWcdma.getMcc());
pDevice.cell.setMobileNetworkCode(identityWcdma.getMnc());
pDevice.cell.setCellId(identityWcdma.getCid());
pDevice.cell.setPrimaryScramblingCode(identityWcdma.getPsc());
} else {
log.info("Unknown type of cell signal! " + "ClassName: " + info.getClass().getSimpleName() + " ToString: " + info.toString());
}
if (pDevice.cell.isValid()) {
break;
}
}
}
} catch (NullPointerException npe) {
log.error("loadCellInfo: Unable to obtain cell signal information: ", npe);
}
}
use of android.telephony.CellIdentityGsm in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RadioInfo method buildGsmInfoString.
private final String buildGsmInfoString(CellInfoGsm ci) {
CellIdentityGsm cidGsm = ci.getCellIdentity();
CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", getConnectionStatusString(ci), getCellInfoDisplayString(cidGsm.getMcc()), getCellInfoDisplayString(cidGsm.getMnc()), getCellInfoDisplayString(cidGsm.getLac()), getCellInfoDisplayString(cidGsm.getCid()), getCellInfoDisplayString(cidGsm.getArfcn()), getCellInfoDisplayString(cidGsm.getBsic()), getCellInfoDisplayString(ssGsm.getDbm()));
}
use of android.telephony.CellIdentityGsm in project android_packages_apps_Settings by omnirom.
the class CellInfoUtil method convertOperatorInfoToCellInfo.
/**
* Creates a CellInfo object from OperatorInfo. GsmCellInfo is used here only because
* operatorInfo does not contain technology type while CellInfo is an abstract object that
* requires to specify technology type. It doesn't matter which CellInfo type to use here, since
* we only want to wrap the operator info and PLMN to a CellInfo object.
*/
public static CellInfo convertOperatorInfoToCellInfo(OperatorInfo operatorInfo) {
final String operatorNumeric = operatorInfo.getOperatorNumeric();
String mcc = null;
String mnc = null;
if (operatorNumeric != null && operatorNumeric.matches("^[0-9]{5,6}$")) {
mcc = operatorNumeric.substring(0, 3);
mnc = operatorNumeric.substring(3);
}
final CellIdentityGsm cig = new CellIdentityGsm(Integer.MAX_VALUE, /* lac */
Integer.MAX_VALUE, /* cid */
Integer.MAX_VALUE, /* arfcn */
Integer.MAX_VALUE, /* bsic */
mcc, mnc, operatorInfo.getOperatorAlphaLong(), operatorInfo.getOperatorAlphaShort(), Collections.emptyList());
final CellInfoGsm ci = new CellInfoGsm();
ci.setCellIdentity(cig);
return ci;
}
use of android.telephony.CellIdentityGsm in project android_packages_apps_Settings by omnirom.
the class NetworkSelectSettingsTest method createGsmCellInfo.
private CellInfoGsm createGsmCellInfo(boolean registered, int cellId, String mcc, String mnc, String plmnName) {
CellIdentityGsm cig = new CellIdentityGsm(1, cellId, 40, 5, new String(mcc), new String(mnc), new String(plmnName), new String(plmnName), Collections.emptyList());
CellSignalStrengthGsm cssg = new CellSignalStrengthGsm(5, 6, 7);
CellInfoGsm cellInfoGsm = new CellInfoGsm();
cellInfoGsm.setRegistered(registered);
cellInfoGsm.setTimeStamp(9);
cellInfoGsm.setCellIdentity(cig);
cellInfoGsm.setCellSignalStrength(cssg);
return cellInfoGsm;
}
Aggregations