From c2036058ca2d61f88d3610dee2e5c7efe4197b68 Mon Sep 17 00:00:00 2001 From: "Security: Pwned." Date: Fri, 15 May 2015 07:25:56 +0000 Subject: [PATCH 01/15] Added DONATIONS via @Bountysource --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 113a3d66d..76c6eb93c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ ### Android IMSI-Catcher Detector -[![Build Status](https://travis-ci.org/SecUpwN/Android-IMSI-Catcher-Detector.svg)](https://travis-ci.org/SecUpwN/Android-IMSI-Catcher-Detector) [![Development Status](http://img.shields.io/badge/Development_Status-ALPHA-brightgreen.svg)](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/Development-Status) [![GooglePlay](http://img.shields.io/badge/GooglePlay-NOT%20SUPPORTED-brightgreen.svg)](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/FAQ#q-why-wont-you-upload-your-app-to-the-google-play-store) [![CoverityScan](https://scan.coverity.com/projects/3346/badge.svg)](https://scan.coverity.com/projects/3346) +[![BuildStatus](https://travis-ci.org/SecUpwN/Android-IMSI-Catcher-Detector.svg)](https://travis-ci.org/SecUpwN/Android-IMSI-Catcher-Detector) [![DevelopmentStatus](http://img.shields.io/badge/Development_Status-ALPHA-brightgreen.svg)](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/Development-Status) [![CoverityScan](https://scan.coverity.com/projects/3346/badge.svg)](https://scan.coverity.com/projects/3346) +[![Bountysource](https://www.bountysource.com/badge/team?team_id=40338&style=bounties_received)](https://www.bountysource.com/teams/android-imsi-catcher-detector/issues?utm_source=Android%20IMSI-Catcher%20Detector&utm_medium=shield&utm_campaign=bounties_received) + -- AIMSICD is an app to detect [IMSI-Catchers](https://en.wikipedia.org/wiki/IMSI-catcher). IMSI-Catchers are false mobile towers (base stations) acting between the target mobile phone(s) and the real towers of service providers. As such they are considered a Man-In-The-Middle (MITM) attack. In the USA the IMSI-Catcher technology is known under the name "[StingRay](https://en.wikipedia.org/wiki/Stingray_phone_tracker)". Find out more in our [WIKI](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki). @@ -14,7 +16,9 @@ AIMSICD is an app to detect [IMSI-Catchers](https://en.wikipedia.org/wiki/IMSI-c --- -[![Aptoide](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/Aptoide.png)](http://aimsicd.store.aptoide.com/ "NOTE: Installs Aptoide-App first!") [![GitHub](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/GitHub.png)](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases "GitHub Releases") [![F-Droid](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/F-Droid.png)](https://f-droid.org/repository/browse/?fdid=com.SecUpwN.AIMSICD "F-Droid Store") [![Twitter](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/Twitter.png)](https://twitter.com/AIMSICD "Official Twitter-Account") +[![Aptoide](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/Aptoide.png)](http://aimsicd.store.aptoide.com/ "NOTE: Installs Aptoide-App first!") [![GitHub](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/GitHub.png)](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases "GitHub Releases") [![F-Droid](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/F-Droid.png)](https://f-droid.org/repository/browse/?fdid=com.SecUpwN.AIMSICD "F-Droid Store") +[![NoGooglePlay](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/NoGooglePlay.png)](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/FAQ#q-why-wont-you-upload-your-app-to-the-google-play-store "Statement against GooglePlay") +[![Twitter](https://spideroak.com/share/IFEU2U2JINCA/GitHub/home/SecUpwN/SpiderOak/MISC/external/Twitter.png)](https://twitter.com/AIMSICD "Official Twitter-Account") --- From ea236a7ffa1af6aee01d8a8a2d8228ba61a4d49a Mon Sep 17 00:00:00 2001 From: "Security: Pwned." Date: Fri, 15 May 2015 10:24:26 +0000 Subject: [PATCH 02/15] Added link to our donation guide --- CONTRIBUTING.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d120ccad..34f524095 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,6 +43,14 @@ Can't code (yet)? No problem, we love you too! --- +#### DONATING + +Thank you for encouraging our developers! + +* Feel invited to donate using [this guide](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki/Donations). + +--- + #### SEEKING Special positions we are currently seeking skilled people for: From 3908e8f733eab9a71ac49892f986be46d7ae08a3 Mon Sep 17 00:00:00 2001 From: "Security: Pwned." Date: Fri, 15 May 2015 14:51:26 +0000 Subject: [PATCH 03/15] Switched to permanent HEAD links --- app/src/main/res/values/untranslatable_strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values/untranslatable_strings.xml b/app/src/main/res/values/untranslatable_strings.xml index afa41c030..9ad8c61e3 100644 --- a/app/src/main/res/values/untranslatable_strings.xml +++ b/app/src/main/res/values/untranslatable_strings.xml @@ -9,12 +9,12 @@ Android IMSI-Catcher Detector (AIMSICD) https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/wiki - https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/development/CONTRIBUTING.md - https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/master/DISCLAIMER + https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/HEAD/CONTRIBUTING.md + https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/HEAD/DISCLAIMER https://secupwn.github.io/Android-IMSI-Catcher-Detector/ https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases - https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/master/CHANGELOG.md - https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/master/LICENSE + https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/HEAD/CHANGELOG.md + https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/blob/HEAD/LICENSE pref_enable_cell_monitoring pref_enable_cell_key From f3e8161539dd6b98c0d4ea879a103632ed445a02 Mon Sep 17 00:00:00 2001 From: agilob Date: Mon, 18 May 2015 18:56:53 +0100 Subject: [PATCH 04/15] moving data to new location, replaced all env directories --- .../java/com/SecUpwN/AIMSICD/AIMSICD.java | 42 +++++++++++++++++ .../AIMSICD/adapters/AIMSICDDbAdapter.java | 4 +- .../SecUpwN/AIMSICD/service/CellTracker.java | 2 +- .../com/SecUpwN/AIMSICD/utils/Helpers.java | 47 ++++++++++--------- .../SecUpwN/AIMSICD/utils/RequestTask.java | 5 +- .../com/SecUpwN/AIMSICD/utils/TinyDB.java | 2 +- 6 files changed, 73 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java b/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java index 43f7dd497..451004d27 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java @@ -17,8 +17,11 @@ import android.content.res.Configuration; import android.net.Uri; import android.os.Bundle; +import android.os.Environment; import android.os.IBinder; +import android.provider.MediaStore; import android.support.v4.app.ActionBarDrawerToggle; +import android.support.v4.content.ContextCompat; import android.support.v4.widget.DrawerLayout; import android.telephony.TelephonyManager; import android.util.Log; @@ -55,6 +58,12 @@ import com.SecUpwN.AIMSICD.utils.LocationServices; import com.SecUpwN.AIMSICD.utils.RequestTask; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; @@ -100,6 +109,8 @@ public class AIMSICD extends BaseActivity implements AsyncResponse { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + moveData(); + getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS); mNavConf = new DrawerMenuActivityConfiguration.Builder(this).build(); @@ -625,4 +636,35 @@ public void onStart() { ((AppAIMSICD) getApplication()).attach(this); } + /** + * TODO: Remove move in 2016. + * All people should have more than enough time to update their AIMSICD + * this method will be obsolete. + */ + private void moveData() { + + // /storage/emulated/0/Android/data/com.SecUpwN.AIMSICD/ + File destinedPath = new File(getExternalFilesDir(null) + File.separator); + // /storage/emulated/0/AIMSICD + File currentPath = new File(Environment.getExternalStorageDirectory().toString() + "/AIMSICD"); + //Log.d(TAG, destinedPath.toString()); + //Log.d(TAG, currentPath.toString()); + + //checks if /storage/emulated/0/AIMSICD exists + if(currentPath.exists()) { + // and if it's a directory, don't touch files + if(currentPath.isDirectory()) { + //list all files (and folders) in /storage/emulated/0/AIMSICD + File[] content = currentPath.listFiles(); + for(int i = 0; i < content.length; i++) { + File from = new File(content[i].toString()); + //move file to new directory + from.renameTo(new File(destinedPath.toString() + content[i].getName().toString())); + } + } + //remove current directory so it won't try to move it again + currentPath.delete(); + } + } + } diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java b/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java index 544226c17..726bf5f48 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java @@ -8,6 +8,7 @@ import android.content.ContentValues; import android.content.Context; +import android.content.SharedPreferences; import android.content.res.AssetManager; import android.database.Cursor; import android.database.SQLException; @@ -91,7 +92,7 @@ public class AIMSICDDbAdapter { - public static final String FOLDER = Environment.getExternalStorageDirectory() + "/AIMSICD/"; + public static String FOLDER; public static final int DATABASE_VERSION = 9; // Is this "pragma user_version;" ? // TODO: This should be implemented as a SharedPreference... @@ -147,6 +148,7 @@ public class AIMSICDDbAdapter { */ public AIMSICDDbAdapter(Context context) { mContext = context; + FOLDER = mContext.getExternalFilesDir(null) + File.separator; //e.g. /storage/emulated/0/Android/data/com.SecUpwN.AIMSICD/ mDbHelper = new DbHelper(context); mTables = new String[]{ // Old... diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java b/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java index 79efea6da..575e47476 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java @@ -422,7 +422,7 @@ public List updateNeighbouringCells() { List neighboringCells = new ArrayList<>(); List neighboringCellInfo; neighboringCellInfo = tm.getNeighboringCellInfo(); - + if (neighboringCellInfo.size() == 0) { // try to poll the neighboring cells for a few seconds neighboringCellBlockingQueue = new LinkedBlockingQueue<>(100); diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java b/app/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java index e6158ed83..5e0767f63 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/utils/Helpers.java @@ -380,29 +380,30 @@ public static List ByteArrayToStringList(byte[] byteArray, int dataLengt return result; } - /** - * Checks if the external media (SD Card) is writable - * - * @return boolean True if Writable - */ - public static boolean isSdWritable() { - - boolean mExternalStorageAvailable = false; - try { - String state = Environment.getExternalStorageState(); - - if (Environment.MEDIA_MOUNTED.equals(state)) { - // We can read and write the media - mExternalStorageAvailable = true; - Log.i(TAG, mTAG + ": External storage card is readable."); - } else { - mExternalStorageAvailable = false; - } - } catch (Exception ex) { - Log.e(TAG, mTAG + ":isSdWritable - " + ex.getMessage()); - } - return mExternalStorageAvailable; - } + // IT'S NEVER USED +// /** +// * Checks if the external media (SD Card) is writable +// * +// * @return boolean True if Writable +// */ +// public static boolean isSdWritable() { +// +// boolean mExternalStorageAvailable = false; +// try { +// String state = Environment.getExternalStorageState(); +// +// if (Environment.MEDIA_MOUNTED.equals(state)) { +// // We can read and write the media +// mExternalStorageAvailable = true; +// Log.i(TAG, mTAG + ": External storage card is readable."); +// } else { +// mExternalStorageAvailable = false; +// } +// } catch (Exception ex) { +// Log.e(TAG, mTAG + ":isSdWritable - " + ex.getMessage()); +// } +// return mExternalStorageAvailable; +// } /** * Return a String List representing response from invokeOemRilRequestRaw diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java b/app/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java index 13531eddf..d74c7473a 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/utils/RequestTask.java @@ -132,8 +132,7 @@ protected String doInBackground(String... commandString) { boolean prepared = mDbAdapter.prepareOpenCellUploadData(); Log.i(TAG, mTAG + ": OCID upload data prepared - " + String.valueOf(prepared)); if (prepared) { - File file = new File(Environment.getExternalStorageDirectory() - + "/AIMSICD/OpenCellID/aimsicd-ocid-data.csv"); + File file = new File((mAppContext.getExternalFilesDir(null) + File.separator) + "OpenCellID/aimsicd-ocid-data.csv"); publishProgress(25,100); MultipartEntity mpEntity = new MultipartEntity(); @@ -193,7 +192,7 @@ protected String doInBackground(String... commandString) { int total; int progress = 0; - File dir = new File(Environment.getExternalStorageDirectory()+ "/AIMSICD/OpenCellID/"); + File dir = new File((mAppContext.getExternalFilesDir(null) + File.separator) + "OpenCellID/"); if (!dir.exists()) { dir.mkdirs(); } // need a try{} catch{} File file = new File(dir, "opencellid.csv"); diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/utils/TinyDB.java b/app/src/main/java/com/SecUpwN/AIMSICD/utils/TinyDB.java index 539953201..17f11c4c3 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/utils/TinyDB.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/utils/TinyDB.java @@ -126,7 +126,7 @@ public Boolean putImagePNGwithfullPath(String fullPath, Bitmap theBitmap){ } private String setupFolderPath(String imageName) { - File sdcard_path = Environment.getExternalStorageDirectory(); + File sdcard_path = new File(mContext.getExternalFilesDir(null) + File.separator); mFolder = new File(sdcard_path, DEFAULT_APP_IMAGEDATA_DIRECTORY); if (!mFolder.exists()) { if (!mFolder.mkdirs()) { From 21e94b35e8457736e03dd03cc362b481c478d20b Mon Sep 17 00:00:00 2001 From: agilob Date: Mon, 18 May 2015 19:13:06 +0100 Subject: [PATCH 05/15] fix wired NPE related to TelephonyManager.getNeighboringCellInfo() --- .../SecUpwN/AIMSICD/service/CellTracker.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java b/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java index 575e47476..9a8e8e88c 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/service/CellTracker.java @@ -417,13 +417,13 @@ public static String requestNewOCIDKey() throws Exception { * */ public List updateNeighbouringCells() { - - List neighboringCells = new ArrayList<>(); - List neighboringCellInfo; - neighboringCellInfo = tm.getNeighboringCellInfo(); - - if (neighboringCellInfo.size() == 0) { + List neighboringCellInfo = tm.getNeighboringCellInfo(); + if(neighboringCellInfo == null) + neighboringCellInfo = new ArrayList<>(); + + if (neighboringCellInfo != null && + neighboringCellInfo.size() == 0) { // try to poll the neighboring cells for a few seconds neighboringCellBlockingQueue = new LinkedBlockingQueue<>(100); Log.i(TAG, mTAG + ": neighbouringCellInfo empty - start polling"); @@ -447,6 +447,7 @@ public List updateNeighbouringCells() { NeighboringCellInfo info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS); if (info == null) { neighboringCellInfo = tm.getNeighboringCellInfo(); + if(neighboringCellInfo != null) if (neighboringCellInfo.size() > 0) { // Can we think of a better log message here? Log.d(TAG, mTAG + ": neighbouringCellInfo found on " + i + " try. (time based)"); @@ -469,7 +470,8 @@ public List updateNeighbouringCells() { } } - Log.d(TAG, mTAG + ": neighbouringCellInfo size: " + neighboringCellInfo.size()); + //commented because I got NPE here + //Log.d(TAG, mTAG + ": neighbouringCellInfo size: " + neighboringCellInfo.size()); /* @@ -672,14 +674,15 @@ public void compareLac(CellLocation location){ } private void handlePhoneStateChange() { - List neighboringCellInfo; - neighboringCellInfo = tm.getNeighboringCellInfo(); - if (neighboringCellInfo.size() == 0) { + List neighboringCellInfo = tm.getNeighboringCellInfo(); + if (neighboringCellInfo == null || neighboringCellInfo.size() == 0) { return; } // Does this make sense? Is it empty or not? Log.i(TAG, mTAG + ": neighbouringCellInfo empty - event based polling succeeded!"); tm.listen(phoneStatelistener, PhoneStateListener.LISTEN_NONE); + if(neighboringCellInfo == null) + neighboringCellInfo = new ArrayList<>(); neighboringCellBlockingQueue.addAll(neighboringCellInfo); } From 3ff830701c4ce6a2620c919448dc0ed8713dd9ed Mon Sep 17 00:00:00 2001 From: ziem Date: Wed, 20 May 2015 19:05:36 +0200 Subject: [PATCH 06/15] Added BTS map legend --- app/src/main/res/layout/map.xml | 101 +++++++++++++++--- app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/dimens.xml | 1 + .../main/res/values/translatable_strings.xml | 10 +- 4 files changed, 95 insertions(+), 18 deletions(-) diff --git a/app/src/main/res/layout/map.xml b/app/src/main/res/layout/map.xml index 56f6cb510..b839af853 100644 --- a/app/src/main/res/layout/map.xml +++ b/app/src/main/res/layout/map.xml @@ -1,31 +1,100 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + tools:context=".MapViewerOsmDroid"> - - + + + android:singleLine="true" + android:text="@string/osm_contributors" + android:textColor="#ff454545" + android:textStyle="normal"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4c37fff5b..0070bc9e0 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,6 +2,7 @@ #ffffffff + #50ffffff #ff000000 #ff0d0d0d #ff00FF00 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 62f73a668..fdf0ca536 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,4 +1,5 @@ 8dp + 4dp \ No newline at end of file diff --git a/app/src/main/res/values/translatable_strings.xml b/app/src/main/res/values/translatable_strings.xml index ca9118818..ebce9f7a0 100644 --- a/app/src/main/res/values/translatable_strings.xml +++ b/app/src/main/res/values/translatable_strings.xml @@ -325,8 +325,14 @@ Measured Signal Strengths *** Looking for AT serial devices…\n - Found: "" - *** Setup Complete ***\n"" + Found: + *** Setup Complete ***\n + + Currently connected BTS + Well known encrypted BTS + Unknown or insecure BTS + New or recently added BTS + @string/ui_icon_flat @string/ui_icon_sense From 420914116e106c76352ce04f622ca19eed4f089f Mon Sep 17 00:00:00 2001 From: agilob Date: Wed, 20 May 2015 18:58:11 +0100 Subject: [PATCH 07/15] load table automatically on item selected --- .../AIMSICD/fragments/DbViewerFragment.java | 83 ++++++------------- app/src/main/res/layout/db_view.xml | 6 -- 2 files changed, 27 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/fragments/DbViewerFragment.java b/app/src/main/java/com/SecUpwN/AIMSICD/fragments/DbViewerFragment.java index c87e82c70..e9b2e8ebf 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/fragments/DbViewerFragment.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/fragments/DbViewerFragment.java @@ -10,7 +10,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; -import android.widget.Button; import android.widget.ListView; import android.widget.Spinner; @@ -35,7 +34,6 @@ public class DbViewerFragment extends Fragment { private AIMSICDDbAdapter mDb; private StatesDbViewer mTableSelected; - private boolean mMadeSelection; private Context mContext; //Layout items @@ -58,50 +56,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View view = inflater.inflate(R.layout.db_view, container, false); - if (view != null) { - lv = (ListView) view.findViewById(R.id.list_view); - emptyView = view.findViewById(R.id.db_list_empty); + lv = (ListView) view.findViewById(R.id.list_view); + emptyView = view.findViewById(R.id.db_list_empty); + tblSpinner = (Spinner) view.findViewById(R.id.table_spinner); + DbViewerSpinnerAdapter mSpinnerAdapter = new DbViewerSpinnerAdapter(getActivity(), R.layout.item_spinner_db_viewer); + tblSpinner.setAdapter(mSpinnerAdapter); - tblSpinner = (Spinner) view.findViewById(R.id.table_spinner); - DbViewerSpinnerAdapter mSpinnerAdapter = new DbViewerSpinnerAdapter(getActivity(), R.layout.item_spinner_db_viewer); - tblSpinner.setAdapter(mSpinnerAdapter); - tblSpinner.setOnItemSelectedListener(new spinnerListener()); - - Button loadTable = (Button) view.findViewById(R.id.load_table_data); - loadTable.setOnClickListener(new btnClick()); - } - - return view; - } - - private class spinnerListener implements AdapterView.OnItemSelectedListener { - - @Override - public void onItemSelected(AdapterView parentView, View selectedItemView, int position, long id) { - - mTableSelected = (StatesDbViewer)tblSpinner.getSelectedItem(); - - mMadeSelection = true; - } - - @Override - public void onNothingSelected(AdapterView parentView) { - mMadeSelection = false; - } - } - - /** - * Button Click (DB table selector) of "Database Viewer" - * - */ - private class btnClick implements View.OnClickListener { - - @Override - public void onClick(final View v) { - if (mMadeSelection) { - v.setEnabled(false); - getActivity().setProgressBarIndeterminateVisibility(true); - lv.setVisibility(View.GONE); + Spinner spnLocale = (Spinner) view.findViewById(R.id.table_spinner); + spnLocale.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parentView, View selectedItemView, final int position, long id) { new AsyncTask () { @@ -113,42 +77,43 @@ protected BaseInflaterAdapter doInBackground(Void... params) { //TODO Table: "DetectionFlags" //case DETECTION_FLAGS: //result = mDb.getDetectionFlagsData(); - switch (mTableSelected) { + mTableSelected = (StatesDbViewer)tblSpinner.getSelectedItem(); - case UNIQUE_BTS_DATA: + switch (position) { + case 0: //UNIQUE_BTS_DATA // The unique BTSs we have been connected to in the past // EVA: Was "Cell Data" // Table: cellinfo // ToBe: "DBi_bts" result = mDb.getCellData(); break; - case BTS_MEASUREMENTS: + case 1: //BTS_MEASUREMENTS: // All BTS measurements we have done since start // EVA: Was "Location Data" // Table: locationinfo // ToBe: "DBi_measure" result = mDb.getLocationData(); break; - case IMPORTED_OCID_DATA: + case 2: //IMPORTED_OCID_DATA: // EVA: Was "OpenCellID Data" // Table: opencellid // ToBe: "DBe_import" result = mDb.getOpenCellIDData(); break; - case DEFAULT_MCC_LOCATIONS: + case 3: //DEFAULT_MCC_LOCATIONS: result = mDb.getDefaultMccLocationData(); break; - case SILENT_SMS: + case 4: //SILENT_SMS: result = mDb.getSilentSmsData(); break; - case MEASURED_SIGNAL_STRENGTHS: + case 5: //MEASURED_SIGNAL_STRENGTHS: // ToBe merged into "DBi_measure:rx_signal" result = mDb.getSignalStrengthMeasurementData(); break; - case EVENT_LOG: + case 6: //EVENT_LOG: // Table: "EventLog" result = mDb.getEventLogData(); break; @@ -156,6 +121,7 @@ protected BaseInflaterAdapter doInBackground(Void... params) { default: throw new IllegalArgumentException("Unknown type of table"); } + BaseInflaterAdapter adapter = null; if (result != null) { adapter = BuildTable(result); @@ -176,15 +142,20 @@ protected void onPostExecute(BaseInflaterAdapter adapter) { } else { lv.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); - //Helpers.msgShort(mContext, "Table contains no data to display."); } - v.setEnabled(true); getActivity().setProgressBarIndeterminateVisibility(false); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } - } + + @Override + public void onNothingSelected(AdapterView parentView) { + return; + } + }); + + return view; } /** diff --git a/app/src/main/res/layout/db_view.xml b/app/src/main/res/layout/db_view.xml index a1fa34e95..67dfa0ca4 100644 --- a/app/src/main/res/layout/db_view.xml +++ b/app/src/main/res/layout/db_view.xml @@ -17,12 +17,6 @@ android:entries="@array/table_names" android:prompt="@string/table_names_prompt" android:layout_weight="5"/> -