use of com.secupwn.aimsicd.utils.GeoLocation in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class MainActivity method downloadBtsDataIfApiKeyAvailable.
private void downloadBtsDataIfApiKeyAvailable() {
if (CellTracker.OCID_API_KEY != null && !CellTracker.OCID_API_KEY.equals("NA")) {
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.contacting_opencellid_for_data));
cell.setLon(loc.getLongitudeInDegrees());
cell.setLat(loc.getLatitudeInDegrees());
Helpers.getOpenCellData(this, cell, RequestTask.DBE_DOWNLOAD_REQUEST, mAimsicdService);
} else {
Helpers.msgShort(this, getString(R.string.waiting_for_location));
// This uses the LocationServices to get CID/LAC/MNC/MCC to be used
// for grabbing the BTS data from OCID, via their API.
// CID Location Async Output Delegate Interface Implementation
LocationServices.LocationAsync locationAsync = new LocationServices.LocationAsync();
locationAsync.delegate = this;
locationAsync.execute(mAimsicdService.getCell().getCellId(), mAimsicdService.getCell().getLocationAreaCode(), mAimsicdService.getCell().getMobileNetworkCode(), mAimsicdService.getCell().getMobileCountryCode());
}
} else {
Helpers.sendMsg(this, getString(R.string.no_opencellid_key_detected));
}
}
use of com.secupwn.aimsicd.utils.GeoLocation in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class MapViewerOsmDroid method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch(item.getItemId()) {
case R.id.map_preferences:
Intent intent = new Intent(this, MapPrefActivity.class);
startActivity(intent);
return true;
case R.id.get_opencellid:
{
if (mBound) {
GeoLocation lastKnown = mAimsicdService.lastKnownLocation();
if (lastKnown != null) {
Helpers.msgLong(this, getString(R.string.contacting_opencellid_for_data));
Cell cell;
cell = mAimsicdService.getCell();
cell.setLon(lastKnown.getLongitudeInDegrees());
cell.setLat(lastKnown.getLatitudeInDegrees());
setRefreshActionButtonState(true);
TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false);
Helpers.getOpenCellData(this, cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP, mAimsicdService);
return true;
}
}
if (mLatestCellLoc != null) {
Helpers.msgLong(this, getString(R.string.contacting_opencellid_for_data));
Cell cell = new Cell();
cell.setLat(mLatestCellLoc.getLatitude());
cell.setLon(mLatestCellLoc.getLongitude());
setRefreshActionButtonState(true);
TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false);
Helpers.getOpenCellData(this, cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP, mAimsicdService);
} else {
Helpers.msgLong(this, getString(R.string.unable_to_determine_last_location));
}
return true;
}
default:
return super.onOptionsItemSelected(item);
}
}
use of com.secupwn.aimsicd.utils.GeoLocation in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class MapFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch(item.getItemId()) {
case R.id.map_preferences:
Intent intent = new Intent(getActivity(), MapPrefActivity.class);
startActivity(intent);
return true;
case R.id.get_opencellid:
{
if (mBound) {
GeoLocation lastKnown = mAimsicdService.lastKnownLocation();
if (lastKnown != null) {
Helpers.msgLong(getActivity(), getString(R.string.contacting_opencellid_for_data));
Cell cell;
cell = mAimsicdService.getCell();
cell.setLon(lastKnown.getLongitudeInDegrees());
cell.setLat(lastKnown.getLatitudeInDegrees());
setRefreshActionButtonState(true);
TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false);
Helpers.getOpenCellData((InjectionAppCompatActivity) getActivity(), cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP, mAimsicdService);
return true;
}
}
if (mLatestCellLoc != null) {
Helpers.msgLong(getActivity(), getString(R.string.contacting_opencellid_for_data));
Cell cell = new Cell();
cell.setLat(mLatestCellLoc.getLatitude());
cell.setLon(mLatestCellLoc.getLongitude());
setRefreshActionButtonState(true);
TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false);
Helpers.getOpenCellData((InjectionAppCompatActivity) getActivity(), cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP, mAimsicdService);
} else {
Helpers.msgLong(getActivity(), getString(R.string.unable_to_determine_last_location));
}
return true;
}
default:
return super.onOptionsItemSelected(item);
}
}
use of com.secupwn.aimsicd.utils.GeoLocation 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.GeoLocation 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));
}
}
Aggregations