From 6c64927f9114b49541c7c81f660baba9e6306ce8 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Wed, 17 Feb 2016 00:38:17 +0100 Subject: [PATCH 01/14] fix lint errors --- AIMSICD/build.gradle | 2 +- AIMSICD/src/main/res/layout/activity_about.xml | 1 - AIMSICD/src/main/res/layout/activity_map_viewer.xml | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/AIMSICD/build.gradle b/AIMSICD/build.gradle index 54bea2caf..90929ecbc 100644 --- a/AIMSICD/build.gradle +++ b/AIMSICD/build.gradle @@ -52,7 +52,7 @@ android { targetCompatibility JavaVersion.VERSION_1_7 } lintOptions { - warning 'MissingTranslation', 'InvalidPackage' + warning 'MissingTranslation', 'InvalidPackage', 'MissingRegistered' abortOnError false xmlReport false diff --git a/AIMSICD/src/main/res/layout/activity_about.xml b/AIMSICD/src/main/res/layout/activity_about.xml index c6ac63dd9..419a170b1 100644 --- a/AIMSICD/src/main/res/layout/activity_about.xml +++ b/AIMSICD/src/main/res/layout/activity_about.xml @@ -9,7 +9,6 @@ Date: Wed, 17 Feb 2016 13:38:13 +0100 Subject: [PATCH 02/14] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegian?= =?UTF-8?q?=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 100.0% (301 of 301 strings) --- AIMSICD/src/main/res/values-nb/translatable_strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AIMSICD/src/main/res/values-nb/translatable_strings.xml b/AIMSICD/src/main/res/values-nb/translatable_strings.xml index 4f6b64760..9929a4811 100644 --- a/AIMSICD/src/main/res/values-nb/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-nb/translatable_strings.xml @@ -1,4 +1,4 @@ - + Sporing Telefon/SIM-detaljer Antennekart-fremviser @@ -24,7 +24,7 @@ Ingen Internett-forbindelse Klarte ikke laste ned OpenCellID-data uten Internettilkobling, vennligst slå på datatilkobling! - Last med BTS-data + Last ned BTS-data Enhetsinformasjon SIM-informasjon From 3cb8d2acdaf030eae02dbd7ff3b506ff0937ae11 Mon Sep 17 00:00:00 2001 From: tt3mm Date: Sat, 20 Feb 2016 13:48:25 +0100 Subject: [PATCH 03/14] UX refactoring - Main application screens changed to fragments - Moved general screens to the menu bar - cleanup / refactor --- AIMSICD/src/main/AndroidManifest.xml | 16 +- .../java/com/SecUpwN/AIMSICD/AIMSICD.java | 288 +++---- .../AIMSICD/activities/BaseActivity.java | 2 +- .../AIMSICD/activities/MapFragment.java | 636 +++++++++++++++ .../AIMSICD/activities/SettingsActivity.java | 30 + .../AIMSICD/adapters/AIMSICDDbAdapter.java | 6 +- .../SecUpwN/AIMSICD/constants/DrawerMenu.java | 4 +- .../DrawerMenuActivityConfiguration.java | 12 +- .../AIMSICD/drawer/DrawerMenuItem.java | 2 +- .../AIMSICD/fragments/AtCommandFragment.java | 442 +++++++++++ .../AIMSICD/fragments/DeviceFragment.java | 6 +- .../AIMSICD/fragments/SettingsFragment.java | 82 ++ .../SecUpwN/AIMSICD/utils/BaseAsyncTask.java | 2 +- .../com/SecUpwN/AIMSICD/utils/Helpers.java | 15 +- .../SecUpwN/AIMSICD/utils/RequestTask.java | 16 +- AIMSICD/src/main/java/scratchpad | 6 + .../src/main/res/layout/fragment_device.xml | 736 ++++++++++-------- .../src/main/res/menu/activity_debug_logs.xml | 2 +- .../src/main/res/menu/fragment_map_menu.xml | 16 + AIMSICD/src/main/res/menu/main_menu.xml | 34 + .../res/values-cs/translatable_strings.xml | 2 +- .../res/values-de/translatable_strings.xml | 2 +- .../res/values-es/translatable_strings.xml | 2 +- .../res/values-fr/translatable_strings.xml | 2 +- .../res/values-ja/translatable_strings.xml | 2 +- .../res/values-nb/translatable_strings.xml | 2 +- .../res/values-nl/translatable_strings.xml | 2 +- .../res/values-pl/translatable_strings.xml | 2 +- .../values-pt-rBR/translatable_strings.xml | 2 +- .../res/values-ru/translatable_strings.xml | 2 +- .../res/values-sq/translatable_strings.xml | 2 +- .../res/values-uk/translatable_strings.xml | 2 +- .../res/values-vi/translatable_strings.xml | 2 +- AIMSICD/src/main/res/values/strings.xml | 4 + .../main/res/values/translatable_strings.xml | 3 +- 35 files changed, 1833 insertions(+), 553 deletions(-) create mode 100644 AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java create mode 100644 AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/SettingsActivity.java create mode 100644 AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/AtCommandFragment.java create mode 100644 AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/SettingsFragment.java create mode 100644 AIMSICD/src/main/java/scratchpad create mode 100644 AIMSICD/src/main/res/menu/fragment_map_menu.xml create mode 100644 AIMSICD/src/main/res/menu/main_menu.xml create mode 100644 AIMSICD/src/main/res/values/strings.xml diff --git a/AIMSICD/src/main/AndroidManifest.xml b/AIMSICD/src/main/AndroidManifest.xml index 5e00981d2..ef2c20c43 100644 --- a/AIMSICD/src/main/AndroidManifest.xml +++ b/AIMSICD/src/main/AndroidManifest.xml @@ -56,19 +56,7 @@ - - - - diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java index ce3ea5fb5..e1f908493 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java @@ -17,11 +17,14 @@ import android.net.Uri; import android.os.Bundle; import android.os.IBinder; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarDrawerToggle; import android.telephony.TelephonyManager; import android.view.Menu; +import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; @@ -31,14 +34,16 @@ import com.SecUpwN.AIMSICD.activities.AboutActivity; import com.SecUpwN.AIMSICD.activities.BaseActivity; import com.SecUpwN.AIMSICD.activities.DebugLogs; -import com.SecUpwN.AIMSICD.activities.MapViewerOsmDroid; -import com.SecUpwN.AIMSICD.activities.PrefActivity; +import com.SecUpwN.AIMSICD.activities.MapFragment; +import com.SecUpwN.AIMSICD.activities.SettingsActivity; import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter; import com.SecUpwN.AIMSICD.constants.DrawerMenu; import com.SecUpwN.AIMSICD.drawer.DrawerMenuActivityConfiguration; import com.SecUpwN.AIMSICD.drawer.NavDrawerItem; -import com.SecUpwN.AIMSICD.activities.AtCommandActivity; -import com.SecUpwN.AIMSICD.fragments.DetailsContainerFragment; +import com.SecUpwN.AIMSICD.fragments.AtCommandFragment; +import com.SecUpwN.AIMSICD.fragments.CellInfoFragment; +import com.SecUpwN.AIMSICD.fragments.DbViewerFragment; +import com.SecUpwN.AIMSICD.fragments.DeviceFragment; import com.SecUpwN.AIMSICD.service.AimsicdService; import com.SecUpwN.AIMSICD.service.CellTracker; import com.SecUpwN.AIMSICD.utils.AsyncResponse; @@ -49,7 +54,6 @@ import com.SecUpwN.AIMSICD.utils.LocationServices; import com.SecUpwN.AIMSICD.utils.RequestTask; import com.SecUpwN.AIMSICD.utils.StackOverflowXmlParser; - import com.squareup.okhttp.Callback; import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.Request; @@ -61,13 +65,9 @@ import java.util.List; import io.freefair.android.injection.annotation.Inject; -import io.freefair.android.util.logging.Logger; public class AIMSICD extends BaseActivity implements AsyncResponse { - @Inject - private Logger log; - private boolean mBound; private SharedPreferences prefs; private SharedPreferences.OnSharedPreferenceChangeListener prefListener; @@ -82,6 +82,12 @@ public class AIMSICD extends BaseActivity implements AsyncResponse { private CharSequence mDrawerTitle; private CharSequence mTitle; + private DeviceFragment deviceFragment; + private CellInfoFragment cellInfoFragment; + private AtCommandFragment atCommandFragment; + private DbViewerFragment dbViewerFragment; + private MapFragment mapFragment; + private long mLastPress = 0; // Back press to exit timer private DrawerMenuActivityConfiguration mNavConf; @@ -89,16 +95,18 @@ public class AIMSICD extends BaseActivity implements AsyncResponse { @Inject OkHttpClient okHttpClient; - /** - * Called when the activity is first created. - */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); - mNavConf = new DrawerMenuActivityConfiguration.Builder(this).build(); + deviceFragment = new DeviceFragment(); + cellInfoFragment = new CellInfoFragment(); + atCommandFragment = new AtCommandFragment(); + dbViewerFragment = new DbViewerFragment(); + mapFragment = new MapFragment(); - setContentView(mNavConf.getMainLayout()); + mNavConf = new DrawerMenuActivityConfiguration.Builder(this).build(); mDrawerLayout = (DrawerLayout) findViewById(mNavConf.getDrawerLayoutId()); mDrawerList = (ListView) findViewById(mNavConf.getLeftDrawerId()); @@ -113,14 +121,12 @@ public void onCreate(Bundle savedInstanceState) { R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ) { - /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); mActionBar.setTitle(mTitle); invalidateOptionsMenu(); } - /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); mActionBar.setTitle(mDrawerTitle); @@ -188,7 +194,7 @@ public void onClick(DialogInterface dialog, int which) { protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); final String iconType = prefs.getString(getString(R.string.pref_ui_icons_key), "SENSE").toUpperCase(); - mActionBar.setIcon(Icon.getIcon(Icon.Type.valueOf(iconType), ((AppAIMSICD)getApplication()).getStatus())); + mActionBar.setIcon(Icon.getIcon(Icon.Type.valueOf(iconType), ((AppAIMSICD) getApplication()).getStatus())); mDrawerToggle.syncState(); } @@ -219,75 +225,49 @@ private class DrawerItemClickListener implements ListView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { mDrawerLayout.closeDrawer(mDrawerList); - selectItem(position); + selectDrawerItem(position); } } - /** - * Swaps fragments in the main content view - */ - void selectItem(int position) { + + + + void selectDrawerItem(int position) { NavDrawerItem selectedItem = mNavConf.getNavItems().get(position); String title = selectedItem.getLabel(); - /** - * This is a work-around for Android Issue 42601 - * https://code.google.com/p/android/issues/detail?id=42601 - * - * The method getChildFragmentManager() does not clear up - * when the Fragment is detached. - */ - DetailsContainerFragment mDetailsFrag = new DetailsContainerFragment(); - - // Create a new fragment switch (selectedItem.getId()) { case DrawerMenu.ID.MAIN.PHONE_SIM_DETAILS: - getSupportFragmentManager().beginTransaction() - .replace(R.id.content_frame, mDetailsFrag).commit(); - mDetailsFrag.setCurrentPage(0); + openFragment(deviceFragment); title = getString(R.string.app_name_short); break; case DrawerMenu.ID.MAIN.CURRENT_TREAT_LEVEL: - getSupportFragmentManager().beginTransaction() - .replace(R.id.content_frame, mDetailsFrag).commit(); - mDetailsFrag.setCurrentPage(1); + openFragment(cellInfoFragment); title = getString(R.string.app_name_short); break; case DrawerMenu.ID.MAIN.AT_COMMAND_INTERFACE: - Intent atCommandIntent = new Intent(this, AtCommandActivity.class); - startActivity(atCommandIntent); + openFragment(atCommandFragment); + title = getString(R.string.app_name_short); break; case DrawerMenu.ID.MAIN.DB_VIEWER: - getSupportFragmentManager().beginTransaction() - .replace(R.id.content_frame, mDetailsFrag).commit(); - mDetailsFrag.setCurrentPage(2); + openFragment(dbViewerFragment); title = getString(R.string.app_name_short); break; - case DrawerMenu.ID.APPLICATION.ABOUT: - Intent aboutIntent = new Intent(this, AboutActivity.class); - startActivity(aboutIntent); - break; case DrawerMenu.ID.APPLICATION.UPLOAD_LOCAL_BTS_DATA: // Request uploading here? new RequestTask(this, com.SecUpwN.AIMSICD.utils.RequestTask.DBE_UPLOAD_REQUEST).execute(""); // no string needed for csv based upload break; + case DrawerMenu.ID.MAIN.ANTENNA_MAP_VIEW: + openFragment(mapFragment); + title = getString(R.string.app_name_short); + break; + case DrawerMenu.ID.SETTINGS.BACKUP_DB: + new RequestTask(this, RequestTask.BACKUP_DATABASE).execute(); + break; } - if (selectedItem.getId() == DrawerMenu.ID.TRACKING.TOGGLE_ATTACK_DETECTION) { - monitorCell(); - } else if (selectedItem.getId() == DrawerMenu.ID.TRACKING.TOGGLE_CELL_TRACKING) { - trackCell(); - } else if (selectedItem.getId() == DrawerMenu.ID.TRACKING.TRACK_FEMTOCELL) { - trackFemtocell(); - } else if (selectedItem.getId() == DrawerMenu.ID.MAIN.ANTENNA_MAP_VIEW) { - showMap(); - } else if (selectedItem.getId() == DrawerMenu.ID.SETTINGS.PREFERENCES) { - Intent intent = new Intent(this, PrefActivity.class); - startActivity(intent); - } else if (selectedItem.getId() == DrawerMenu.ID.SETTINGS.BACKUP_DB) { - new RequestTask(this, RequestTask.BACKUP_DATABASE).execute(); - } else if (selectedItem.getId() == DrawerMenu.ID.SETTINGS.RESTORE_DB) { + if (selectedItem.getId() == DrawerMenu.ID.SETTINGS.RESTORE_DB) { if (CellTracker.LAST_DB_BACKUP_VERSION < AIMSICDDbAdapter.DATABASE_VERSION) { Helpers.msgLong(this, getString(R.string.unable_to_restore_backup_from_previous_database_version)); } else { @@ -301,47 +281,8 @@ void selectItem(int position) { } else if (selectedItem.getId() == DrawerMenu.ID.APPLICATION.DOWNLOAD_LOCAL_BTS_DATA) { - 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) { - int mcc = Integer.parseInt(networkOperator.substring(0, 3)); - cell.setMCC(Integer.parseInt(networkOperator.substring(0, 3))); - int mnc = Integer.parseInt(networkOperator.substring(3)); - cell.setMNC(Integer.parseInt(networkOperator.substring(3, 5))); - log.debug("CELL:: mcc=" + mcc + " mnc=" + 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); - } 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().getCID(), - mAimsicdService.getCell().getLAC(), - mAimsicdService.getCell().getMNC(), - mAimsicdService.getCell().getMCC()); - } - } else { - Helpers.sendMsg(this, getString(R.string.no_opencellid_key_detected)); - } - } else if (selectedItem.getId() == DrawerMenu.ID.MAIN.ACD) { + downloadBtsDataIfApiKeyAvailable(); + } else if (selectedItem.getId() == DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS) { if (CellTracker.OCID_API_KEY != null && !CellTracker.OCID_API_KEY.equals("NA")) { //TODO: Use Retrofit for that @@ -391,9 +332,6 @@ public void onResponse(Response response) throws IOException { } else { Helpers.sendMsg(this, getString(R.string.no_opencellid_key_detected)); } - } else if (selectedItem.getId() == DrawerMenu.ID.APPLICATION.SEND_DEBUGGING_LOG) { - Intent i = new Intent(this, DebugLogs.class); - startActivity(i); } else if (selectedItem.getId() == DrawerMenu.ID.APPLICATION.QUIT) { try { if (mAimsicdService.isSmsTracking()) { @@ -423,6 +361,57 @@ public void onResponse(Response response) throws IOException { } } + private void openFragment(Fragment fragment) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); + transaction.replace(R.id.content_frame, fragment); + transaction.addToBackStack(null); + transaction.commit(); + } + + 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) { + int mcc = Integer.parseInt(networkOperator.substring(0, 3)); + cell.setMCC(Integer.parseInt(networkOperator.substring(0, 3))); + int mnc = Integer.parseInt(networkOperator.substring(3)); + cell.setMNC(Integer.parseInt(networkOperator.substring(3, 5))); + log.debug("CELL:: mcc=" + mcc + " mnc=" + 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); + } 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().getCID(), + mAimsicdService.getCell().getLAC(), + mAimsicdService.getCell().getMNC(), + mAimsicdService.getCell().getMCC()); + } + } else { + Helpers.sendMsg(this, getString(R.string.no_opencellid_key_detected)); + } + } + @Override public void processFinish(float[] location) { log.info("processFinish - location[0]=" + location[0] + " location[1]=" + location[1]); @@ -506,10 +495,7 @@ private void startService() { startService(intent); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); - // Display the Device Fragment as the Default View - getSupportFragmentManager().beginTransaction() - .replace(R.id.content_frame, new DetailsContainerFragment()) - .commit(); + openFragment(deviceFragment); } } @@ -533,61 +519,35 @@ public void onPause() { } @Override - public boolean onPrepareOptionsMenu(Menu menu) { - if (mNavConf.getActionMenuItemsToHideWhenDrawerOpen() != null) { - boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); - for (int iItem : mNavConf.getActionMenuItemsToHideWhenDrawerOpen()) { - menu.findItem(iItem).setVisible(!drawerOpen); - } - } - - NavDrawerItem femtoTrackingItem = null; - NavDrawerItem cellMonitoringItem = null; - NavDrawerItem cellTrackingItem = null; - - List menuItems = mNavConf.getNavItems(); - for (NavDrawerItem lItem : menuItems) { - if (lItem.getId() == DrawerMenu.ID.TRACKING.TOGGLE_ATTACK_DETECTION) { - cellMonitoringItem = lItem; - } else if (lItem.getId() == DrawerMenu.ID.TRACKING.TOGGLE_CELL_TRACKING) { - cellTrackingItem = lItem; - } else if (lItem.getId() == DrawerMenu.ID.TRACKING.TRACK_FEMTOCELL) { - femtoTrackingItem = lItem; - } - } - - if (mBound) { - if (cellMonitoringItem != null) { - if (mAimsicdService.isMonitoringCell()) { - cellMonitoringItem.setmIconId(R.drawable.track_cell); - } else { - cellMonitoringItem.setmIconId(R.drawable.untrack_cell); - } - mNavConf.getBaseAdapter().notifyDataSetChanged(); - } - if (cellTrackingItem != null) { - if (mAimsicdService.isTrackingCell()) { - cellTrackingItem.setmIconId(R.drawable.track_cell); - } else { - cellTrackingItem.setmIconId(R.drawable.untrack_cell); - } - mNavConf.getBaseAdapter().notifyDataSetChanged(); - } - - if (femtoTrackingItem != null) { - if (mAimsicdService.isTrackingFemtocell()) { - femtoTrackingItem.setmIconId(R.drawable.ic_action_network_cell); - } else { - femtoTrackingItem.setmIconId(R.drawable.ic_action_network_cell_not_tracked); - } - mNavConf.getBaseAdapter().notifyDataSetChanged(); - } - } - return super.onPrepareOptionsMenu(menu); + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.main_menu, menu); + return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()){ + case R.id.toggle_attack_detection: + monitorCell(); + break; + case R.id.toggle_cell_tracking: + trackCell(); + break; + case R.id.settings: + Intent settingsIntent = new Intent(this, SettingsActivity.class); + startActivity(settingsIntent ); + break; + case R.id.about: + Intent aboutIntent = new Intent(this, AboutActivity.class); + startActivity(aboutIntent); + break; + case R.id.debugging: + Intent i = new Intent(this, DebugLogs.class); + startActivity(i); + break; + } + return mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item); } @@ -634,14 +594,6 @@ private void SmsDetection() { } } - /** - * Show the Map Viewer Activity - */ - private void showMap() { - Intent myIntent = new Intent(this, MapViewerOsmDroid.class); - startActivity(myIntent); - } - /** * Cell Information Tracking - Enable/Disable */ diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/BaseActivity.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/BaseActivity.java index c0f19c2db..74f4063a3 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/BaseActivity.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/BaseActivity.java @@ -29,7 +29,7 @@ public abstract class BaseActivity extends InjectionAppCompatActivity { @Inject - private Logger log; + protected Logger log; /** * Triggered when GUI is opened diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java new file mode 100644 index 000000000..574af0195 --- /dev/null +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java @@ -0,0 +1,636 @@ +/* Android IMSI-Catcher Detector | (c) AIMSICD Privacy Project + * ----------------------------------------------------------- + * LICENSE: http://git.io/vki47 | TERMS: http://git.io/vki4o + * ----------------------------------------------------------- + */ +package com.SecUpwN.AIMSICD.activities; + +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.ServiceConnection; +import android.content.SharedPreferences; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.database.Cursor; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.IBinder; +import android.support.v4.content.LocalBroadcastManager; +import android.telephony.CellInfo; +import android.telephony.PhoneStateListener; +import android.telephony.ServiceState; +import android.telephony.TelephonyManager; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; + +import com.SecUpwN.AIMSICD.AppAIMSICD; +import com.SecUpwN.AIMSICD.BuildConfig; +import com.SecUpwN.AIMSICD.R; +import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter; +import com.SecUpwN.AIMSICD.constants.DBTableColumnIds; +import com.SecUpwN.AIMSICD.constants.TinyDbKeys; +import com.SecUpwN.AIMSICD.map.CellTowerGridMarkerClusterer; +import com.SecUpwN.AIMSICD.map.CellTowerMarker; +import com.SecUpwN.AIMSICD.map.MarkerData; +import com.SecUpwN.AIMSICD.service.AimsicdService; +import com.SecUpwN.AIMSICD.utils.Cell; +import com.SecUpwN.AIMSICD.utils.GeoLocation; +import com.SecUpwN.AIMSICD.utils.Helpers; +import com.SecUpwN.AIMSICD.utils.RequestTask; +import com.SecUpwN.AIMSICD.utils.TinyDB; + +import org.osmdroid.tileprovider.tilesource.TileSourceFactory; +import org.osmdroid.util.GeoPoint; +import org.osmdroid.views.MapView; +import org.osmdroid.views.overlay.ScaleBarOverlay; +import org.osmdroid.views.overlay.compass.CompassOverlay; +import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider; +import org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider; +import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay; + +import java.util.LinkedList; +import java.util.List; + +import io.freefair.android.injection.annotation.Inject; +import io.freefair.android.injection.annotation.InjectView; +import io.freefair.android.injection.annotation.XmlLayout; +import io.freefair.android.injection.app.InjectionAppCompatActivity; +import io.freefair.android.injection.app.InjectionFragment; +import io.freefair.android.util.logging.Logger; + +/** + * Description: TODO: add details + *

+ * Variables: TODO: add a list of variables that can be tuned (Max/MinZoom factors etc) + *

+ * Current Issues: + *

+ * [x] Map is not immediately updated with the BTS info. It take a "long" time ( >10 seconds) + * before map is updated. Any way to shorten this? + * [ ] See: #272 #250 #228 + * [ ] Some pins remain clustered even on the greatest zoom, this is probably + * due to over sized icons, or too low zoom level. + * [x] pin icons are too big. We need to reduce pin dot diameter by ~50% + * [ ] Need a manual way to add GPS coordinates of current location (see code comments below) + * [ ] + *

+ * Notes: + * a) Latest OSM version can use MaxZoomLevel of 21, please see: + * https://github.com/osmdroid/osmdroid/issues/49 + * https://github.com/osmdroid/osmdroid/issues/81 + * https://code.google.com/p/osmbonuspack/issues/detail?id=102 + */ +@XmlLayout(R.layout.activity_map_viewer) +public final class MapFragment extends InjectionFragment implements OnSharedPreferenceChangeListener { + + @Inject + private Logger log; + public static final String updateOpenCellIDMarkers = "update_open_cell_markers"; + + @InjectView(R.id.mapview) + private MapView mMap; + private AIMSICDDbAdapter mDbHelper; + private SharedPreferences prefs; + private AimsicdService mAimsicdService; + private boolean mBound; + + private GeoPoint loc = null; + + private MyLocationNewOverlay mMyLocationOverlay; + private CompassOverlay mCompassOverlay; + private CellTowerGridMarkerClusterer mCellTowerGridMarkerClusterer; + private Menu mOptionsMenu; + TelephonyManager tm; + + private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { + @Override + public void onServiceStateChanged(ServiceState serviceState) { + loadEntries(); + } + + @Override + public void onCellInfoChanged(List cellInfo) { + loadEntries(); + } + }; + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + log.info("Starting MapViewer"); + + setUpMapIfNeeded(); + + mDbHelper = new AIMSICDDbAdapter(getActivity()); + tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); + + // Bind to LocalService + Intent intent = new Intent(getActivity(), AimsicdService.class); + getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); + + TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); + tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION | + PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setHasOptionsMenu(true); + } + + @Override + public void onResume() { + super.onResume(); + setUpMapIfNeeded(); + + prefs = getActivity().getSharedPreferences( + AimsicdService.SHARED_PREFERENCES_BASENAME, 0); + prefs.registerOnSharedPreferenceChangeListener(this); + + LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, + new IntentFilter(updateOpenCellIDMarkers)); + + if (!mBound) { + // Bind to LocalService + Intent intent = new Intent(getActivity(), AimsicdService.class); + getActivity().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); + } + + loadPreferences(); + loadEntries(); + + if (mCompassOverlay != null) { + mCompassOverlay.enableCompass(); + } + + if (mMyLocationOverlay != null) { + mMyLocationOverlay.enableMyLocation(); + } + } + + + @Override + public void onDestroyView() { + super.onDestroy(); + + LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mMessageReceiver); + if (mCompassOverlay != null) { + mCompassOverlay.disableCompass(); + } + + if (mMyLocationOverlay != null) { + mMyLocationOverlay.disableMyLocation(); + } + + prefs.unregisterOnSharedPreferenceChangeListener(this); + // Unbind from the service + if (mBound) { + getActivity().unbindService(mConnection); + mBound = false; + } + + TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); + tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); + + LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mMessageReceiver); + } + + private final BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + loadEntries(); + if (BuildConfig.DEBUG && mCellTowerGridMarkerClusterer != null && mCellTowerGridMarkerClusterer.getItems() != null) { + log.verbose("mMessageReceiver CellTowerMarkers.invalidate() markers.size():" + mCellTowerGridMarkerClusterer.getItems().size()); + } + + } + }; + + /** + * Service Connection to bind the activity to the service + *

+ * This seem to setup the connection and animates the map window movement to the + * last known location. + */ + private final ServiceConnection mConnection = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + // We've bound to LocalService, cast the IBinder and get LocalService instance + mAimsicdService = ((AimsicdService.AimscidBinder) service).getService(); + mBound = true; + + // setup map + GeoLocation lastKnown = mAimsicdService.lastKnownLocation(); + if (lastKnown != null) { + mMap.getController().setZoom(16); // Initial Zoom level + mMap.getController().animateTo(new GeoPoint( + lastKnown.getLatitudeInDegrees(), + lastKnown.getLongitudeInDegrees())); + } + } + + @Override + public void onServiceDisconnected(ComponentName arg0) { + log.error("Service Disconnected"); + mBound = false; + } + }; + + // Load the default map type from preferences + private void loadPreferences() { + String mapTypePref = getResources().getString(R.string.pref_map_type_key); + prefs = getActivity().getSharedPreferences( + AimsicdService.SHARED_PREFERENCES_BASENAME, 0); + if (prefs.contains(mapTypePref)) { + int mapType = Integer.parseInt(prefs.getString(mapTypePref, "0")); + setupMapType(mapType); + } + } + + private void setupMapType(int mapType) { + mMap.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE); + // There are two other map types (hybrid and satellite), but we don't use them + // as they are redundant (hybrid) and broken (satellite). + switch (mapType) { + case 0: + mMap.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE); + break; + case 1: + mMap.setTileSource(TileSourceFactory.CYCLEMAP); + break; + default: + mMap.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE); + break; + } + } + + /** + * Description: Initialises the Map and sets initial options such as: + * Zoom levels and controls + * Compass + * ScaleBar + * Cluster Pin colors + * Location update settings + */ + private void setUpMapIfNeeded() { + + // Check if we were successful in obtaining the map. + mMap.setBuiltInZoomControls(true); + mMap.setMultiTouchControls(true); + mMap.setMinZoomLevel(3); + mMap.setMaxZoomLevel(19); // Latest OSM can go to 21! + mMap.getTileProvider().createTileCache(); + mCompassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), mMap); + + ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(getActivity()); + mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10); + mScaleBarOverlay.setCentred(true); + + // Sets cluster pin color + mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(getActivity()); + BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange); + mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap()); + + GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(getActivity().getBaseContext()); + gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m] // Set the minimum distance for location updates + gpsMyLocationProvider.setLocationUpdateMinTime(10000); // [ms] // Set the minimum time interval for location updates + mMyLocationOverlay = new MyLocationNewOverlay(getActivity().getBaseContext(), gpsMyLocationProvider, mMap); + mMyLocationOverlay.setDrawAccuracyEnabled(true); + + mMap.getOverlays().add(mCellTowerGridMarkerClusterer); + mMap.getOverlays().add(mMyLocationOverlay); + mMap.getOverlays().add(mCompassOverlay); + mMap.getOverlays().add(mScaleBarOverlay); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return super.onCreateView(inflater, container, savedInstanceState); + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + this.mOptionsMenu = menu; + inflater.inflate(R.menu.fragment_map_menu, mOptionsMenu); + } + + @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); + return true; + } + } + + if (loc != null) { + Helpers.msgLong(getActivity(), getString(R.string.contacting_opencellid_for_data)); + Cell cell = new Cell(); + cell.setLat(loc.getLatitude()); + cell.setLon(loc.getLongitude()); + setRefreshActionButtonState(true); + TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false); + Helpers.getOpenCellData((InjectionAppCompatActivity)getActivity(), cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP); + } else { + Helpers.msgLong(getActivity(), + getString(R.string.unable_to_determine_last_location)); + } + return true; + } + default: + return super.onOptionsItemSelected(item); + } + } + + /** + * Description: Loads Signal Strength Database details to plot on the map, + * only entries which have a location (lon, lat) are used. + */ + private void loadEntries() { + + new AsyncTask() { + @Override + protected GeoPoint doInBackground(Void... voids) { + //int signal; + + mCellTowerGridMarkerClusterer.getItems().clear(); + + //New function only gets bts from DBe_import by sim network + loadOcidMarkersByNetwork(); + + List items = new LinkedList<>(); + + Cursor c = null; + try { + // Grab cell data from CELL_TABLE (cellinfo) --> DBi_bts + c = mDbHelper.getCellData(); + } catch (IllegalStateException ix) { + log.error("Problem getting data from CELL_TABLE", ix); + } + + /* + This function is getting cells we logged from DBi_bts + */ + if (c != null && c.moveToFirst()) { + do { + if (isCancelled()) { + return null; + } + // The indexing here is that of DB table + final int cellID = c.getInt(c.getColumnIndex(DBTableColumnIds.DBI_BTS_CID)); // CID + final int lac = c.getInt(c.getColumnIndex(DBTableColumnIds.DBI_BTS_LAC)); // LAC + final int mcc = c.getInt(c.getColumnIndex(DBTableColumnIds.DBI_BTS_MCC)); // MCC + final int mnc = c.getInt(c.getColumnIndex(DBTableColumnIds.DBI_BTS_MNC)); // MNC + final double dLat = c.getDouble(c.getColumnIndex(DBTableColumnIds.DBI_BTS_LAT)); // Lat + final double dLng = c.getDouble(c.getColumnIndex(DBTableColumnIds.DBI_BTS_LON)); // Lon + + if (Double.doubleToRawLongBits(dLat) == 0 + && Double.doubleToRawLongBits(dLng) == 0) { + continue; + } + // TODO this (signal) is not in DBi_bts + // signal = 1; + //c.getInt(c.getColumnIndex(DBTableColumnIds.DBE_IMPORT_AVG_SIGNAL)); // signal + // In case of missing or negative signal, set a default fake signal, + // so that we can still draw signal circles. ? + //if (signal <= 0) { + // signal = 20; + //} + + if (Double.doubleToRawLongBits(dLat) != 0 + || Double.doubleToRawLongBits(dLng) != 0) { + loc = new GeoPoint(dLat, dLng); + + CellTowerMarker ovm = new CellTowerMarker(getActivity(), mMap, + "Cell ID: " + cellID, + "", loc, + new MarkerData( + String.valueOf(cellID), + String.valueOf(loc.getLatitude()), + String.valueOf(loc.getLongitude()), + String.valueOf(lac), + String.valueOf(mcc), + String.valueOf(mnc), + "", false) + ); + // The pin of our current position + ovm.setIcon(getResources().getDrawable(R.drawable.ic_map_pin_blue)); + + items.add(ovm); + } + + } while (c.moveToNext()); + } else { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + Helpers.msgLong(getActivity(), getString(R.string.no_tracked_locations_found)); + } + }); + } + + GeoPoint ret = new GeoPoint(0, 0); + if (mBound) { + try { + int mcc = mAimsicdService.getCell().getMCC(); + double[] d = mDbHelper.getDefaultLocation(mcc); + ret = new GeoPoint(d[0], d[1]); + } catch (Exception e) { + log.error("Error getting default location!", e); + } + } + if (c != null) { + c.close(); + } + // plot neighbouring cells + while (mAimsicdService == null) { + try { + if (isCancelled()) { + return null; + } + Thread.sleep(100); + } catch (InterruptedException e) { + log.warn("thread interrupted", e); + } + } + List nc = mAimsicdService.getCellTracker().updateNeighbouringCells(); + for (Cell cell : nc) { + if (isCancelled()) { + return null; + } + try { + loc = new GeoPoint(cell.getLat(), cell.getLon()); + CellTowerMarker ovm = new CellTowerMarker(getActivity(), mMap, + getString(R.string.cell_id_label) + cell.getCID(), + "", loc, + new MarkerData( + String.valueOf(cell.getCID()), + String.valueOf(loc.getLatitude()), + String.valueOf(loc.getLongitude()), + String.valueOf(cell.getLAC()), + String.valueOf(cell.getMCC()), + String.valueOf(cell.getMNC()), + "", false)); + + // The pin of other BTS + ovm.setIcon(getResources().getDrawable(R.drawable.ic_map_pin_orange)); + items.add(ovm); + } catch (Exception e) { + log.error("Error plotting neighbouring cells", e); + } + } + + mCellTowerGridMarkerClusterer.addAll(items); + + return ret; + } + + /** + * TODO: We need a manual way to add our own location in case: + * a) GPS is jammed or not working + * b) WiFi location is not used + * c) Default MCC is too far off + * + * @param defaultLoc Default location to open map on + */ + @Override + protected void onPostExecute(GeoPoint defaultLoc) { + if (loc != null && (Double.doubleToRawLongBits(loc.getLatitude()) != 0 + && Double.doubleToRawLongBits(loc.getLongitude()) != 0)) { + mMap.getController().setZoom(16); + mMap.getController().animateTo(new GeoPoint(loc.getLatitude(), loc.getLongitude())); + } else { + if (mBound) { + // Try and find last known location and zoom there + GeoLocation lastLoc = mAimsicdService.lastKnownLocation(); + if (lastLoc != null) { + loc = new GeoPoint(lastLoc.getLatitudeInDegrees(), + lastLoc.getLongitudeInDegrees()); + + mMap.getController().setZoom(16); + mMap.getController().animateTo(new GeoPoint(loc.getLatitude(), loc.getLongitude())); + } else { + //Use MCC to move camera to an approximate location near Countries Capital + loc = defaultLoc; + + mMap.getController().setZoom(12); + mMap.getController().animateTo(new GeoPoint(loc.getLatitude(), loc.getLongitude())); + } + } + } + if (mCellTowerGridMarkerClusterer != null) { + if (BuildConfig.DEBUG && mCellTowerGridMarkerClusterer.getItems() != null) { + log.verbose("CellTowerMarkers.invalidate() markers.size():" + mCellTowerGridMarkerClusterer.getItems().size()); + } + //Drawing markers of cell tower immediately as possible + mCellTowerGridMarkerClusterer.invalidate(); + } + } + }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + + private void loadOcidMarkersByNetwork() { + // Check if OpenCellID data exists and if so load this now + List 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)); + } + // DBe_import tower pins. + Drawable cellTowerMarkerIcon = getResources().getDrawable(R.drawable.ic_map_pin_green); + + Cursor c = mDbHelper.returnOcidBtsByNetwork(currentMmc, currentMnc); + if (c.moveToFirst()) { + do { + // CellID,Lac,Mcc,Mnc,Lat,Lng,AvgSigStr,Samples + final int cellID = c.getInt(c.getColumnIndex(DBTableColumnIds.DBE_IMPORT_CID)); + final int lac = c.getInt(c.getColumnIndex(DBTableColumnIds.DBE_IMPORT_LAC)); + final int mcc = c.getInt(c.getColumnIndex(DBTableColumnIds.DBE_IMPORT_MCC)); + final int mnc = c.getInt(c.getColumnIndex(DBTableColumnIds.DBE_IMPORT_MNC)); + final double dLat = Double.parseDouble(c.getString(c.getColumnIndex(DBTableColumnIds.DBE_IMPORT_GPS_LAT))); + final double dLng = Double.parseDouble(c.getString(c.getColumnIndex(DBTableColumnIds.DBE_IMPORT_GPS_LON))); + final GeoPoint location = new GeoPoint(dLat, dLng); + //where is c.getString(6)AvgSigStr + final int samples = c.getInt(c.getColumnIndex(DBTableColumnIds.DBE_IMPORT_SAMPLES)); + // Add map marker for CellID + CellTowerMarker ovm = new CellTowerMarker(getActivity(), mMap, + "Cell ID: " + cellID, + "", location, + new MarkerData( + String.valueOf(cellID), + String.valueOf(location.getLatitude()), + String.valueOf(location.getLongitude()), + String.valueOf(lac), + String.valueOf(mcc), + String.valueOf(mnc), + String.valueOf(samples), + false)); + + ovm.setIcon(cellTowerMarkerIcon); + items.add(ovm); + } while (c.moveToNext()); + } + c.close(); + + mCellTowerGridMarkerClusterer.addAll(items); + } + + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + final String KEY_MAP_TYPE = getActivity().getBaseContext().getString(R.string.pref_map_type_key); + if (key.equals(KEY_MAP_TYPE)) { + int item = Integer.parseInt(sharedPreferences.getString(key, "0")); + setupMapType(item); + } + } + + public void setRefreshActionButtonState(final boolean refreshing) { + if (mOptionsMenu != null) { + final MenuItem refreshItem = mOptionsMenu.findItem(R.id.get_opencellid); + if (refreshItem != null) { + if (refreshing) { + refreshItem.setActionView(R.layout.actionbar_indeterminate_progress); + } else { + refreshItem.setActionView(null); + } + } + } + } + + + @Override + public void onStart() { + super.onStart(); + ((AppAIMSICD) getActivity().getApplication()).attach((InjectionAppCompatActivity) getActivity()); + if (TinyDB.getInstance().getBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP)) { + setRefreshActionButtonState(false); + } + } +} diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/SettingsActivity.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/SettingsActivity.java new file mode 100644 index 000000000..1b9e32860 --- /dev/null +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/SettingsActivity.java @@ -0,0 +1,30 @@ +/* Android IMSI-Catcher Detector | (c) AIMSICD Privacy Project + * ----------------------------------------------------------- + * LICENSE: http://git.io/vki47 | TERMS: http://git.io/vki4o + * ----------------------------------------------------------- + */ +package com.SecUpwN.AIMSICD.activities; + +import android.app.FragmentManager; +import android.app.FragmentTransaction; +import android.os.Bundle; + +import com.SecUpwN.AIMSICD.fragments.SettingsFragment; + + +public class SettingsActivity extends BaseActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + loadFragment(); + } + + private void loadFragment() { + SettingsFragment settingsFragment = new SettingsFragment(); + FragmentManager fragmentManager = getFragmentManager(); + FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); + fragmentTransaction.replace(android.R.id.content, settingsFragment); + fragmentTransaction.commit(); + } +} diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java index b1bb9945e..5e10edf25 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java @@ -249,7 +249,7 @@ public int deleteCell(int cellId) { * whereas in the getOpenCellIDData() cursor, they are arranged as: * CellID,Lac,Mcc,Mnc,Lat,Lng,AvgSigStr,Samples * - * Thus when used in MapViewerOsmDroid.java at loadEntries() and + * Thus when used in MapFragment.java at loadEntries() and * loadOpenCellIDMarkers(), the index used there is completely different * than what could be expected. * @@ -265,7 +265,7 @@ public int deleteCell(int cellId) { /** * Returns Cell Information (DBi_bts) database contents * this returns BTSs that we logged and is called from - * MapViewerOsmDroid.java to display cells on map + * MapFragment.java to display cells on map */ public Cursor getCellData() { return returnDBiBts(); @@ -1232,7 +1232,7 @@ public Cursor returnDefaultLocation() { *

* Used in: * DbViewerFragment.java - * MapViewerOsmDroid.java + * MapFragment.java *

* Returned Columns: * "_id" INTEGER PRIMARY KEY AUTOINCREMENT, diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/constants/DrawerMenu.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/constants/DrawerMenu.java index 7d8ba8281..d028a2298 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/constants/DrawerMenu.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/constants/DrawerMenu.java @@ -22,7 +22,7 @@ public static class ID { */ public static final int SECTION_MAIN = 10; public static final int SECTION_TRACKING = 20; - public static final int SECTION_SETTINGS = 30; + public static final int SECTION_DATABASE_SETTINGS = 30; public static final int SECTION_APPLICATION = 40; /** @@ -32,7 +32,7 @@ public static class MAIN { public static final int CURRENT_TREAT_LEVEL = 100; //Current Threat Level public static final int PHONE_SIM_DETAILS = 110; //Phone/SIM Details - public static final int ACD = 120; //All Current Cell Details (ACD) + public static final int ALL_CURRENT_CELL_DETAILS = 120; //All Current Cell Details public static final int DB_VIEWER = 130; //Database Viewer public static final int ANTENNA_MAP_VIEW = 140; // Antenna Map View public static final int AT_COMMAND_INTERFACE = 150; //AT Command Interface diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/drawer/DrawerMenuActivityConfiguration.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/drawer/DrawerMenuActivityConfiguration.java index 92f1cc1ed..0b4235163 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/drawer/DrawerMenuActivityConfiguration.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/drawer/DrawerMenuActivityConfiguration.java @@ -106,19 +106,13 @@ public DrawerMenuActivityConfiguration build() { menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_MAIN, mContext.getString(R.string.main))); menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.PHONE_SIM_DETAILS, mContext.getString(R.string.device_info), R.drawable.ic_action_phone, true)); // Phone/SIM Details menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.CURRENT_TREAT_LEVEL, mContext.getString(R.string.cell_info_title), R.drawable.cell_tower, true)); // Cell Information (Neighboring cells etc) - menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.ACD, mContext.getString(R.string.cell_lookup), R.drawable.stat_sys_download_anim0, false)); // Lookup "All Current Cell Details (ACD)" + menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS, mContext.getString(R.string.cell_lookup), R.drawable.stat_sys_download_anim0, false)); // Lookup "All Current Cell Details (ALL_CURRENT_CELL_DETAILS)" menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.DB_VIEWER, mContext.getString(R.string.db_viewer), R.drawable.ic_action_storage, true)); // Database Viewer menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.ANTENNA_MAP_VIEW, mContext.getString(R.string.map_view), R.drawable.ic_action_map, false)); // Antenna Map Viewer menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.AT_COMMAND_INTERFACE, mContext.getString(R.string.at_command_title), R.drawable.ic_action_computer, true)); // AT Command Interface - //Section Tracking - menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_TRACKING, mContext.getString(R.string.tracking))); - menu.add(DrawerMenuItem.create(DrawerMenu.ID.TRACKING.TOGGLE_ATTACK_DETECTION, mContext.getString(R.string.toggle_attack_detection), R.drawable.untrack_cell, false)); // Toggle "Attack Detection" - menu.add(DrawerMenuItem.create(DrawerMenu.ID.TRACKING.TOGGLE_CELL_TRACKING, mContext.getString(R.string.toggle_cell_tracking), R.drawable.untrack_cell, false)); // Toggle "Cell Tracking" - //Section Settings - menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_SETTINGS, mContext.getString(R.string.settings))); - menu.add(DrawerMenuItem.create(DrawerMenu.ID.SETTINGS.PREFERENCES, mContext.getString(R.string.preferences), R.drawable.ic_action_settings, false)); // Preferences + menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_DATABASE_SETTINGS, mContext.getString(R.string.database_settings))); menu.add(DrawerMenuItem.create(DrawerMenu.ID.SETTINGS.BACKUP_DB, mContext.getString(R.string.backup_database), R.drawable.ic_action_import_export, false)); // Backup Database menu.add(DrawerMenuItem.create(DrawerMenu.ID.SETTINGS.RESTORE_DB, mContext.getString(R.string.restore_database), R.drawable.ic_action_import_export, false)); // Restore Database menu.add(DrawerMenuItem.create(DrawerMenu.ID.SETTINGS.RESET_DB, mContext.getString(R.string.clear_database), R.drawable.ic_action_delete_database, false)); // Reset Database @@ -127,8 +121,6 @@ public DrawerMenuActivityConfiguration build() { menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_APPLICATION, mContext.getString(R.string.application))); menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.DOWNLOAD_LOCAL_BTS_DATA, mContext.getString(R.string.get_opencellid), R.drawable.stat_sys_download_anim0, false)); // "Download Local BTS data" menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.UPLOAD_LOCAL_BTS_DATA, mContext.getString(R.string.upload_bts), R.drawable.stat_sys_upload_anim0, false)); // "Upload Local BTS data" - menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.ABOUT, mContext.getString(R.string.about_aimsicd), R.drawable.ic_action_about, true)); // About - menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.SEND_DEBUGGING_LOG, mContext.getString(R.string.send_logs), R.drawable.ic_action_computer, false)); // Debugging menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.QUIT, mContext.getString(R.string.quit), R.drawable.ic_action_remove, false)); // Quit mNavItems = menu; diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/drawer/DrawerMenuItem.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/drawer/DrawerMenuItem.java index 9a42158de..a328ee9e9 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/drawer/DrawerMenuItem.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/drawer/DrawerMenuItem.java @@ -104,7 +104,7 @@ public int getHelpStringId() { case MAIN.CURRENT_TREAT_LEVEL: return R.string.help_main_current_threat_level; - case MAIN.ACD: + case MAIN.ALL_CURRENT_CELL_DETAILS: return R.string.help_main_acd; case MAIN.DB_VIEWER: diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/AtCommandFragment.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/AtCommandFragment.java new file mode 100644 index 000000000..997fddadd --- /dev/null +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/AtCommandFragment.java @@ -0,0 +1,442 @@ +/* Android IMSI-Catcher Detector | (c) AIMSICD Privacy Project + * ----------------------------------------------------------- + * LICENSE: http://git.io/vki47 | TERMS: http://git.io/vki4o + * ----------------------------------------------------------- + */ +package com.SecUpwN.AIMSICD.fragments; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.text.Editable; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.RelativeLayout; +import android.widget.Spinner; +import android.widget.TextView; + +import com.SecUpwN.AIMSICD.R; +import com.SecUpwN.AIMSICD.utils.Helpers; +import com.SecUpwN.AIMSICD.utils.atcmd.AtCommandTerminal; +import com.SecUpwN.AIMSICD.utils.atcmd.TtyPrivFile; +import com.stericson.RootShell.RootShell; +import com.stericson.RootShell.execution.Command; +import com.stericson.RootShell.execution.Shell; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import io.freefair.android.injection.annotation.Inject; +import io.freefair.android.injection.annotation.InjectView; +import io.freefair.android.injection.annotation.XmlLayout; +import io.freefair.android.injection.app.InjectionAppCompatActivity; +import io.freefair.android.injection.app.InjectionFragment; +import io.freefair.android.util.logging.Logger; + + +/** + * Description: This is the AT Command Interface or AT Command Processor (ATCoP) that + * allow the user to communicate directly to the baseband processor (BP), + * via old-school AT commands. This can be very useful for debugging radio + * related network problems on those devices that are using this interface. + * The most common baseband hardware that allow for this are those made by + * Qualcomm (MSM) or Mediatek (MTK). Intel XMM based devices have been found + * very difficult or impossible to use this, especailly on Samsung devices. + * + * Requirements: 1) You need to have supported hardware that already has an AT serial device + * enumerated in the Android /dev tree. Some common ones are: + * Qualcomm: /dev/smd[0,7] + * MTK: /dev/radio/atci[0-9] + * XMM: TBA + * + * 2) You need to be rooted as this interface is using a persistent root shell. + * + * Issues: + * [ ] Need to increase time for long AT commands like "AT+COPS=?" (~30 sec) + * [ ] Need a "no" timeout to watch output for while, or let's make it 10 minutes. + * Perhaps with a manual stop? + */ +@XmlLayout(R.layout.activity_at_command) +public class AtCommandFragment extends InjectionFragment { + + @Inject + private Logger log; + + //Return value constants + private static final int SERIAL_INIT_OK = 100; + private static final int SERIAL_INIT_ERROR = 101; + private static final int ROOT_UNAVAILABLE = 102; + private static final int BUSYBOX_UNAVAILABLE = 103; + private static final List mSerialDevices = new ArrayList<>(); + + private String mSerialDevice; + private int mTimeout; + + @InjectView(R.id.atcommandView) + private RelativeLayout mAtCommandLayout; + + @InjectView(R.id.at_command_error) + private TextView mAtCommandError; + + @InjectView(R.id.serial_device) + private TextView mSerialDeviceDisplay; + + @InjectView(R.id.response) + private TextView mAtResponse; + + @InjectView(R.id.at_command) + private EditText mAtCommand; + + @InjectView(R.id.serial_device_spinner) + private Spinner mSerialDeviceSpinner; + + @InjectView(R.id.serial_device_spinner_title) + private TextView mSerialDeviceSpinnerLabel; + + private AtCommandTerminal mCommandTerminal; + + @InjectView(R.id.timeout_spinner) + private Spinner timeoutSpinner; + + @InjectView(R.id.execute) + private Button atCommandExecute; + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + atCommandExecute.setOnClickListener(new btnClick()); + mSerialDeviceSpinner.setOnItemSelectedListener(new spinnerListener()); + timeoutSpinner.setOnItemSelectedListener(new timeoutSpinnerListener()); + timeoutSpinner.setSelection(1); + mTimeout = 5000; + } + + private class timeoutSpinnerListener implements AdapterView.OnItemSelectedListener { + + @Override + public void onItemSelected(AdapterView parentView, View selectedItemView, + int position, long id) { + switch (position) { + // Don't forget to also change the arrays.xml + case 0: //2 seconds + mTimeout = 2000; + break; + case 1: //5 seconds + mTimeout = 5000; + break; + case 2: //10 seconds + mTimeout = 10000; + break; + case 3: //20 seconds + mTimeout = 20000; + break; + case 4: //30 seconds + mTimeout = 30000; + break; + case 5: // No timeout, when watching output... + mTimeout = 600000; // Well, ok, 10 min + break; + default: + mTimeout = 5000; + } + } + + @Override + public void onNothingSelected(AdapterView parentView) { + } + } + + private class spinnerListener implements AdapterView.OnItemSelectedListener { + + @Override + public void onItemSelected(AdapterView parentView, View selectedItemView, + int position, long id) { + mSerialDevice = String.valueOf(mSerialDeviceSpinner.getSelectedItem()); + mSerialDeviceDisplay.setText(mSerialDevice); + setSerialDevice(); + } + + @Override + public void onNothingSelected(AdapterView parentView) { + + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + if (mCommandTerminal != null) { + mCommandTerminal.dispose(); + } + } + + @Override + public void onResume() { + super.onResume(); + + int serialDevice = initSerialDevice(); + + switch (serialDevice) { + case SERIAL_INIT_OK: + mAtCommandLayout.setVisibility(View.VISIBLE); + break; + case ROOT_UNAVAILABLE: + mAtCommandError.setText(R.string.unable_to_acquire_root_access); + break; + case BUSYBOX_UNAVAILABLE: + mAtCommandError.setText(R.string.unable_to_detect_busybox); + break; + case SERIAL_INIT_ERROR: + mAtCommandError.setText(R.string.unknown_error_trying_to_acquire_serial_device); + break; + default: + mAtCommandError.setText(R.string.unknown_error_initialising_at_command_injector); + break; + } + + } + + private class btnClick implements View.OnClickListener { + + @Override + public void onClick(View v) { + if (mAtCommand.getText() != null) { + String command = mAtCommand.getText().toString(); + log.info("AT Command Detected: " + command); + executeAT(); + } + } + } + + /** + * Description: This is looking for possible serial devices that may be used for ATCoP. + * + * Issues: This is generally not working since it is very HW and SW dependent. + * + * + * @return + */ + private int initSerialDevice() { + + /** + * NOTE: + * + * Because of how RootShell is being used the handler has to be disabled. + * + * With the handler disabled absolutely NO UI work can be done in the callback methods + * since they will be called on a separate thread. + * + * To work around this, either: + * + * a) Execute all Shell commands in a thread, such as AsyncTask + * OR + * b) Stop using commandWait (which is a no no...you should never sleep on the + * main UI thread) and implement the callback commandFinished/commandTerminated + * to determine when to continue on. + * + */ + RootShell.handlerEnabled = false; + + // Check for root access + boolean root = RootShell.isAccessGiven(); + if (!root) { + return ROOT_UNAVAILABLE; + } + + // Check if Busybox is installed + boolean busybox = RootShell.isBusyboxAvailable(); + if (!busybox) { + return BUSYBOX_UNAVAILABLE; + } + + try { + mAtResponse.setText(R.string.at_command_response_looking); + mSerialDevices.clear(); + + // THIS IS A BAD IDEA TODO: Consider removing + // Use RIL Serial Device details from the System Property + try { + String rilDevice = Helpers.getSystemProp(getActivity(), "rild.libargs", "UNKNOWN"); + mSerialDevice = ("UNKNOWN".equals(rilDevice) ? rilDevice : rilDevice.substring(3)); + + if (!"UNKNOWN".equals(mSerialDevice)) { + mSerialDevices.add(mSerialDevice); + } + } catch (StringIndexOutOfBoundsException e) { + log.warn(e.getMessage()); + // ignore, move on + } + + //================================================================== + // WARNING: Scraping commands can be masked by aliases in: mkshrc + // and even hardcoded in the sh binary or elsewhere. + // To get unaliased versions, use: "\\" + //================================================================== + + for (File file : new File("/dev").listFiles()) { + String name = file.getName(); + boolean add = false; + // QC: /dev/smd[0-7] + if (name.matches("^smd.$")) { + add = true; + } else if ("radio".equals(name)) { + // MTK: /dev/radio/*atci* + for (File subfile : file.listFiles()) { + String subname = subfile.getName(); + if (subname.contains("atci")) { + add = true; + file = subfile; + } + } + } + + if (add) { + mSerialDevices.add(file.getAbsolutePath()); + mAtResponse.append(getString(R.string.at_command_response_found) + file.getAbsolutePath() + "\n"); + } + } + + // Now try XMM/XGOLD modem config + File xgold = new File("/system/etc/ril_xgold_radio.cfg"); + if (xgold.exists() && xgold.isFile()) { + Command cmd = new Command(1, "\\cat /system/etc/ril_xgold_radio.cfg | " + + "\\grep -E \"atport*|dataport*\"") { + + @Override + public void commandOutput(int id, String line) { + if (id == 0) { + if (!line.trim().isEmpty() && line.contains("/dev/")) { + int place = line.indexOf("=") + 1; + mSerialDevices.add(line.substring(place, line.length() - 1)); + mAtResponse.append(getString(R.string.at_command_response_found)+line.substring(place, line.length() - 1) + "\n"); + } + } + super.commandOutput(id, line); + } + }; + + Shell shell = RootShell.getShell(true); + shell.add(cmd); + commandWait(shell, cmd); + } + + } catch (Exception e) { + log.error("InitSerialDevice ", e); + } + + if (!mSerialDevices.isEmpty()) { + String[] entries = new String[mSerialDevices.size()]; + entries = mSerialDevices.toArray(entries); + ArrayAdapter spinnerAdapter = new ArrayAdapter<>(getActivity(), + android.R.layout.simple_spinner_item, entries); + mSerialDeviceSpinner.setAdapter(spinnerAdapter); + mSerialDeviceSpinner.setVisibility(View.VISIBLE); + mSerialDeviceSpinnerLabel.setVisibility(View.VISIBLE); + } + + mAtResponse.append(getString(R.string.at_command_response_setup_complete)); + mAtResponse.setVisibility(View.VISIBLE); + + return SERIAL_INIT_OK; + } + + private void setSerialDevice() { + if (mCommandTerminal != null) { + mCommandTerminal.dispose(); + mCommandTerminal = null; + } + } + + private AtCommandTerminal getSerialDevice() { + if (mCommandTerminal == null) { + try { + mCommandTerminal = new TtyPrivFile(mSerialDevice); + return mCommandTerminal; + } catch (IOException e) { + mAtResponse.append(e.toString()); + } + } else { + return mCommandTerminal; + } + return null; + } + + private void executeAT() { + // It seem that MTK devices doesn't need "\r" but QC devices do. + // We need a device-type check here, perhaps: gsm.version.ril-impl. + Editable cmd = mAtCommand.getText(); + if (cmd != null && cmd.length() != 0) { + log.debug("ExecuteAT: attempting to send: " + cmd.toString()); + + if (getSerialDevice() != null) { + mCommandTerminal.send(cmd.toString(), new Handler(Looper.getMainLooper()) { + @Override + public void handleMessage(Message message) { + if (message.obj instanceof List) { + List lines = ((List) message.obj); + StringBuffer response = new StringBuffer(); + for (String line : lines) { + response.append(line); + response.append('\n'); + } + if (response.length() != 0) { + mAtResponse.append(response); + } + + } else if (message.obj instanceof IOException) { + mAtResponse.append("IOException: " + ((IOException) message.obj).getMessage() + "\n"); + } + } + }.obtainMessage()); + } + } + + } + + /** + * This below method is part of the RootTools Project: https://github.com/Stericson/RootTools + * Copyright (c) 2012 Stephen Erickson, Chris Ravenscroft, Dominik Schuermann, Adam Shanks + * + * Slightly modified commandWait method as found in RootToolsInternalMethods.java to utilise + * the user selected timeout value. + * + */ + private void commandWait(Shell shell, Command cmd) throws Exception { + while (!cmd.isFinished()) { + synchronized (cmd) { + try { + if (!cmd.isFinished()) { + cmd.wait(mTimeout); + } + } catch (InterruptedException e) { + log.error(e.getMessage()); + } + } + if (!cmd.isExecuting() && !cmd.isFinished()) { + Exception e = new Exception(); + + if (!shell.isExecuting && !shell.isReading) { + log.warn("Waiting for a command to be executed in a shell that is not executing and not reading! \n\n Command: " + cmd.getCommand()); + e.setStackTrace(Thread.currentThread().getStackTrace()); + log.error(e.getMessage(), e); + + } else if (shell.isExecuting && !shell.isReading) { + log.error("Waiting for a command to be executed in a shell that is executing but not reading! \n\n Command: " + cmd.getCommand()); + e.setStackTrace(Thread.currentThread().getStackTrace()); + log.error(e.getMessage(), e); + + } else { + log.error("Waiting for a command to be executed in a shell that is not reading! \n\n Command: " + cmd.getCommand()); + e.setStackTrace(Thread.currentThread().getStackTrace()); + log.error(e.getMessage(), e); + } + } + } + } +} diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java index 0c3cfd66e..0fe9eccd7 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java @@ -41,9 +41,9 @@ public class DeviceFragment extends InjectionFragment { private Context mContext; @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - mContext = activity.getBaseContext(); + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + mContext = getActivity().getBaseContext(); // Bind to LocalService Intent intent = new Intent(mContext, AimsicdService.class); mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/SettingsFragment.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/SettingsFragment.java new file mode 100644 index 000000000..e9bb94173 --- /dev/null +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/SettingsFragment.java @@ -0,0 +1,82 @@ +/* Android IMSI-Catcher Detector | (c) AIMSICD Privacy Project + * ----------------------------------------------------------- + * LICENSE: http://git.io/vki47 | TERMS: http://git.io/vki4o + * ----------------------------------------------------------- + */ +package com.SecUpwN.AIMSICD.fragments; + +import android.content.Context; +import android.content.Intent; +import android.location.LocationManager; +import android.os.Bundle; +import android.preference.CheckBoxPreference; +import android.preference.Preference; +import android.preference.PreferenceFragment; +import android.util.Log; + +import com.SecUpwN.AIMSICD.R; + +public class SettingsFragment extends PreferenceFragment { + + + CheckBoxPreference gpsPref; + LocationManager locationManager; + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.preferences); + final String gps_key=getResources().getString(R.string.pref_enable_gps_key); + locationManager=(LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE); + + gpsPref=(CheckBoxPreference)findPreference(gps_key); + gpsPref.setDefaultValue(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)); + gpsPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + + Intent gpsSettings = new Intent( + android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); + startActivityForResult(gpsSettings, 1); + if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { + gpsPref.setChecked(true); + return true; + } + + gpsPref.setChecked(false); + return false; + + } + + }); + + + gpsPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + + if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { + Log.e("pref", "changed to " + newValue); + preference.setDefaultValue(newValue); + return true; + } + + preference.setDefaultValue(newValue); + return false; + } + }); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == 1) { + if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { + gpsPref.setChecked(true); + gpsPref.setDefaultValue(true); + } else { + gpsPref.setDefaultValue(false); + gpsPref.setChecked(false); + } + } + } +} diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/BaseAsyncTask.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/BaseAsyncTask.java index e11e3ee15..7002c996b 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/BaseAsyncTask.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/BaseAsyncTask.java @@ -56,7 +56,7 @@ protected void onCancelled() { mApp.removeTask(this); } - protected Activity getActivity() { + protected InjectionAppCompatActivity getActivity() { return mWeakReferenceActivity.get(); } diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java index 1bd538796..121a634e0 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java @@ -24,11 +24,13 @@ import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.support.v4.app.Fragment; import android.text.TextUtils; import com.SecUpwN.AIMSICD.R; -import com.SecUpwN.AIMSICD.activities.MapViewerOsmDroid; +import com.SecUpwN.AIMSICD.activities.MapFragment; import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter; +import com.SecUpwN.AIMSICD.constants.DrawerMenu; import com.SecUpwN.AIMSICD.service.AimsicdService; import com.SecUpwN.AIMSICD.service.CellTracker; @@ -227,15 +229,18 @@ public static void getOpenCellData(InjectionAppCompatActivity injectionActivity, new RequestTask(injectionActivity, type).execute(sb.toString()); } } else { - if(injectionActivity instanceof MapViewerOsmDroid) { - ((MapViewerOsmDroid)injectionActivity).setRefreshActionButtonState(false); + 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 { - if(injectionActivity instanceof MapViewerOsmDroid) { - ((MapViewerOsmDroid)injectionActivity).setRefreshActionButtonState(false); + 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); diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java index 0b63f9931..fdaea54ab 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java @@ -9,12 +9,14 @@ import android.app.AlertDialog; import android.content.Context; import android.content.Intent; +import android.support.v4.app.Fragment; import android.support.v4.content.LocalBroadcastManager; import com.SecUpwN.AIMSICD.BuildConfig; import com.SecUpwN.AIMSICD.R; -import com.SecUpwN.AIMSICD.activities.MapViewerOsmDroid; +import com.SecUpwN.AIMSICD.activities.MapFragment; import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter; +import com.SecUpwN.AIMSICD.constants.DrawerMenu; import com.SecUpwN.AIMSICD.constants.TinyDbKeys; import com.SecUpwN.AIMSICD.service.CellTracker; import com.squareup.okhttp.MediaType; @@ -87,7 +89,7 @@ public class RequestTask extends BaseAsyncTask { public static final char DBE_UPLOAD_REQUEST = 6; // OCID upload request from "APPLICATION" drawer title public static final char BACKUP_DATABASE = 3; // Backup DB to CSV and AIMSICD_dump.db public static final char RESTORE_DATABASE = 4; // Restore DB from CSV files - public static final char CELL_LOOKUP = 5; // TODO: "All Current Cell Details (ACD)" + public static final char CELL_LOOKUP = 5; // TODO: "All Current Cell Details (ALL_CURRENT_CELL_DETAILS)" @Inject private Logger log; @@ -288,7 +290,7 @@ protected void onPostExecute(String result) { case DBE_DOWNLOAD_REQUEST_FROM_MAP: if ("Successful".equals(result)) { if (mDbAdapter.populateDBeImport()) { - Intent intent = new Intent(MapViewerOsmDroid.updateOpenCellIDMarkers); + Intent intent = new Intent(MapFragment.updateOpenCellIDMarkers); LocalBroadcastManager.getInstance(mAppContext).sendBroadcast(intent); Helpers.msgShort(mAppContext, mAppContext.getString(R.string.opencellid_data_successfully_received_markers_updated)); @@ -371,12 +373,14 @@ protected void onCancelled() { } private void showHideMapProgressBar(boolean pFlag) { - Activity lActivity = getActivity(); + InjectionAppCompatActivity lActivity = getActivity(); if(BuildConfig.DEBUG && lActivity == null) { log.verbose("BaseTask showHideMapProgressBar() activity is null"); } - if (lActivity != null && lActivity instanceof MapViewerOsmDroid) { - ((MapViewerOsmDroid) lActivity).setRefreshActionButtonState(pFlag); + + Fragment myFragment = lActivity.getSupportFragmentManager().findFragmentByTag(String.valueOf(DrawerMenu.ID.MAIN.ALL_CURRENT_CELL_DETAILS)); + if(myFragment instanceof MapFragment) { + ((MapFragment) myFragment).setRefreshActionButtonState(pFlag); } } diff --git a/AIMSICD/src/main/java/scratchpad b/AIMSICD/src/main/java/scratchpad new file mode 100644 index 000000000..c6b7dca67 --- /dev/null +++ b/AIMSICD/src/main/java/scratchpad @@ -0,0 +1,6 @@ +FEMTOCELL? -> can AIMSICD onPrepareOptionsMenu deleted, +DrawerMenu / Tracking delete + +SettingsActivity has an unnecesary fragment + +MapFragment: if no Cell id info downloaded dialog/download/better button etc \ No newline at end of file diff --git a/AIMSICD/src/main/res/layout/fragment_device.xml b/AIMSICD/src/main/res/layout/fragment_device.xml index 703404718..385b5831f 100644 --- a/AIMSICD/src/main/res/layout/fragment_device.xml +++ b/AIMSICD/src/main/res/layout/fragment_device.xml @@ -2,480 +2,568 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" + android:overScrollMode="never" + android:fadingEdgeLength="0dp"> + android:id="@+id/mainView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:stretchColumns="1"> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="device"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="18sp" + android:text="@string/device_info_title" + android:layout_span="2" + android:textColor="@color/green_text" + android:padding="4dip"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="device"> + android:id="@+id/device_type_label" + android:text="@string/device_type" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/device_type" + android:text="@string/empty" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="start" + android:tag="device"> + android:id="@+id/device_imei_label" + android:text="@string/device_imei" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/device_imei" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="device"> + android:id="@+id/device_version_label" + android:text="@string/device_version" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/device_version" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="sim"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="18sp" + android:text="@string/sim_info_title" + android:layout_span="2" + android:textColor="@color/green_text" + android:padding="5dip"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="sim"> + android:id="@+id/sim_country_label" + android:text="@string/sim_country" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_width="fill_parent" + android:layout_gravity="end"/> + android:id="@+id/sim_country" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="sim"> + android:id="@+id/sim_operator_id_label" + android:text="@string/sim_operator_id" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/sim_operator_id" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="sim"> + android:id="@+id/sim_operator_name_label" + android:text="@string/sim_operator_name" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/sim_operator_name" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="sim"> + android:id="@+id/sim_imsi_label" + android:text="@string/sim_imsi" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/sim_imsi" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="sim"> + android:id="@+id/sim_serial_label" + android:text="@string/sim_serial" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/sim_serial" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="network"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="18sp" + android:text="@string/network_info" + android:layout_span="2" + android:textColor="@color/green_text" + android:padding="5dip"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="network"> + android:id="@+id/network_name_label" + android:text="@string/network_name" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_name" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="network"> + android:id="@+id/network_code_label" + android:text="@string/network_code" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_code" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="start" + android:tag="network"> + android:id="@+id/network_type_label" + android:text="@string/network_type" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_type" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="network"> + android:id="@+id/network_lac_label" + android:text="@string/network_lac" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_lac" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:id="@+id/gsm_cellid" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="gsm_network" + android:visibility="gone"> + android:id="@+id/network_cellid_label" + android:text="@string/network_cellid" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_cellid" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:id="@+id/primary_scrambling_code" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:visibility="gone"> + android:id="@+id/network_psc_label" + android:text="@string/network_psc" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_psc" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:tag="network"> + android:id="@+id/network_roaming_label" + android:text="@string/network_roaming" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_roaming" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:tag="network"> + android:id="@+id/data_activity_label" + android:text="@string/data_activity" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end"/> + android:id="@+id/data_activity" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="network"> + android:id="@+id/data_status_label" + android:text="@string/data_status" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end"/> + android:id="@+id/data_status" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:id="@+id/lte_timing_advance" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="lte" + android:visibility="gone"> + android:id="@+id/network_lte_timing_advance_label" + android:text="@string/network_lte_timing_advance" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_lte_timing_advance" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:id="@+id/cdma_netid" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="cdma" + android:visibility="gone"> + android:id="@+id/network_netid_label" + android:text="@string/network_netid" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_netid" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:id="@+id/cdma_sysid" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="cdma" + android:visibility="gone"> + android:id="@+id/network_sysid_label" + android:text="@string/network_sysid" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_sysid" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> + android:id="@+id/cdma_baseid" + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:gravity="center_horizontal" + android:tag="cdma" + android:visibility="gone"> + android:id="@+id/network_baseid_label" + android:text="@string/network_baseid" + android:layout_weight="1" + android:textColor="@color/white" + android:padding="2dip" + android:gravity="end" + android:layout_gravity="end" + android:layout_width="fill_parent"/> + android:id="@+id/network_baseid" + android:text="@string/empty" + android:layout_weight="1" + android:textColor="@color/medium_blue" + android:padding="2dip" + android:gravity="start"/> diff --git a/AIMSICD/src/main/res/menu/activity_debug_logs.xml b/AIMSICD/src/main/res/menu/activity_debug_logs.xml index 0f64c176c..cf9c5ae9e 100644 --- a/AIMSICD/src/main/res/menu/activity_debug_logs.xml +++ b/AIMSICD/src/main/res/menu/activity_debug_logs.xml @@ -7,7 +7,7 @@ diff --git a/AIMSICD/src/main/res/menu/fragment_map_menu.xml b/AIMSICD/src/main/res/menu/fragment_map_menu.xml new file mode 100644 index 000000000..f5703d2f6 --- /dev/null +++ b/AIMSICD/src/main/res/menu/fragment_map_menu.xml @@ -0,0 +1,16 @@ + + +

+ + + \ No newline at end of file diff --git a/AIMSICD/src/main/res/menu/main_menu.xml b/AIMSICD/src/main/res/menu/main_menu.xml new file mode 100644 index 000000000..fea748416 --- /dev/null +++ b/AIMSICD/src/main/res/menu/main_menu.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/AIMSICD/src/main/res/values-cs/translatable_strings.xml b/AIMSICD/src/main/res/values-cs/translatable_strings.xml index 3d100a93a..21f234d23 100644 --- a/AIMSICD/src/main/res/values-cs/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-cs/translatable_strings.xml @@ -15,7 +15,7 @@ Záloha databáze Obnova databáze Nastavení - Ladění + Ladění Stáhnout data BTS Informace o zařízení diff --git a/AIMSICD/src/main/res/values-de/translatable_strings.xml b/AIMSICD/src/main/res/values-de/translatable_strings.xml index ead88329b..1adb42f46 100644 --- a/AIMSICD/src/main/res/values-de/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-de/translatable_strings.xml @@ -35,7 +35,7 @@ Einstellungen Erneut drücken zum Verlassen. Derzeitige Funkzellen - Fehlerbehebung + Fehlerbehebung Keine Internetverbindung Kein herunterladen der OpenCellID-Daten ohne Internet möglich, bitte Datenverbindung einschalten! diff --git a/AIMSICD/src/main/res/values-es/translatable_strings.xml b/AIMSICD/src/main/res/values-es/translatable_strings.xml index 6df40b789..f854bafd8 100644 --- a/AIMSICD/src/main/res/values-es/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-es/translatable_strings.xml @@ -21,7 +21,7 @@ Opciones Presiona de nuevo para salir. Detalles de Celda Actuales - Debugeo + Debugeo Sin Conexion a Internet No se pueden descargar datos de OpenCellID sin conectividad a Internet, active la conexión de datos! diff --git a/AIMSICD/src/main/res/values-fr/translatable_strings.xml b/AIMSICD/src/main/res/values-fr/translatable_strings.xml index 0e2363e1b..df8d7fc69 100755 --- a/AIMSICD/src/main/res/values-fr/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-fr/translatable_strings.xml @@ -34,7 +34,7 @@ Préférences Appuyez une seconde fois pour quitter. Détails sur la/les cellule(s) actuelles - Débogage + Débogage Aucune Connexion Internet Impossible de télécharger les données OpenCellID sans connexion à Internet, veuillez activer la connexion de données ! diff --git a/AIMSICD/src/main/res/values-ja/translatable_strings.xml b/AIMSICD/src/main/res/values-ja/translatable_strings.xml index 22dbc71c1..6ed86bb37 100644 --- a/AIMSICD/src/main/res/values-ja/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-ja/translatable_strings.xml @@ -22,7 +22,7 @@ プリファレンス もう一度押すと終了します。 すべての現在の基地局の詳細 - デバッグ + デバッグ インターネット接続がありません インターネット接続がないため OpenCellID データをダウンロードすることができません。データ接続を有効にしてください! diff --git a/AIMSICD/src/main/res/values-nb/translatable_strings.xml b/AIMSICD/src/main/res/values-nb/translatable_strings.xml index 4f6b64760..765f48daf 100644 --- a/AIMSICD/src/main/res/values-nb/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-nb/translatable_strings.xml @@ -20,7 +20,7 @@ Tilbakefør database Trykk på nytt for å gå ut. Alle Nåværende celledetaljer - Feilsøking + Feilsøking Ingen Internett-forbindelse Klarte ikke laste ned OpenCellID-data uten Internettilkobling, vennligst slå på datatilkobling! diff --git a/AIMSICD/src/main/res/values-nl/translatable_strings.xml b/AIMSICD/src/main/res/values-nl/translatable_strings.xml index 9f609a702..e7ba7e75a 100644 --- a/AIMSICD/src/main/res/values-nl/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-nl/translatable_strings.xml @@ -19,7 +19,7 @@ Voorkeuren Druk opnieuw om af te sluiten. Alle gegevens van huidige cel - Foutopsporing + Foutopsporing Geen internet verbinding Kan geen OpenCellID data laden zonder dataverbinding, zet de dataverbinding a.u.b. aan! diff --git a/AIMSICD/src/main/res/values-pl/translatable_strings.xml b/AIMSICD/src/main/res/values-pl/translatable_strings.xml index 2040db362..38e5e4a0a 100644 --- a/AIMSICD/src/main/res/values-pl/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-pl/translatable_strings.xml @@ -27,7 +27,7 @@ Ustawienia Wciśnij ponownie by wyjść. Wszystkie informacje o obecnej komórce - Debugowanie + Debugowanie Brak połączenia z Internetem Nie da się pobrać danych z OpenCellID bez połączenia Internetowego. Proszę włączyć połączenie danych! diff --git a/AIMSICD/src/main/res/values-pt-rBR/translatable_strings.xml b/AIMSICD/src/main/res/values-pt-rBR/translatable_strings.xml index 5f7cd49a5..421b0406a 100644 --- a/AIMSICD/src/main/res/values-pt-rBR/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-pt-rBR/translatable_strings.xml @@ -21,7 +21,7 @@ Preferências Pressione novamente para sair. Todos os detalhes da célula atual - Depurar + Depurar Sem conexão à internet Sem permissão para transferir dados do OpenCelllD sem conexão à internet, por favor habilite a conexão de dados! diff --git a/AIMSICD/src/main/res/values-ru/translatable_strings.xml b/AIMSICD/src/main/res/values-ru/translatable_strings.xml index 80c7660fc..52ab89992 100644 --- a/AIMSICD/src/main/res/values-ru/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-ru/translatable_strings.xml @@ -33,7 +33,7 @@ Параметры Нажмите еще раз для выхода. Все текущие данные соты - Отладка + Отладка Нет интернет-соединения Не удается загрузить данные OpenCellID без интернета, пожалуйста включите передачу данных! diff --git a/AIMSICD/src/main/res/values-sq/translatable_strings.xml b/AIMSICD/src/main/res/values-sq/translatable_strings.xml index d8f387442..3fb83bc73 100644 --- a/AIMSICD/src/main/res/values-sq/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-sq/translatable_strings.xml @@ -21,7 +21,7 @@ Preferencat Shtyp përsëri të dalësh. Të gjitha detajet e deritanishme të kullës - Zbulim gabimesh + Zbulim gabimesh S\'ka lidhje me internetin Nuk është e mundur të tërhiqen të dhënat e OpenCellID pa lidhje interneti, ju lutem aktivizojeni atë! diff --git a/AIMSICD/src/main/res/values-uk/translatable_strings.xml b/AIMSICD/src/main/res/values-uk/translatable_strings.xml index 83bbc15a5..b45e4aad1 100644 --- a/AIMSICD/src/main/res/values-uk/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-uk/translatable_strings.xml @@ -19,7 +19,7 @@ Параметри Натисніть ще раз для виходу. Всі поточні відомості про стільник - Зневадження + Зневадження Відсутнє з\'єднання з інтернетом Завантажити дані базових станцій diff --git a/AIMSICD/src/main/res/values-vi/translatable_strings.xml b/AIMSICD/src/main/res/values-vi/translatable_strings.xml index 28cf7295c..41f1b024d 100644 --- a/AIMSICD/src/main/res/values-vi/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-vi/translatable_strings.xml @@ -19,7 +19,7 @@ Tuỳ chỉnh Nhấn lại để thoát. Tất cả chi tiết về máy di động hiện thời - Dò lỗi + Dò lỗi Không có kết nối mạng Không thể tải xuống dữ liệu OpenCellID mà không có mạng, xin bật kết nối dữ liệu! diff --git a/AIMSICD/src/main/res/values/strings.xml b/AIMSICD/src/main/res/values/strings.xml new file mode 100644 index 000000000..5ecd90551 --- /dev/null +++ b/AIMSICD/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Antenna Map Viewer + \ No newline at end of file diff --git a/AIMSICD/src/main/res/values/translatable_strings.xml b/AIMSICD/src/main/res/values/translatable_strings.xml index f4333b943..be31670ee 100644 --- a/AIMSICD/src/main/res/values/translatable_strings.xml +++ b/AIMSICD/src/main/res/values/translatable_strings.xml @@ -33,7 +33,7 @@ Preferences Press again to exit. All Current Cell Details - Debugging + Debugging No Internet Connection Unable to download OpenCellID data without Internet connectivity, please enable data connection! @@ -236,6 +236,7 @@ 10 min Main Settings + Database settings Application Monitoring Cell Information. Stopped monitoring Cell Information. From 9df7515557fbe83943dd910db71135c1b5d42c98 Mon Sep 17 00:00:00 2001 From: tt3mm Date: Sat, 20 Feb 2016 14:03:36 +0100 Subject: [PATCH 04/14] Removed unnecesary file --- AIMSICD/src/main/java/scratchpad | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 AIMSICD/src/main/java/scratchpad diff --git a/AIMSICD/src/main/java/scratchpad b/AIMSICD/src/main/java/scratchpad deleted file mode 100644 index c6b7dca67..000000000 --- a/AIMSICD/src/main/java/scratchpad +++ /dev/null @@ -1,6 +0,0 @@ -FEMTOCELL? -> can AIMSICD onPrepareOptionsMenu deleted, -DrawerMenu / Tracking delete - -SettingsActivity has an unnecesary fragment - -MapFragment: if no Cell id info downloaded dialog/download/better button etc \ No newline at end of file From ac267ca5a2c980265a17c4f58a2a304f869dd458 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Mon, 14 Dec 2015 10:24:17 +0100 Subject: [PATCH 05/14] calculate versionNames from git-tags use new plugin --- AIMSICD/build.gradle | 2 -- build.gradle | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AIMSICD/build.gradle b/AIMSICD/build.gradle index a673c4f69..386450c39 100644 --- a/AIMSICD/build.gradle +++ b/AIMSICD/build.gradle @@ -17,8 +17,6 @@ if (isTravis) { buildNumber = System.getenv("BUILDOZER_BUILDNUMBER") } -version = '0.1.39.1-alpha' - android { compileSdkVersion 23 buildToolsVersion '23.0.2' diff --git a/build.gradle b/build.gradle index cc4998e43..f3f65b317 100644 --- a/build.gradle +++ b/build.gradle @@ -6,13 +6,16 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' - classpath 'io.freefair.gradle-plugins:android:2.0.0-beta1' + classpath 'io.freefair:gradle-plugins:2.0.0-beta1' } } +apply plugin: 'io.freefair.git-version' + allprojects { repositories { jcenter() maven { url "https://jitpack.io" } } + version = rootProject.version } From 06d0550be618d34b66e0323d9e5ceca58f9c341c Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Fri, 5 Feb 2016 21:11:04 +0100 Subject: [PATCH 06/14] handle the tag prefix correctly --- build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f3f65b317..0b45aa10b 100644 --- a/build.gradle +++ b/build.gradle @@ -6,12 +6,16 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' - classpath 'io.freefair:gradle-plugins:2.0.0-beta1' + classpath 'io.freefair:gradle-plugins:2.0.0-beta3' } } apply plugin: 'io.freefair.git-version' +gitVersion { + tagPrefix 'v' +} + allprojects { repositories { jcenter() From 52a0357c5983ac28228014fec49a3aef6ba4d398 Mon Sep 17 00:00:00 2001 From: tt3mm Date: Sat, 20 Feb 2016 14:35:32 +0100 Subject: [PATCH 07/14] Minor fixes --- .gitignore | 1 + .../java/com/SecUpwN/AIMSICD/activities/MapFragment.java | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 51c40955a..0e095b582 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,4 @@ signing.properties import-summary.txt manifest-merger*.txt .navigation/ +scratchpad diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java index 574af0195..e1c17d272 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java @@ -312,11 +312,6 @@ private void setUpMapIfNeeded() { mMap.getOverlays().add(mScaleBarOverlay); } - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return super.onCreateView(inflater, container, savedInstanceState); - } - @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { this.mOptionsMenu = menu; From cad9d8092b968bd0b640c0f84f428736102455db Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 20 Feb 2016 14:55:37 +0100 Subject: [PATCH 08/14] improve build number display fix #773 --- AIMSICD/build.gradle | 24 ++++++++++++------- .../AIMSICD/activities/AboutActivity.java | 9 ++++++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/AIMSICD/build.gradle b/AIMSICD/build.gradle index 6ef98d285..b7473304f 100644 --- a/AIMSICD/build.gradle +++ b/AIMSICD/build.gradle @@ -8,14 +8,6 @@ try { } def isCi = "true".equals(System.getenv("CI")) -def isTravis = "true".equals(System.getenv("TRAVIS")) - -def buildNumber = null -if (isTravis) { - buildNumber = System.getenv("TRAVIS_BUILD_NUMBER") -} else { - buildNumber = System.getenv("BUILDOZER_BUILDNUMBER") -} version = '0.1.39.1-alpha' @@ -29,7 +21,7 @@ android { versionCode 39 testApplicationId "com.SecUpwN.AIMSICD.test" - buildConfigField 'String', 'BUILD_NUMBER', (buildNumber == null ? 'null' : "\"${buildNumber}\"") + buildConfigField 'String', 'BUILD_NUMBER', (getBuildNumber() == null ? 'null' : "\"${buildNumber}\"") buildConfigField 'String', 'GIT_SHA', (gitSha == null ? 'null' : "\"${gitSha}\"") } buildTypes { @@ -109,3 +101,17 @@ apply plugin: "io.freefair.android-checkstyle" checkstyle { toolVersion = "6.15" } + +String getBuildNumber() { + String travisBuildNumber = System.getenv("TRAVIS_BUILD_NUMBER") + if(travisBuildNumber != null) { + return "T-$travisBuildNumber" + } + + String buildozerBuildNumber = System.getenv("BUILDOZER_BUILDNUMBER") + if(buildozerBuildNumber != null) { + return "B-$buildozerBuildNumber" + } + + return null; +} \ No newline at end of file diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/AboutActivity.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/AboutActivity.java index 7d3648ade..41895e72e 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/AboutActivity.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/AboutActivity.java @@ -56,7 +56,14 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); versionNumber.setText(getString(R.string.app_version, BuildConfig.VERSION_NAME)); - buildNumberTextView.setText(getString(R.string.buildnumber, BuildConfig.BUILD_NUMBER)); + + String buildNumber = BuildConfig.BUILD_NUMBER; + //noinspection ConstantConditions + if (buildNumber == null) { + buildNumber = getString(R.string.n_a); + } + buildNumberTextView.setText(getString(R.string.buildnumber, buildNumber)); + gitShaTextView.setText(getString(R.string.git_sha, BuildConfig.GIT_SHA)); //GitHub WIKI Link From fee98366dbf0533bca6498d3a837d64bd28ad6a7 Mon Sep 17 00:00:00 2001 From: tt3mm Date: Sat, 20 Feb 2016 20:37:39 +0100 Subject: [PATCH 09/14] Making checkable the toggle menu buttons --- AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java | 7 +++++++ AIMSICD/src/main/res/menu/main_menu.xml | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java index e1f908493..39e065a7e 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java @@ -522,6 +522,11 @@ public void onPause() { public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); + + MenuItem toggleAttackDetectionMenuItem = menu.findItem(R.id.toggle_attack_detection); + toggleAttackDetectionMenuItem.setChecked(true); + MenuItem toggleCellTrackingMenuItem = menu.findItem(R.id.toggle_cell_tracking); + toggleCellTrackingMenuItem.setChecked(true); return true; } @@ -529,9 +534,11 @@ public boolean onCreateOptionsMenu(Menu menu) { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()){ case R.id.toggle_attack_detection: + item.setChecked(!item.isChecked()); monitorCell(); break; case R.id.toggle_cell_tracking: + item.setChecked(!item.isChecked()); trackCell(); break; case R.id.settings: diff --git a/AIMSICD/src/main/res/menu/main_menu.xml b/AIMSICD/src/main/res/menu/main_menu.xml index fea748416..ee63df847 100644 --- a/AIMSICD/src/main/res/menu/main_menu.xml +++ b/AIMSICD/src/main/res/menu/main_menu.xml @@ -5,12 +5,12 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> From 9478d1ee23c2967e4d6a866aa6faba6cddf05ef5 Mon Sep 17 00:00:00 2001 From: tt3mm Date: Sun, 21 Feb 2016 11:32:27 +0100 Subject: [PATCH 10/14] Deleted unused imports, and ATCommandActivity --- AIMSICD/src/main/AndroidManifest.xml | 5 - .../java/com/SecUpwN/AIMSICD/AIMSICD.java | 2 +- .../AIMSICD/activities/AtCommandActivity.java | 441 ------------------ .../AIMSICD/fragments/AtCommandFragment.java | 1 - .../AIMSICD/fragments/DeviceFragment.java | 1 - .../MapFragment.java | 5 +- .../SecUpwN/AIMSICD/utils/BaseAsyncTask.java | 1 - .../com/SecUpwN/AIMSICD/utils/Helpers.java | 2 +- .../SecUpwN/AIMSICD/utils/RequestTask.java | 2 +- 9 files changed, 5 insertions(+), 455 deletions(-) delete mode 100644 AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/AtCommandActivity.java rename AIMSICD/src/main/java/com/SecUpwN/AIMSICD/{activities => fragments}/MapFragment.java (99%) diff --git a/AIMSICD/src/main/AndroidManifest.xml b/AIMSICD/src/main/AndroidManifest.xml index ef2c20c43..5c55b5d05 100644 --- a/AIMSICD/src/main/AndroidManifest.xml +++ b/AIMSICD/src/main/AndroidManifest.xml @@ -85,11 +85,6 @@ - - mSerialDevices = new ArrayList<>(); - - private String mSerialDevice; - private int mTimeout; - - @InjectView(R.id.atcommandView) - private RelativeLayout mAtCommandLayout; - - @InjectView(R.id.at_command_error) - private TextView mAtCommandError; - - @InjectView(R.id.serial_device) - private TextView mSerialDeviceDisplay; - - @InjectView(R.id.response) - private TextView mAtResponse; - - @InjectView(R.id.at_command) - private EditText mAtCommand; - - @InjectView(R.id.serial_device_spinner) - private Spinner mSerialDeviceSpinner; - - @InjectView(R.id.serial_device_spinner_title) - private TextView mSerialDeviceSpinnerLabel; - - private AtCommandTerminal mCommandTerminal; - - @InjectView(R.id.timeout_spinner) - private Spinner timeoutSpinner; - - @InjectView(R.id.execute) - private Button atCommandExecute; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - atCommandExecute.setOnClickListener(new btnClick()); - mSerialDeviceSpinner.setOnItemSelectedListener(new spinnerListener()); - timeoutSpinner.setOnItemSelectedListener(new timeoutSpinnerListener()); - timeoutSpinner.setSelection(1); - mTimeout = 5000; - } - - private class timeoutSpinnerListener implements AdapterView.OnItemSelectedListener { - - @Override - public void onItemSelected(AdapterView parentView, View selectedItemView, - int position, long id) { - switch (position) { - // Don't forget to also change the arrays.xml - case 0: //2 seconds - mTimeout = 2000; - break; - case 1: //5 seconds - mTimeout = 5000; - break; - case 2: //10 seconds - mTimeout = 10000; - break; - case 3: //20 seconds - mTimeout = 20000; - break; - case 4: //30 seconds - mTimeout = 30000; - break; - case 5: // No timeout, when watching output... - mTimeout = 600000; // Well, ok, 10 min - break; - default: - mTimeout = 5000; - } - } - - @Override - public void onNothingSelected(AdapterView parentView) { - } - } - - private class spinnerListener implements AdapterView.OnItemSelectedListener { - - @Override - public void onItemSelected(AdapterView parentView, View selectedItemView, - int position, long id) { - mSerialDevice = String.valueOf(mSerialDeviceSpinner.getSelectedItem()); - mSerialDeviceDisplay.setText(mSerialDevice); - setSerialDevice(); - } - - @Override - public void onNothingSelected(AdapterView parentView) { - - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - if (mCommandTerminal != null) { - mCommandTerminal.dispose(); - } - } - - @Override - public void onResume() { - super.onResume(); - - int serialDevice = initSerialDevice(); - - switch (serialDevice) { - case SERIAL_INIT_OK: - mAtCommandLayout.setVisibility(View.VISIBLE); - break; - case ROOT_UNAVAILABLE: - mAtCommandError.setText(R.string.unable_to_acquire_root_access); - break; - case BUSYBOX_UNAVAILABLE: - mAtCommandError.setText(R.string.unable_to_detect_busybox); - break; - case SERIAL_INIT_ERROR: - mAtCommandError.setText(R.string.unknown_error_trying_to_acquire_serial_device); - break; - default: - mAtCommandError.setText(R.string.unknown_error_initialising_at_command_injector); - break; - } - - } - - private class btnClick implements View.OnClickListener { - - @Override - public void onClick(View v) { - if (mAtCommand.getText() != null) { - String command = mAtCommand.getText().toString(); - log.info("AT Command Detected: " + command); - executeAT(); - } - } - } - - /** - * Description: This is looking for possible serial devices that may be used for ATCoP. - * - * Issues: This is generally not working since it is very HW and SW dependent. - * - * - * @return - */ - private int initSerialDevice() { - - /** - * NOTE: - * - * Because of how RootShell is being used the handler has to be disabled. - * - * With the handler disabled absolutely NO UI work can be done in the callback methods - * since they will be called on a separate thread. - * - * To work around this, either: - * - * a) Execute all Shell commands in a thread, such as AsyncTask - * OR - * b) Stop using commandWait (which is a no no...you should never sleep on the - * main UI thread) and implement the callback commandFinished/commandTerminated - * to determine when to continue on. - * - */ - RootShell.handlerEnabled = false; - - // Check for root access - boolean root = RootShell.isAccessGiven(); - if (!root) { - return ROOT_UNAVAILABLE; - } - - // Check if Busybox is installed - boolean busybox = RootShell.isBusyboxAvailable(); - if (!busybox) { - return BUSYBOX_UNAVAILABLE; - } - - try { - mAtResponse.setText(R.string.at_command_response_looking); - mSerialDevices.clear(); - - // THIS IS A BAD IDEA TODO: Consider removing - // Use RIL Serial Device details from the System Property - try { - String rilDevice = Helpers.getSystemProp(this, "rild.libargs", "UNKNOWN"); - mSerialDevice = ("UNKNOWN".equals(rilDevice) ? rilDevice : rilDevice.substring(3)); - - if (!"UNKNOWN".equals(mSerialDevice)) { - mSerialDevices.add(mSerialDevice); - } - } catch (StringIndexOutOfBoundsException e) { - log.warn(e.getMessage()); - // ignore, move on - } - - //================================================================== - // WARNING: Scraping commands can be masked by aliases in: mkshrc - // and even hardcoded in the sh binary or elsewhere. - // To get unaliased versions, use: "\\" - //================================================================== - - for (File file : new File("/dev").listFiles()) { - String name = file.getName(); - boolean add = false; - // QC: /dev/smd[0-7] - if (name.matches("^smd.$")) { - add = true; - } else if ("radio".equals(name)) { - // MTK: /dev/radio/*atci* - for (File subfile : file.listFiles()) { - String subname = subfile.getName(); - if (subname.contains("atci")) { - add = true; - file = subfile; - } - } - } - - if (add) { - mSerialDevices.add(file.getAbsolutePath()); - mAtResponse.append(getString(R.string.at_command_response_found) + file.getAbsolutePath() + "\n"); - } - } - - // Now try XMM/XGOLD modem config - File xgold = new File("/system/etc/ril_xgold_radio.cfg"); - if (xgold.exists() && xgold.isFile()) { - Command cmd = new Command(1, "\\cat /system/etc/ril_xgold_radio.cfg | " - + "\\grep -E \"atport*|dataport*\"") { - - @Override - public void commandOutput(int id, String line) { - if (id == 0) { - if (!line.trim().isEmpty() && line.contains("/dev/")) { - int place = line.indexOf("=") + 1; - mSerialDevices.add(line.substring(place, line.length() - 1)); - mAtResponse.append(getString(R.string.at_command_response_found)+line.substring(place, line.length() - 1) + "\n"); - } - } - super.commandOutput(id, line); - } - }; - - Shell shell = RootShell.getShell(true); - shell.add(cmd); - commandWait(shell, cmd); - } - - } catch (Exception e) { - log.error("InitSerialDevice ", e); - } - - if (!mSerialDevices.isEmpty()) { - String[] entries = new String[mSerialDevices.size()]; - entries = mSerialDevices.toArray(entries); - ArrayAdapter spinnerAdapter = new ArrayAdapter<>(this, - android.R.layout.simple_spinner_item, entries); - mSerialDeviceSpinner.setAdapter(spinnerAdapter); - mSerialDeviceSpinner.setVisibility(View.VISIBLE); - mSerialDeviceSpinnerLabel.setVisibility(View.VISIBLE); - } - - mAtResponse.append(getString(R.string.at_command_response_setup_complete)); - mAtResponse.setVisibility(View.VISIBLE); - - return SERIAL_INIT_OK; - } - - private void setSerialDevice() { - if (mCommandTerminal != null) { - mCommandTerminal.dispose(); - mCommandTerminal = null; - } - } - - private AtCommandTerminal getSerialDevice() { - if (mCommandTerminal == null) { - try { - mCommandTerminal = new TtyPrivFile(mSerialDevice); - return mCommandTerminal; - } catch (IOException e) { - mAtResponse.append(e.toString()); - } - } else { - return mCommandTerminal; - } - return null; - } - - private void executeAT() { - // It seem that MTK devices doesn't need "\r" but QC devices do. - // We need a device-type check here, perhaps: gsm.version.ril-impl. - Editable cmd = mAtCommand.getText(); - if (cmd != null && cmd.length() != 0) { - log.debug("ExecuteAT: attempting to send: " + cmd.toString()); - - if (getSerialDevice() != null) { - mCommandTerminal.send(cmd.toString(), new Handler(Looper.getMainLooper()) { - @Override - public void handleMessage(Message message) { - if (message.obj instanceof List) { - List lines = ((List) message.obj); - StringBuffer response = new StringBuffer(); - for (String line : lines) { - response.append(line); - response.append('\n'); - } - if (response.length() != 0) { - mAtResponse.append(response); - } - - } else if (message.obj instanceof IOException) { - mAtResponse.append("IOException: " + ((IOException) message.obj).getMessage() + "\n"); - } - } - }.obtainMessage()); - } - } - - } - - /** - * This below method is part of the RootTools Project: https://github.com/Stericson/RootTools - * Copyright (c) 2012 Stephen Erickson, Chris Ravenscroft, Dominik Schuermann, Adam Shanks - * - * Slightly modified commandWait method as found in RootToolsInternalMethods.java to utilise - * the user selected timeout value. - * - */ - private void commandWait(Shell shell, Command cmd) throws Exception { - while (!cmd.isFinished()) { - synchronized (cmd) { - try { - if (!cmd.isFinished()) { - cmd.wait(mTimeout); - } - } catch (InterruptedException e) { - log.error(e.getMessage()); - } - } - if (!cmd.isExecuting() && !cmd.isFinished()) { - Exception e = new Exception(); - - if (!shell.isExecuting && !shell.isReading) { - log.warn("Waiting for a command to be executed in a shell that is not executing and not reading! \n\n Command: " + cmd.getCommand()); - e.setStackTrace(Thread.currentThread().getStackTrace()); - log.error(e.getMessage(), e); - - } else if (shell.isExecuting && !shell.isReading) { - log.error("Waiting for a command to be executed in a shell that is executing but not reading! \n\n Command: " + cmd.getCommand()); - e.setStackTrace(Thread.currentThread().getStackTrace()); - log.error(e.getMessage(), e); - - } else { - log.error("Waiting for a command to be executed in a shell that is not reading! \n\n Command: " + cmd.getCommand()); - e.setStackTrace(Thread.currentThread().getStackTrace()); - log.error(e.getMessage(), e); - } - } - } - } -} diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/AtCommandFragment.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/AtCommandFragment.java index 997fddadd..a86bc9fca 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/AtCommandFragment.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/AtCommandFragment.java @@ -35,7 +35,6 @@ import io.freefair.android.injection.annotation.Inject; import io.freefair.android.injection.annotation.InjectView; import io.freefair.android.injection.annotation.XmlLayout; -import io.freefair.android.injection.app.InjectionAppCompatActivity; import io.freefair.android.injection.app.InjectionFragment; import io.freefair.android.util.logging.Logger; diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java index 0fe9eccd7..8f48093e4 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/DeviceFragment.java @@ -5,7 +5,6 @@ */ package com.SecUpwN.AIMSICD.fragments; -import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/MapFragment.java similarity index 99% rename from AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java rename to AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/MapFragment.java index e1c17d272..e93f32b62 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/activities/MapFragment.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/fragments/MapFragment.java @@ -3,7 +3,7 @@ * LICENSE: http://git.io/vki47 | TERMS: http://git.io/vki4o * ----------------------------------------------------------- */ -package com.SecUpwN.AIMSICD.activities; +package com.SecUpwN.AIMSICD.fragments; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -24,16 +24,15 @@ import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.TelephonyManager; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; import com.SecUpwN.AIMSICD.AppAIMSICD; import com.SecUpwN.AIMSICD.BuildConfig; import com.SecUpwN.AIMSICD.R; +import com.SecUpwN.AIMSICD.activities.MapPrefActivity; import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter; import com.SecUpwN.AIMSICD.constants.DBTableColumnIds; import com.SecUpwN.AIMSICD.constants.TinyDbKeys; diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/BaseAsyncTask.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/BaseAsyncTask.java index 7002c996b..66f283eb8 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/BaseAsyncTask.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/BaseAsyncTask.java @@ -6,7 +6,6 @@ package com.SecUpwN.AIMSICD.utils; -import android.app.Activity; import android.os.AsyncTask; import com.SecUpwN.AIMSICD.AppAIMSICD; diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java index 121a634e0..de58793b9 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java @@ -28,7 +28,7 @@ import android.text.TextUtils; import com.SecUpwN.AIMSICD.R; -import com.SecUpwN.AIMSICD.activities.MapFragment; +import com.SecUpwN.AIMSICD.fragments.MapFragment; import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter; import com.SecUpwN.AIMSICD.constants.DrawerMenu; import com.SecUpwN.AIMSICD.service.AimsicdService; diff --git a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java index fdaea54ab..d299163a0 100644 --- a/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java +++ b/AIMSICD/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java @@ -14,7 +14,7 @@ import com.SecUpwN.AIMSICD.BuildConfig; import com.SecUpwN.AIMSICD.R; -import com.SecUpwN.AIMSICD.activities.MapFragment; +import com.SecUpwN.AIMSICD.fragments.MapFragment; import com.SecUpwN.AIMSICD.adapters.AIMSICDDbAdapter; import com.SecUpwN.AIMSICD.constants.DrawerMenu; import com.SecUpwN.AIMSICD.constants.TinyDbKeys; From 46ac606d9c5e24b37259787a79030143bf384c68 Mon Sep 17 00:00:00 2001 From: Nordlenningen Date: Wed, 17 Feb 2016 13:38:13 +0100 Subject: [PATCH 11/14] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegian?= =?UTF-8?q?=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 100.0% (302 of 302 strings) --- AIMSICD/src/main/res/values-nb/translatable_strings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/AIMSICD/src/main/res/values-nb/translatable_strings.xml b/AIMSICD/src/main/res/values-nb/translatable_strings.xml index 5e3ec6537..3ddaac667 100644 --- a/AIMSICD/src/main/res/values-nb/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-nb/translatable_strings.xml @@ -336,4 +336,5 @@ Slå på GPS for Cellesporing Ikke Tilgjengelig + Database Innstillinger
From 8055288c7b6eafd9a1e15e3b6ca5f2b234b0f9b5 Mon Sep 17 00:00:00 2001 From: dd721411 Date: Sat, 30 Jan 2016 11:01:31 +0100 Subject: [PATCH 12/14] Translated using Weblate (Vietnamese) Currently translated at 100.0% (302 of 302 strings) --- AIMSICD/src/main/res/values-vi/translatable_strings.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AIMSICD/src/main/res/values-vi/translatable_strings.xml b/AIMSICD/src/main/res/values-vi/translatable_strings.xml index 41f1b024d..2093b6386 100644 --- a/AIMSICD/src/main/res/values-vi/translatable_strings.xml +++ b/AIMSICD/src/main/res/values-vi/translatable_strings.xml @@ -1,4 +1,4 @@ - + Theo dõi Thông tin điện thoại/SIM Trình xem bản đồ ăng-ten @@ -336,4 +336,5 @@ N/A + Cài đặt CSDL From 4d4d34b5148fc1c0b3aef86f56c22f7b26d56150 Mon Sep 17 00:00:00 2001 From: SecUpwN Date: Sun, 21 Feb 2016 22:27:52 +0100 Subject: [PATCH 13/14] Update CHANGELOG.md --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b12737bd..72be8bfc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # CHANGELOG of 'AIMSICD' ------------------------ +#### [21.02.2016 - WIP-Release v0.1.40-alpha](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases/tag/v0.1.40-alpha) + +* Removed: Purged unused imports and `ATCommandActivity` +* Changed: Improved UX by changing main app screens to fragments +* Changed: Improved UX by moving general screens to new menu bar +* Updated: Made toggle menu buttons checkable (icons will be removed) +* Updated: Norwegian Bokmål and Vietnamese translations +* Added: Calculation of `versionName` from git-tags +* Fixed: Lint errors and build number display in `About` screen + +--- + #### [16.02.2016 - WIP-Release v0.1.39.1-alpha](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases/tag/v0.1.39.1-alpha) * Removed: Purged more unused imports from `MiscUtils.java` From 599859d3ac9a3064b90d30fcbe97d9d19097ff82 Mon Sep 17 00:00:00 2001 From: SecUpwN Date: Sun, 21 Feb 2016 22:28:58 +0100 Subject: [PATCH 14/14] Preparing WIP-Release v0.1.40-alpha --- AIMSICD/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AIMSICD/build.gradle b/AIMSICD/build.gradle index bd1ccb159..707972125 100644 --- a/AIMSICD/build.gradle +++ b/AIMSICD/build.gradle @@ -16,7 +16,7 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 19 // Do not change: Working Icons on Android 5+ - versionCode 39 + versionCode 40 testApplicationId "com.SecUpwN.AIMSICD.test" buildConfigField 'String', 'BUILD_NUMBER', (getBuildNumber() == null ? 'null' : "\"${buildNumber}\"")