use of android.telephony.CellIdentityWcdma 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.CellIdentityWcdma 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.CellIdentityWcdma in project android_frameworks_base by AOSPA.
the class NetworkMonitor method sendNetworkConditionsBroadcast.
/**
* @param responseReceived - whether or not we received a valid HTTP response to our request.
* If false, isCaptivePortal and responseTimestampMs are ignored
* TODO: This should be moved to the transports. The latency could be passed to the transports
* along with the captive portal result. Currently the TYPE_MOBILE broadcasts appear unused so
* perhaps this could just be added to the WiFi transport only.
*/
private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal, long requestTimestampMs, long responseTimestampMs) {
if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 0) {
return;
}
if (systemReady == false)
return;
Intent latencyBroadcast = new Intent(ACTION_NETWORK_CONDITIONS_MEASURED);
switch(mNetworkAgentInfo.networkInfo.getType()) {
case ConnectivityManager.TYPE_WIFI:
WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo();
if (currentWifiInfo != null) {
// NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not
// surrounded by double quotation marks (thus violating the Javadoc), but this
// was changed to match the Javadoc in API 17. Since clients may have started
// sanitizing the output of this method since API 17 was released, we should
// not change it here as it would become impossible to tell whether the SSID is
// simply being surrounded by quotes due to the API, or whether those quotes
// are actually part of the SSID.
latencyBroadcast.putExtra(EXTRA_SSID, currentWifiInfo.getSSID());
latencyBroadcast.putExtra(EXTRA_BSSID, currentWifiInfo.getBSSID());
} else {
if (VDBG)
logw("network info is TYPE_WIFI but no ConnectionInfo found");
return;
}
break;
case ConnectivityManager.TYPE_MOBILE:
latencyBroadcast.putExtra(EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType());
List<CellInfo> info = mTelephonyManager.getAllCellInfo();
if (info == null)
return;
int numRegisteredCellInfo = 0;
for (CellInfo cellInfo : info) {
if (cellInfo.isRegistered()) {
numRegisteredCellInfo++;
if (numRegisteredCellInfo > 1) {
if (VDBG)
logw("more than one registered CellInfo." + " Can't tell which is active. Bailing.");
return;
}
if (cellInfo instanceof CellInfoCdma) {
CellIdentityCdma cellId = ((CellInfoCdma) cellInfo).getCellIdentity();
latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
} else if (cellInfo instanceof CellInfoGsm) {
CellIdentityGsm cellId = ((CellInfoGsm) cellInfo).getCellIdentity();
latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
} else if (cellInfo instanceof CellInfoLte) {
CellIdentityLte cellId = ((CellInfoLte) cellInfo).getCellIdentity();
latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
} else if (cellInfo instanceof CellInfoWcdma) {
CellIdentityWcdma cellId = ((CellInfoWcdma) cellInfo).getCellIdentity();
latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
} else {
if (VDBG)
logw("Registered cellinfo is unrecognized");
return;
}
}
}
break;
default:
return;
}
latencyBroadcast.putExtra(EXTRA_CONNECTIVITY_TYPE, mNetworkAgentInfo.networkInfo.getType());
latencyBroadcast.putExtra(EXTRA_RESPONSE_RECEIVED, responseReceived);
latencyBroadcast.putExtra(EXTRA_REQUEST_TIMESTAMP_MS, requestTimestampMs);
if (responseReceived) {
latencyBroadcast.putExtra(EXTRA_IS_CAPTIVE_PORTAL, isCaptivePortal);
latencyBroadcast.putExtra(EXTRA_RESPONSE_TIMESTAMP_MS, responseTimestampMs);
}
mContext.sendBroadcastAsUser(latencyBroadcast, UserHandle.CURRENT, PERMISSION_ACCESS_NETWORK_CONDITIONS);
}
use of android.telephony.CellIdentityWcdma in project assertj-android by square.
the class CellInfoWcdmaAssert method hasCellIdentity.
public CellInfoWcdmaAssert hasCellIdentity(CellIdentityWcdma cellIdentity) {
isNotNull();
CellIdentityWcdma actualCellIdentity = actual.getCellIdentity();
//
assertThat(actualCellIdentity).overridingErrorMessage("Expected cell identity <%s> but was <%s>.", cellIdentity, //
actualCellIdentity).isEqualTo(cellIdentity);
return this;
}
Aggregations