use of com.secupwn.aimsicd.ui.fragments.MapFragment in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class Helpers method getOpenCellData.
public static void getOpenCellData(InjectionAppCompatActivity injectionActivity, Cell cell, char type, final AimsicdService service) {
if (Helpers.isNetAvailable(injectionActivity)) {
if (!"NA".equals(CellTracker.OCID_API_KEY)) {
// [Km]
double earthRadius = 6371.01;
// Use a 2 Km radius with center at GPS location.
int radius = 2;
if (Double.doubleToRawLongBits(cell.getLat()) != 0 && Double.doubleToRawLongBits(cell.getLon()) != 0) {
//New GeoLocation object to find bounding Coordinates
GeoLocation currentLoc = GeoLocation.fromDegrees(cell.getLat(), cell.getLon());
//Calculate the Bounding Box Coordinates using an N Km "radius" //0=min, 1=max
GeoLocation[] boundingCoords = currentLoc.boundingCoordinates(radius, earthRadius);
String boundParameter;
//Request OpenCellID data for Bounding Coordinates (0 = min, 1 = max)
boundParameter = String.valueOf(boundingCoords[0].getLatitudeInDegrees()) + "," + String.valueOf(boundingCoords[0].getLongitudeInDegrees()) + "," + String.valueOf(boundingCoords[1].getLatitudeInDegrees()) + "," + String.valueOf(boundingCoords[1].getLongitudeInDegrees());
log.info("OCID BBOX is set to: " + boundParameter + " with radius " + radius + " Km.");
StringBuilder sb = new StringBuilder();
sb.append("http://www.opencellid.org/cell/getInArea?key=").append(CellTracker.OCID_API_KEY).append("&BBOX=").append(boundParameter);
log.info("OCID MCC is set to: " + cell.getMobileCountryCode());
if (cell.getMobileCountryCode() != Integer.MAX_VALUE) {
sb.append("&mcc=").append(cell.getMobileCountryCode());
}
log.info("OCID MNC is set to: " + cell.getMobileNetworkCode());
if (cell.getMobileNetworkCode() != Integer.MAX_VALUE) {
sb.append("&mnc=").append(cell.getMobileNetworkCode());
}
sb.append("&format=csv");
new RequestTask(injectionActivity, type, new RequestTask.AsyncTaskCompleteListener() {
@Override
public void onAsyncTaskSucceeded() {
log.verbose("RequestTask's OCID download was successful. Callback rechecking connected cell against database");
service.getCellTracker().compareLacAndOpenDb();
}
@Override
public void onAsyncTaskFailed(String result) {
}
}).execute(sb.toString());
}
} else {
Fragment myFragment = injectionActivity.getSupportFragmentManager().findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS));
if (myFragment instanceof MapFragment) {
((MapFragment) myFragment).setRefreshActionButtonState(false);
}
Helpers.sendMsg(injectionActivity, injectionActivity.getString(R.string.no_opencellid_key_detected));
}
} else {
Fragment myFragment = injectionActivity.getSupportFragmentManager().findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS));
if (myFragment instanceof MapFragment) {
((MapFragment) myFragment).setRefreshActionButtonState(false);
}
final AlertDialog.Builder builder = new AlertDialog.Builder(injectionActivity);
builder.setTitle(R.string.no_network_connection_title).setMessage(R.string.no_network_connection_message);
builder.create().show();
}
}
use of com.secupwn.aimsicd.ui.fragments.MapFragment in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class Helpers method importCellTowersData.
/**
* Description: Imports cell data from the specified file
*
* Used:
* @param celltowersPath path to the cell_towers.csv / cell_towers.csv.gz
* @param cell Current Cell Information
* @param importFile
*
*/
public static void importCellTowersData(InjectionAppCompatActivity injectionActivity, Cell cell, Uri importFile, final AimsicdService service) {
if (Helpers.isNetAvailable(injectionActivity)) {
// Use a 2 Km radius with center at GPS location.
int radius = 2;
if (Double.doubleToRawLongBits(cell.getLat()) != 0 && Double.doubleToRawLongBits(cell.getLon()) != 0) {
GeoLocation currentLoc = GeoLocation.fromDegrees(cell.getLat(), cell.getLon());
log.info("OCID location: " + currentLoc.toString() + " with radius " + radius + " Km.");
log.info("OCID MCC is set to: " + cell.getMobileCountryCode());
log.info("OCID MNC is set to: " + cell.getMobileNetworkCode());
new ImportTask(injectionActivity, importFile, cell.getMobileCountryCode(), cell.getMobileNetworkCode(), currentLoc, radius, new ImportTask.AsyncTaskCompleteListener() {
@Override
public void onAsyncTaskSucceeded() {
log.verbose("ImportTask's OCID import was successful. Callback rechecking connected cell against database");
service.getCellTracker().compareLacAndOpenDb();
}
@Override
public void onAsyncTaskFailed(String result) {
}
}).execute();
}
} else {
Fragment myFragment = injectionActivity.getSupportFragmentManager().findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS));
if (myFragment instanceof MapFragment) {
((MapFragment) myFragment).setRefreshActionButtonState(false);
}
final AlertDialog.Builder builder = new AlertDialog.Builder(injectionActivity);
builder.setTitle(R.string.no_network_connection_title).setMessage(R.string.no_network_connection_message);
builder.create().show();
}
}
use of com.secupwn.aimsicd.ui.fragments.MapFragment in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
deviceFragment = new DeviceFragment();
cellInfoFragment = new CellInfoFragment();
atCommandFragment = new AtCommandFragment();
dbViewerFragment = new DbViewerFragment();
mapFragment = new MapFragment();
mNavConf = new DrawerMenuActivityConfiguration.Builder(this).build();
mDrawerLayout = (DrawerLayout) findViewById(mNavConf.getDrawerLayoutId());
mDrawerList = (ListView) findViewById(mNavConf.getLeftDrawerId());
mActionBar = getSupportActionBar();
mTitle = getTitle();
mDrawerTitle = getTitle();
mDrawerList.setAdapter(mNavConf.getBaseAdapter());
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.string.drawer_open, /* "open drawer" description */
R.string.drawer_close) {
/* "close drawer" description */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
mActionBar.setTitle(mTitle);
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
mActionBar.setTitle(mDrawerTitle);
invalidateOptionsMenu();
}
};
// Set the drawer toggle as the DrawerListener
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mDrawerLayout.setDrawerListener(mDrawerToggle);
mActionBar.setDisplayHomeAsUpEnabled(true);
mActionBar.setHomeButtonEnabled(true);
prefs = getSharedPreferences(AimsicdService.SHARED_PREFERENCES_BASENAME, 0);
/* Pref listener to enable sms detection on pref change */
prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (key.equals(getString(R.string.adv_user_root_pref_key))) {
SmsDetection();
}
}
};
prefs.registerOnSharedPreferenceChangeListener(prefListener);
mDisclaimerAccepted = getResources().getString(R.string.disclaimer_accepted);
if (!prefs.getBoolean(mDisclaimerAccepted, false)) {
final AlertDialog.Builder disclaimer = new AlertDialog.Builder(this).setTitle(R.string.disclaimer_title).setMessage(R.string.disclaimer).setPositiveButton(R.string.text_agree, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
prefsEditor = prefs.edit();
prefsEditor.putBoolean(mDisclaimerAccepted, true);
prefsEditor.apply();
startService();
}
}).setNegativeButton(R.string.text_disagree, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
prefsEditor = prefs.edit();
prefsEditor.putBoolean(mDisclaimerAccepted, false);
prefsEditor.apply();
Uri packageUri = Uri.parse("package:com.SecUpwN.AIMSICD");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
startActivity(uninstallIntent);
finish();
if (mAimsicdService != null) {
mAimsicdService.onDestroy();
}
}
});
AlertDialog disclaimerAlert = disclaimer.create();
disclaimerAlert.show();
} else {
startService();
}
}
Aggregations