use of com.secupwn.aimsicd.data.model.Import in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class MapViewerOsmDroid method loadOcidMarkersByNetwork.
private void loadOcidMarkersByNetwork() {
// Check if OpenCellID data exists and if so load this now
List<CellTowerMarker> items = new LinkedList<>();
String networkOperator = tm.getNetworkOperator();
int currentMmc = 0;
int currentMnc = 0;
if (networkOperator != null && networkOperator.length() > 3) {
currentMmc = Integer.parseInt(networkOperator.substring(0, 3));
currentMnc = Integer.parseInt(networkOperator.substring(3));
}
Drawable cellTowerMarkerIcon = getResources().getDrawable(R.drawable.ic_map_pin_green);
@Cleanup Realm realm = Realm.getDefaultInstance();
RealmResults<Import> importRealmResults = mDbHelper.returnOcidBtsByNetwork(realm, currentMmc, currentMnc).findAll();
for (Import anImport : importRealmResults) {
// CellID,Lac,Mcc,Mnc,Lat,Lng,AvgSigStr,Samples
final int cellID = anImport.getCellId();
final int lac = anImport.getLocationAreaCode();
final int mcc = anImport.getMobileCountryCode();
final int mnc = anImport.getMobileNetworkCode();
final int psc = anImport.getPrimaryScramblingCode();
final String rat = anImport.getRadioAccessTechnology();
final double dLat = anImport.getGpsLocation().getLatitude();
final double dLng = anImport.getGpsLocation().getLongitude();
final GeoPoint location = new GeoPoint(dLat, dLng);
// where is c.getString(6)AvgSigStr
final int samples = anImport.getSamples();
// Add map marker for CellID
CellTowerMarker ovm = new CellTowerMarker(this, mMap, "Cell ID: " + cellID, "", location, new MarkerData(getApplicationContext(), String.valueOf(cellID), String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude()), String.valueOf(lac), String.valueOf(mcc), String.valueOf(mnc), String.valueOf(psc), rat, String.valueOf(samples), false));
ovm.setIcon(cellTowerMarkerIcon);
items.add(ovm);
}
mCellTowerGridMarkerClusterer.addAll(items);
}
use of com.secupwn.aimsicd.data.model.Import in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class RealmHelper method checkDBe.
/**
* This is the {@link Import} data consistency check wich checks each
* imported BTS data for consistency and correctness according to general
* 3GPP LAC/CID/RAT rules and according to the app settings:
* <p/>
* tf_settings (currently hard-coded)
* min_gps_precision (currently hard-coded)
* <p/>
* So there are really two steps in this procedure:
* a) Remove bad {@link Import Imports} from Realm
* b) Mark unsafe {@link Import Imports} with "rej_cause" value.
* <p/>
* The formula for the long cell ID is as follows:
* Long CID = 65536 * RNC + CID
* <p/>
* If you have the Long CID, you can get RNC and CID in the following way:
* RNC = Long CID / 65536 (integer division)
* CID = Long CID mod 65536 (modulo operation)
*/
public Realm.Transaction checkDBe() {
return new Realm.Transaction() {
@Override
public void execute(Realm realm) {
// We hard-code these for now, but should be in the settings eventually
// int tf_settings = 30; // [days] Minimum acceptable number of days since "time_first" seen.
// [m] Minimum acceptable GPS accuracy in meters.
int min_gps_precision = 50;
// =============================================================
// === DELETE bad cells from BTS data
// =============================================================
log.debug("CheckDBe() Attempting to delete bad import data from Imports database...");
// =========== samples ===========
realm.where(Import.class).lessThan("samples", 1).findAll().clear();
// =========== avg_range ===========
// TODO: OCID data marks many good BTS with a negative range so we can't use this yet.
// TODO: Also delete cells where the avg_range is way too large, say > 2000 meter
/*realm.where(Import.class)
.not()
.between("avgRange", 1, 2000)
.findAll().clear();*/
// =========== LAC ===========
realm.where(Import.class).lessThan("locationAreaCode", 1).findAll().clear();
// We should delete cells with CDMA (4) LAC not in [1,65534] but we can simplify this to:
// Delete ANY cells with a LAC not in [1,65534]
realm.where(Import.class).greaterThan("locationAreaCode", 65534).findAll().clear();
// Delete cells with GSM/UMTS/LTE (1/2/3/13 ??) (or all others?) LAC not in [1,65533]
/*realm.where(Import.class)
.notEqualTo("radioAccessTechnology", "CDMA")
.greaterThan("locationAreaCode", 65533)
.findAll().clear();*/
// =========== CID ===========
realm.where(Import.class).lessThan("cell", 1).findAll().clear();
// We should delete cells with UMTS/LTE (3,13) CID not in [1,268435455] (0xFFF FFFF) but
// we can simplify this to:
// Delete ANY cells with a CID not in [1,268435455]
realm.where(Import.class).greaterThan("cellId", 268435455).findAll().clear();
// Delete cells with GSM/CDMA (1-3,4) CID not in [1,65534]
realm.where(Import.class).greaterThan("cellId", 65534).beginGroup().equalTo("radioAccessTechnology", "GSM").or().equalTo("radioAccessTechnology", "CDMA").endGroup().findAll().clear();
log.info("CheckDBe() Deleted BTS entries from Import realm with bad LAC/CID...");
// NOTE: In OCID: "changeable"=1 ==> isGPSexact=0
for (Import i : realm.where(Import.class).equalTo("gpsExact", false).findAll()) {
i.setRejCause(i.getRejCause() + 3);
}
// Increase rej_cause, when: the average range is < a minimum GPS precision
for (Import i : realm.where(Import.class).lessThan("avgRange", min_gps_precision).findAll()) {
i.setRejCause(i.getRejCause() + 3);
}
// =========== time_first ===========
// Increase rej_cause, when: the time first seen is less than a number of days.
// TODO: We need to convert tf_settings to seconds since epoch/unix time...
// int tf_settings = current_time[s] - (3600 * 24 * tf_settings) ???
// sqlQuery = "UPDATE DBe_import SET rej_cause = rej_cause + 1 WHERE time_first < " + tf_settings;
// mDb.execSQL(sqlQuery);
}
};
}
use of com.secupwn.aimsicd.data.model.Import in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class RealmHelper method insertDBeImport.
/**
* This method is used to insert and populate the downloaded or previously
* backed up OCID details into the {@link Import} realm table.
* <p/>
* It also prevents adding multiple entries of the same cell-id, when OCID
* downloads are repeated.
*/
public Realm.Transaction insertDBeImport(final String db_src, final String rat, final int mcc, final int mnc, final int lac, final int cid, final int psc, final double lat, final double lon, final boolean isGpsExact, final int avg_range, final int avg_signal, final int samples, final Date time_first, final Date time_last) {
return new Realm.Transaction() {
@Override
public void execute(Realm realm) {
long count = realm.where(Import.class).equalTo("locationAreaCode", lac).equalTo("cellId", cid).count();
if (count <= 0) {
Import anImport = realm.createObject(Import.class);
anImport.setDbSource(db_src);
anImport.setRadioAccessTechnology(rat);
anImport.setMobileCountryCode(mcc);
anImport.setMobileNetworkCode(mnc);
anImport.setLocationAreaCode(lac);
anImport.setCellId(cid);
anImport.setPrimaryScramblingCode(psc);
GpsLocation gpsLocation = realm.createObject(GpsLocation.class);
gpsLocation.setLatitude(lat);
gpsLocation.setLongitude(lon);
anImport.setGpsLocation(gpsLocation);
anImport.setGpsExact(isGpsExact);
anImport.setAvgRange(avg_range);
anImport.setAvgSignal(avg_signal);
anImport.setSamples(samples);
anImport.setTimeFirst(time_first);
anImport.setTimeLast(time_last);
}
}
};
}
use of com.secupwn.aimsicd.data.model.Import in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class MapFragment method loadOcidMarkersByNetwork.
private void loadOcidMarkersByNetwork() {
// Check if OpenCellID data exists and if so load this now
List<CellTowerMarker> items = new LinkedList<>();
String networkOperator = tm.getNetworkOperator();
int currentMmc = 0;
int currentMnc = 0;
if (networkOperator != null && networkOperator.length() > 3) {
currentMmc = Integer.parseInt(networkOperator.substring(0, 3));
currentMnc = Integer.parseInt(networkOperator.substring(3));
}
Drawable cellTowerMarkerIcon = getResources().getDrawable(R.drawable.ic_map_pin_green);
@Cleanup Realm realm = Realm.getDefaultInstance();
RealmResults<Import> importRealmResults = mDbHelper.returnOcidBtsByNetwork(realm, currentMmc, currentMnc).findAll();
for (Import anImport : importRealmResults) {
final int cellID = anImport.getCellId();
final int lac = anImport.getLocationAreaCode();
final int mcc = anImport.getMobileCountryCode();
final int mnc = anImport.getMobileNetworkCode();
final int psc = anImport.getPrimaryScramblingCode();
final String rat = anImport.getRadioAccessTechnology();
final double dLat = anImport.getGpsLocation().getLatitude();
final double dLng = anImport.getGpsLocation().getLongitude();
final GeoPoint location = new GeoPoint(dLat, dLng);
// where is c.getString(6)AvgSigStr
final int samples = anImport.getSamples();
// Add map marker for CellID
CellTowerMarker ovm = new CellTowerMarker(getActivity(), mMap, "Cell ID: " + cellID, "", location, new MarkerData(getContext(), String.valueOf(cellID), String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude()), String.valueOf(lac), String.valueOf(mcc), String.valueOf(mnc), String.valueOf(psc), rat, String.valueOf(samples), false));
ovm.setIcon(cellTowerMarkerIcon);
items.add(ovm);
}
mCellTowerGridMarkerClusterer.addAll(items);
}
use of com.secupwn.aimsicd.data.model.Import in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class ImportAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
convertView = inflater.inflate(R.layout.dbe_import_items, parent, false);
holder = new ViewHolder(convertView);
} else {
holder = (ViewHolder) convertView.getTag();
}
final Import anImport = getItem(position);
holder.updateDisplay(anImport, position);
return convertView;
}
Aggregations