use of com.secupwn.aimsicd.utils.Cell in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class MainActivity method importCellTowersData.
private void importCellTowersData(Uri importFile) {
Cell cell = new Cell();
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tm.getNetworkOperator();
if (networkOperator != null && !networkOperator.isEmpty()) {
int mcc = Integer.parseInt(networkOperator.substring(0, 3));
cell.setMobileCountryCode(mcc);
int mnc = Integer.parseInt(networkOperator.substring(3));
cell.setMobileNetworkCode(mnc);
log.debug("CELL:: mobileCountryCode=" + mcc + " mobileNetworkCode=" + mnc);
}
GeoLocation loc = mAimsicdService.lastKnownLocation();
if (loc != null) {
Helpers.msgLong(this, getString(R.string.imporing_celltowers_data));
cell.setLon(loc.getLongitudeInDegrees());
cell.setLat(loc.getLatitudeInDegrees());
Helpers.importCellTowersData(this, cell, importFile, mAimsicdService);
} else {
Helpers.msgShort(this, getString(R.string.needs_location));
}
}
use of com.secupwn.aimsicd.utils.Cell in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class CellInfoFragment method updateStockNeighboringCells.
void updateStockNeighboringCells() {
mNeighboringTotal.setText(String.valueOf(neighboringCells.size()));
if (neighboringCells.size() != 0) {
BaseInflaterAdapter<CardItemData> adapter = new BaseInflaterAdapter<>(new CellCardInflater());
int i = 1;
int total = neighboringCells.size();
for (Cell cell : neighboringCells) {
CardItemData data = new CardItemData(cell, i++ + " / " + total);
adapter.addItem(data, false);
}
lv.setAdapter(adapter);
mNeighboringCells.setVisibility(View.GONE);
mNeighboringTotalView.setVisibility(View.VISIBLE);
}
}
use of com.secupwn.aimsicd.utils.Cell in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class DeviceFragment method responseToCell.
private Cell responseToCell(Response response) {
try {
JSONObject jsonCell = new JSONObject(response.body().string());
Cell cell = new Cell();
cell.setLat(jsonCell.getDouble("lat"));
cell.setLon(jsonCell.getDouble("lon"));
cell.setMobileCountryCode(jsonCell.getInt("mcc"));
cell.setMobileNetworkCode(jsonCell.getInt("mnc"));
cell.setCellId(jsonCell.getInt("cellid"));
cell.setLocationAreaCode(jsonCell.getInt("lac"));
return cell;
} catch (JSONException | IOException e) {
e.printStackTrace();
}
return null;
}
use of com.secupwn.aimsicd.utils.Cell in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class LocationTracker method lastKnownLocation.
public GeoLocation lastKnownLocation() {
GeoLocation loc = null;
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null && (Double.doubleToLongBits(location.getLatitude()) != 0 && Double.doubleToLongBits(location.getLongitude()) != 0)) {
TruncatedLocation TruncatedLocation = new TruncatedLocation(location);
loc = GeoLocation.fromDegrees(TruncatedLocation.getLatitude(), TruncatedLocation.getLongitude());
} else {
location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null && (Double.doubleToLongBits(location.getLatitude()) != 0 && Double.doubleToLongBits(location.getLongitude()) != 0)) {
TruncatedLocation TruncatedLocation = new TruncatedLocation(location);
loc = GeoLocation.fromDegrees(TruncatedLocation.getLatitude(), TruncatedLocation.getLongitude());
} else {
String coords = prefs.getString(context.getString(R.string.data_last_lat_lon), null);
if (coords != null) {
String[] coord = coords.split(":");
loc = GeoLocation.fromDegrees(Double.valueOf(coord[0]), Double.valueOf(coord[1]));
} else {
// get location from MCC
try {
Cell cell = context.getCell();
if (cell != null) {
log.debug("Looking up MCC " + cell.getMobileCountryCode());
@Cleanup Realm realm = Realm.getDefaultInstance();
GpsLocation defLoc = mDbHelper.getDefaultLocation(realm, cell.getMobileCountryCode());
loc = GeoLocation.fromDegrees(defLoc.getLatitude(), defLoc.getLongitude());
}
} catch (Exception e) {
log.error("Unable to get location from MCC", e);
}
}
}
}
if (loc != null) {
log.info("Last known location " + loc.toString());
}
return loc;
}
use of com.secupwn.aimsicd.utils.Cell in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class CellTracker method updateNeighboringCells.
/**
* Description: Updates Neighboring Cell details
*
* TODO: add more details...
*/
public List<Cell> updateNeighboringCells() {
List<Cell> neighboringCells = new ArrayList<>();
List<NeighboringCellInfo> neighboringCellInfo = tm.getNeighboringCellInfo();
if (neighboringCellInfo == null) {
neighboringCellInfo = new ArrayList<>();
}
// NC list present? (default is false)
Boolean nclp = tinydb.getBoolean("nc_list_present");
// if nclp = true then check for neighboringCellInfo
if (neighboringCellInfo != null && neighboringCellInfo.size() == 0 && nclp) {
log.info("NeighboringCellInfo is empty: start polling...");
// Try to poll the neighboring cells for a few seconds
// TODO What is this ??
neighboringCellBlockingQueue = new LinkedBlockingQueue<>(100);
// TODO: See issue #555 (DeviceApi17.java is using API 18 CellInfoWcdma calls.
if (Build.VERSION.SDK_INT > 17) {
DeviceApi18.startListening(tm, phoneStatelistener);
} else {
tm.listen(phoneStatelistener, PhoneStateListener.LISTEN_CELL_LOCATION | // API 17
PhoneStateListener.LISTEN_CELL_INFO | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
// TODO: Consider removing ??
for (int i = 0; i < 10 && neighboringCellInfo.size() == 0; i++) {
try {
log.debug("NeighboringCellInfo empty: trying " + i);
NeighboringCellInfo info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS);
if (info == null) {
neighboringCellInfo = tm.getNeighboringCellInfo();
if (neighboringCellInfo != null) {
if (neighboringCellInfo.size() > 0) {
// Can we think of a better log message here?
log.debug("NeighboringCellInfo found on " + i + " try. (time based)");
break;
} else {
continue;
}
}
}
List<NeighboringCellInfo> cellInfoList = new ArrayList<>(neighboringCellBlockingQueue.size() + 1);
while (info != null) {
cellInfoList.add(info);
info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS);
}
neighboringCellInfo = cellInfoList;
} catch (InterruptedException e) {
// TODO: Add a more valuable message here!
log.error("", e);
}
}
}
// Add NC list to DBi_measure:nc_list
for (NeighboringCellInfo neighborCell : neighboringCellInfo) {
log.info("NeighboringCellInfo -" + " LAC:" + neighborCell.getLac() + " CID:" + neighborCell.getCid() + " PSC:" + neighborCell.getPsc() + " RSSI:" + neighborCell.getRssi());
final Cell cell = new Cell(neighborCell.getCid(), neighborCell.getLac(), neighborCell.getRssi(), neighborCell.getPsc(), neighborCell.getNetworkType(), false);
neighboringCells.add(cell);
}
return neighboringCells;
}
Aggregations