Skip to content

Commit

Permalink
Merge pull request #638 from SecUpwN/development
Browse files Browse the repository at this point in the history
Unchaining WIP-Release v0.1.36-alpha-build-00
  • Loading branch information
SecUpwN committed Nov 15, 2015
2 parents b56c947 + c5dfd15 commit 93b4247
Show file tree
Hide file tree
Showing 21 changed files with 448 additions and 158 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# CHANGELOG of 'AIMSICD'
----------------------

#### [15.11.2015 - WIP-Release v0.1.36-alpha-build-00](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases/tag/v0.1.36-alpha-b00)

* Changed: **We're now back from a huge break and intend to improve our project in all areas!**
* Updated: Improved Japanese, French, Russian German and Czech translations, added Lithuanian
* Updated: Formatted both comments and code, working torwards an easier code structure
* Updated: RootShell library pushed to version 1.3, thanked [smarek](https://github.com/smarek) in `CREDITS` for saving us
* Removed: Unused imports, unused class-global variables and dual `view.findViewById` calls
* Removed: Unnecessary `return` call and unused `count` variable
* Added: New vibration options in new menu `NOTIFICATION SETTINGS` (see `Preferences`)
* Fixed: Phone will no longer vibrate every few seconds on status changes (set it yourself)
* Fixed: Issue where `getSelectedItem()` was called in `doInBackground`
* Fixed: Handled unchecked type of `getSelectedItem()` return
* Fixed: Avoided NPE on `result.close();`

#### [20.09.2015 - WIP-Release v0.1.35-alpha-build-00](https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/releases/tag/v0.1.35-alpha-b00)

* Changed: Improved code quality and better error handling
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.SecUpwN.AIMSICD"
android:versionCode="35"
android:versionName="0.1.35-alpha-b00">
android:versionCode="36"
android:versionName="0.1.36-alpha-b00">

<!-- If we ever wanna make this a system app, we can add the following 2 lines above:
coreApp="true"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/assets/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,7 @@ https://changelog.com/\n
for their podcast and tweet about us!\n
(SPECIAL THANKS to Jerod)
\n
Marek Sebera\n
https://github.com/smarek\n
for saving our project from death!\n
\n
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.Log;
import android.util.SparseArray;

import com.SecUpwN.AIMSICD.AIMSICD;
import com.SecUpwN.AIMSICD.R;
import com.SecUpwN.AIMSICD.constants.DBTableColumnIds;
import com.SecUpwN.AIMSICD.service.CellTracker;
import com.SecUpwN.AIMSICD.smsdetection.AdvanceUserItems;
import com.SecUpwN.AIMSICD.smsdetection.CapturedSmsData;
import com.SecUpwN.AIMSICD.utils.CMDProcessor;
import com.SecUpwN.AIMSICD.utils.Cell;
import com.SecUpwN.AIMSICD.utils.MiscUtils;
import com.SecUpwN.AIMSICD.utils.Status;

import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -138,10 +142,12 @@ public class AIMSICDDbAdapter extends SQLiteOpenHelper{
private String[] mTables;
private SQLiteDatabase mDb;
private Context mContext;
private SharedPreferences mPreferences;

public AIMSICDDbAdapter(Context context) {
super(context, DB_NAME, null, 1);
mContext = context;
mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
FOLDER = mContext.getExternalFilesDir(null) + File.separator;
//e.g. /storage/emulated/0/Android/data/com.SecUpwN.AIMSICD/

Expand Down Expand Up @@ -2161,9 +2167,17 @@ public void toEventLog(int DF_id, String DF_desc){

mDb.insert("EventLog", null, eventLog);
Log.i(TAG, "ToEventLog(): Added new event: id=" + DF_id + " time=" + time + " cid=" + cid);

// Short 100 ms Vibration
Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(100);
// TODO not elegant solution, vibrator invocation should be moved somewhere else imho
boolean vibrationEnabled = mPreferences.getBoolean(mContext.getString(R.string.pref_notification_vibrate_enable), true);
int thresholdLevel = Integer.valueOf(mPreferences.getString(mContext.getString(R.string.pref_notification_vibrate_min_level), String.valueOf(Status.Type.MEDIUM.level)));
boolean higherLevelThanThreshold = Status.Type.MEDIUM.level <= thresholdLevel;

if (vibrationEnabled && higherLevelThanThreshold) {
Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(100);
}

// Short sound:
// TODO see issue #15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.SecUpwN.AIMSICD.fragments;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
Expand All @@ -19,7 +18,6 @@
import com.SecUpwN.AIMSICD.adapters.BtsMeasureCardInflater;
import com.SecUpwN.AIMSICD.adapters.BtsMeasureItemData;
import com.SecUpwN.AIMSICD.adapters.CardItemData;
import com.SecUpwN.AIMSICD.adapters.CellCardInflater;
import com.SecUpwN.AIMSICD.adapters.DbViewerSpinnerAdapter;
import com.SecUpwN.AIMSICD.adapters.DbeImportCardInflater;
import com.SecUpwN.AIMSICD.adapters.DbeImportItemData;
Expand All @@ -28,9 +26,7 @@
import com.SecUpwN.AIMSICD.adapters.EventLogItemData;
import com.SecUpwN.AIMSICD.adapters.MeasuredCellStrengthCardData;
import com.SecUpwN.AIMSICD.adapters.MeasuredCellStrengthCardInflater;
import com.SecUpwN.AIMSICD.adapters.OpenCellIdCardInflater;
import com.SecUpwN.AIMSICD.adapters.SilentSmsCardData;
import com.SecUpwN.AIMSICD.adapters.SilentSmsCardInflater;
import com.SecUpwN.AIMSICD.adapters.UniqueBtsCardInflater;
import com.SecUpwN.AIMSICD.adapters.UniqueBtsItemData;
import com.SecUpwN.AIMSICD.constants.DBTableColumnIds;
Expand All @@ -41,28 +37,24 @@
import com.SecUpwN.AIMSICD.smsdetection.DetectionStringsCardInflater;
import com.SecUpwN.AIMSICD.smsdetection.DetectionStringsData;

import java.util.ArrayList;

/**
* Description: Class that handles the display of the items in the 'Database Viewer' (DBV)
*
* Issues:
*
* Notes: See issue #234 for details on how to format the UI
*
* ChangeLog:
*
* 2015-07-14 E:V:A Changed the display names of several items (see issue #234)
* 2015-07-31 E:V:A Added comments and changed some inflater data to avoid using:
* DBTableColumnIds.java. More to do... Use string convert trick:
* "" + int = "string" (See EventLog for example)
*
* Description: Class that handles the display of the items in the 'Database Viewer' (DBV)
* <p/>
* Issues:
* <p/>
* Notes: See issue #234 for details on how to format the UI
* <p/>
* ChangeLog:
* <p/>
* 2015-07-14 E:V:A Changed the display names of several items (see issue #234)
* 2015-07-31 E:V:A Added comments and changed some inflater data to avoid using:
* DBTableColumnIds.java. More to do... Use string convert trick:
* "" + int = "string" (See EventLog for example)
*/
public class DbViewerFragment extends Fragment {
public final class DbViewerFragment extends Fragment {

private AIMSICDDbAdapter mDb;
private StatesDbViewer mTableSelected;
private Context mContext;

// Layout items
private Spinner tblSpinner;
Expand All @@ -75,35 +67,32 @@ public DbViewerFragment() {
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mContext = activity.getBaseContext();
mDb = new AIMSICDDbAdapter(mContext);
mDb = new AIMSICDDbAdapter(activity.getBaseContext());
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.db_view, container, false);

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);

Spinner spnLocale = (Spinner) view.findViewById(R.id.table_spinner);
spnLocale.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
tblSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, final int position, long id) {

new AsyncTask<Void, Void, BaseInflaterAdapter> () {
Object selectedItem = tblSpinner.getSelectedItem();
if (!(selectedItem instanceof StatesDbViewer)) {
return;
}
mTableSelected = (StatesDbViewer) selectedItem;
new AsyncTask<Void, Void, BaseInflaterAdapter>() {

@Override
protected BaseInflaterAdapter doInBackground(Void... params) {
//# mDb.open();
Cursor result;
ArrayList<String> CellDetails = new ArrayList<String>();

mTableSelected = (StatesDbViewer)tblSpinner.getSelectedItem();

switch (position) {
case 0: // UNIQUE_BTS_DATA ("DBi_bts")
Expand Down Expand Up @@ -156,9 +145,9 @@ protected BaseInflaterAdapter doInBackground(Void... params) {
BaseInflaterAdapter adapter = null;
if (result != null) {
adapter = BuildTable(result);
result.close();
}
//# mDb.close();
result.close();

return adapter;
}

Expand All @@ -182,7 +171,6 @@ protected void onPostExecute(BaseInflaterAdapter adapter) {

@Override
public void onNothingSelected(AdapterView<?> parentView) {
return;
}
});

Expand All @@ -191,24 +179,23 @@ public void onNothingSelected(AdapterView<?> parentView) {

/**
* Description: Content layout and presentation of the Database Viewer
*
* This is where the text labels are created for each column in
* the Database Viewer (DBV). For details of how this should be presented, see:
* https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/234
*
* <p/>
* This is where the text labels are created for each column in
* the Database Viewer (DBV). For details of how this should be presented, see:
* https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/234
* <p/>
* Lat/Lng: Latitude / Longitude (We should use "Lon" instead of "Lng".)
* AvgSignal: Average Signal Strength
* RSSI: Received Signal Strength Indicator (previously "Signal Strength")
* Can have different meanings on different RAN's, e.g. RSCP in UMTS.
* Can have different meanings on different RAN's, e.g. RSCP in UMTS.
* RAN: Radio Access Network (GSM, UMTS, LTE etc.)
*
* <p/>
* Notes:
*
* 1. Although "RAN" is more correct here, we'll use "RAT" (Radio Access Technology),
* which is the more common terminology. Thus reverting.
*
* 2. Since Signal is not an "indicator" we should just call it "RSS" or "RXS"
*
* <p/>
* 1. Although "RAN" is more correct here, we'll use "RAT" (Radio Access Technology),
* which is the more common terminology. Thus reverting.
* <p/>
* 2. Since Signal is not an "indicator" we should just call it "RSS" or "RXS"
*/
private BaseInflaterAdapter BuildTable(Cursor tableData) {
if (tableData != null && tableData.getCount() > 0) {
Expand All @@ -235,7 +222,7 @@ private BaseInflaterAdapter BuildTable(Cursor tableData) {
tableData.getString(tableData.getColumnIndex(DBTableColumnIds.DBI_BTS_LON)), // gps_lon
(tableData.getPosition() + 1) + " / " + count // item: "n/X"
);
adapter.addItem(data,false);
adapter.addItem(data, false);
}
if (!tableData.isClosed()) {
tableData.close();
Expand All @@ -254,7 +241,7 @@ private BaseInflaterAdapter BuildTable(Cursor tableData) {
// WARNING! The ORDER and number of these are crucial, and need to correspond
// to what's found in: BtsMeasureCardInflater.java and BtsMeasureItemData.java
BtsMeasureItemData data = new BtsMeasureItemData(
"bts_id: " + String.valueOf(tableData.getInt(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_BTS_ID))), // TODO: Wrong! Should be DBi_bts:CID
"bts_id: " + String.valueOf(tableData.getInt(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_BTS_ID))), // TODO: Wrong! Should be DBi_bts:CID
"n/a", // + tableData.getString(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_NC_LIST)), // nc_list TODO: fix
tableData.getString(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_TIME)), // time
tableData.getString(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_GPSD_LAT)), // gpsd_lat
Expand Down Expand Up @@ -397,10 +384,10 @@ private BaseInflaterAdapter BuildTable(Cursor tableData) {
//int count = tableData.getCount();
while (tableData.moveToNext()) {
MeasuredCellStrengthCardData data = new MeasuredCellStrengthCardData(
tableData.getInt(tableData.getColumnIndex("bts_id")), // TODO: CID
Integer.parseInt(tableData.getString(tableData.getColumnIndex("rx_signal"))), // rx_signal
tableData.getString(tableData.getColumnIndex("time")) // time
//"" + (tableData.getPosition() + 1) + " / " + count // item: "n/X"
tableData.getInt(tableData.getColumnIndex("bts_id")), // TODO: CID
Integer.parseInt(tableData.getString(tableData.getColumnIndex("rx_signal"))), // rx_signal
tableData.getString(tableData.getColumnIndex("time")) // time
//"" + (tableData.getPosition() + 1) + " / " + count // item: "n/X"
);
adapter.addItem(data, false);
}
Expand Down Expand Up @@ -446,7 +433,6 @@ private BaseInflaterAdapter BuildTable(Cursor tableData) {
// Storage of Abnormal SMS detection strings
BaseInflaterAdapter<DetectionStringsData> adapter
= new BaseInflaterAdapter<>(new DetectionStringsCardInflater());
int count = tableData.getCount();
while (tableData.moveToNext()) {
DetectionStringsData data = new DetectionStringsData(
tableData.getString(tableData.getColumnIndex("det_str")), // det_str
Expand Down
Loading

0 comments on commit 93b4247

Please sign in to comment.