use of com.secupwn.aimsicd.data.model.BaseTransceiverStation in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class BaseStationAdapter 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.unique_bts_data, parent, false);
holder = new ViewHolder(convertView);
} else {
holder = (ViewHolder) convertView.getTag();
}
final BaseTransceiverStation item = getItem(position);
holder.updateDisplay(item, position);
return convertView;
}
use of com.secupwn.aimsicd.data.model.BaseTransceiverStation in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class RealmHelper method insertBTS.
/**
* Created this because we don't need to insert all the data in this table
* since we don't yet have items like TMSI etc.
*/
public void insertBTS(Realm realm, Cell cell) {
// If LAC and CID are not already in BTS realm, then add them.
if (!cellInDbiBts(realm, cell.getLocationAreaCode(), cell.getCellId())) {
realm.beginTransaction();
BaseTransceiverStation baseStation = realm.createObject(BaseTransceiverStation.class);
baseStation.setMobileCountryCode(cell.getMobileCountryCode());
baseStation.setMobileNetworkCode(cell.getMobileNetworkCode());
baseStation.setLocationAreaCode(cell.getLocationAreaCode());
baseStation.setCellId(cell.getCellId());
baseStation.setPrimaryScramblingCode(cell.getPrimaryScramblingCode());
baseStation.setTimeFirst(new Date());
baseStation.setTimeLast(new Date());
GpsLocation gpsLocation = realm.createObject(GpsLocation.class);
// TODO NO! These should be exact GPS from Import or by manual addition!
gpsLocation.setLatitude(cell.getLat());
// TODO NO! These should be exact GPS from Import or by manual addition!
gpsLocation.setLongitude(cell.getLon());
baseStation.setGpsLocation(gpsLocation);
realm.commitTransaction();
} else {
// If cell is already in the DB, update it to last time seen and
// update its GPS coordinates, if not 0.0
BaseTransceiverStation baseStation = realm.where(BaseTransceiverStation.class).equalTo("cellId", cell.getCellId()).findFirst();
realm.beginTransaction();
baseStation.setTimeLast(new Date());
// Only update if GPS coordinates are good
if (Double.doubleToRawLongBits(cell.getLat()) != 0 && Double.doubleToRawLongBits(cell.getLat()) != 0 && Double.doubleToRawLongBits(cell.getLon()) != 0 && Double.doubleToRawLongBits(cell.getLon()) != 0) {
if (baseStation.getGpsLocation() == null) {
baseStation.setGpsLocation(realm.createObject(GpsLocation.class));
}
baseStation.getGpsLocation().setLatitude(cell.getLat());
baseStation.getGpsLocation().setLongitude(cell.getLon());
}
realm.commitTransaction();
log.info("BTS updated: CID=" + cell.getCellId() + " LAC=" + cell.getLocationAreaCode());
}
// Checking to see if CID (now bts_id) is already in DBi_measure, if not add it.
if (!cellInDbiMeasure(realm, cell.getCellId())) {
realm.beginTransaction();
Measure measure = realm.createObject(Measure.class);
BaseTransceiverStation baseStation = realm.where(BaseTransceiverStation.class).equalTo("cellId", cell.getCellId()).findFirst();
measure.setBaseStation(baseStation);
measure.setTime(new Date());
GpsLocation gpsLocation = realm.createObject(GpsLocation.class);
gpsLocation.setLatitude(cell.getLat());
gpsLocation.setLongitude(cell.getLon());
gpsLocation.setAccuracy(cell.getAccuracy());
measure.setGpsLocation(gpsLocation);
measure.setRxSignal(cell.getDbm());
measure.setRadioAccessTechnology(String.valueOf(cell.getRat()));
//TODO does this actually get timing advance?
measure.setTimingAdvance(cell.getTimingAdvance());
measure.setSubmitted(false);
measure.setNeighbor(false);
realm.commitTransaction();
log.info("Measure inserted cellId=" + cell.getCellId());
} else {
// Updating DBi_measure tables if already exists.
realm.beginTransaction();
RealmResults<Measure> all = realm.where(Measure.class).equalTo("baseStation.cellId", cell.getCellId()).findAll();
for (int i = 0; i < all.size(); i++) {
Measure measure = all.get(i);
if (Double.doubleToRawLongBits(cell.getLat()) != 0 && Double.doubleToRawLongBits(cell.getLon()) != 0) {
measure.getGpsLocation().setLatitude(cell.getLat());
measure.getGpsLocation().setLongitude(cell.getLon());
}
if (Double.doubleToRawLongBits(cell.getAccuracy()) != 0 && cell.getAccuracy() > 0) {
measure.getGpsLocation().setAccuracy(cell.getAccuracy());
}
if (cell.getDbm() > 0) {
measure.setRxSignal(cell.getDbm());
}
if (cell.getTimingAdvance() > 0) {
// Only available on API >16 on LTE
measure.setTimingAdvance(cell.getTimingAdvance());
}
}
realm.commitTransaction();
log.info("DBi_measure updated bts_id=" + cell.getCellId());
}
}
Aggregations