Skip to content

Commit 93b4247

Browse files
committed
Merge pull request #638 from SecUpwN/development
Unchaining WIP-Release v0.1.36-alpha-build-00
2 parents b56c947 + c5dfd15 commit 93b4247

21 files changed

Lines changed: 448 additions & 158 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# CHANGELOG of 'AIMSICD'
22
----------------------
33

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

620
* Changed: Improved code quality and better error handling

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.SecUpwN.AIMSICD"
5-
android:versionCode="35"
6-
android:versionName="0.1.35-alpha-b00">
5+
android:versionCode="36"
6+
android:versionName="0.1.36-alpha-b00">
77

88
<!-- If we ever wanna make this a system app, we can add the following 2 lines above:
99
coreApp="true"

app/src/main/assets/CREDITS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,7 @@ https://changelog.com/\n
232232
for their podcast and tweet about us!\n
233233
(SPECIAL THANKS to Jerod)
234234
\n
235+
Marek Sebera\n
236+
https://github.com/smarek\n
237+
for saving our project from death!\n
238+
\n

app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@
22

33
import android.content.ContentValues;
44
import android.content.Context;
5+
import android.content.SharedPreferences;
56
import android.database.Cursor;
67
import android.database.SQLException;
78
import android.database.sqlite.SQLiteDatabase;
89
import android.database.sqlite.SQLiteException;
910
import android.database.sqlite.SQLiteOpenHelper;
1011
import android.os.Vibrator;
12+
import android.preference.PreferenceManager;
1113
import android.util.Log;
1214
import android.util.SparseArray;
1315

1416
import com.SecUpwN.AIMSICD.AIMSICD;
17+
import com.SecUpwN.AIMSICD.R;
1518
import com.SecUpwN.AIMSICD.constants.DBTableColumnIds;
1619
import com.SecUpwN.AIMSICD.service.CellTracker;
1720
import com.SecUpwN.AIMSICD.smsdetection.AdvanceUserItems;
1821
import com.SecUpwN.AIMSICD.smsdetection.CapturedSmsData;
1922
import com.SecUpwN.AIMSICD.utils.CMDProcessor;
2023
import com.SecUpwN.AIMSICD.utils.Cell;
2124
import com.SecUpwN.AIMSICD.utils.MiscUtils;
25+
import com.SecUpwN.AIMSICD.utils.Status;
2226

2327
import java.io.File;
2428
import java.io.FileOutputStream;
@@ -138,10 +142,12 @@ public class AIMSICDDbAdapter extends SQLiteOpenHelper{
138142
private String[] mTables;
139143
private SQLiteDatabase mDb;
140144
private Context mContext;
145+
private SharedPreferences mPreferences;
141146

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

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

21622168
mDb.insert("EventLog", null, eventLog);
21632169
Log.i(TAG, "ToEventLog(): Added new event: id=" + DF_id + " time=" + time + " cid=" + cid);
2170+
21642171
// Short 100 ms Vibration
2165-
Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
2166-
v.vibrate(100);
2172+
// TODO not elegant solution, vibrator invocation should be moved somewhere else imho
2173+
boolean vibrationEnabled = mPreferences.getBoolean(mContext.getString(R.string.pref_notification_vibrate_enable), true);
2174+
int thresholdLevel = Integer.valueOf(mPreferences.getString(mContext.getString(R.string.pref_notification_vibrate_min_level), String.valueOf(Status.Type.MEDIUM.level)));
2175+
boolean higherLevelThanThreshold = Status.Type.MEDIUM.level <= thresholdLevel;
2176+
2177+
if (vibrationEnabled && higherLevelThanThreshold) {
2178+
Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
2179+
v.vibrate(100);
2180+
}
21672181

21682182
// Short sound:
21692183
// TODO see issue #15

app/src/main/java/com/SecUpwN/AIMSICD/fragments/DbViewerFragment.java

Lines changed: 41 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.SecUpwN.AIMSICD.fragments;
22

33
import android.app.Activity;
4-
import android.content.Context;
54
import android.database.Cursor;
65
import android.os.AsyncTask;
76
import android.os.Bundle;
@@ -19,7 +18,6 @@
1918
import com.SecUpwN.AIMSICD.adapters.BtsMeasureCardInflater;
2019
import com.SecUpwN.AIMSICD.adapters.BtsMeasureItemData;
2120
import com.SecUpwN.AIMSICD.adapters.CardItemData;
22-
import com.SecUpwN.AIMSICD.adapters.CellCardInflater;
2321
import com.SecUpwN.AIMSICD.adapters.DbViewerSpinnerAdapter;
2422
import com.SecUpwN.AIMSICD.adapters.DbeImportCardInflater;
2523
import com.SecUpwN.AIMSICD.adapters.DbeImportItemData;
@@ -28,9 +26,7 @@
2826
import com.SecUpwN.AIMSICD.adapters.EventLogItemData;
2927
import com.SecUpwN.AIMSICD.adapters.MeasuredCellStrengthCardData;
3028
import com.SecUpwN.AIMSICD.adapters.MeasuredCellStrengthCardInflater;
31-
import com.SecUpwN.AIMSICD.adapters.OpenCellIdCardInflater;
3229
import com.SecUpwN.AIMSICD.adapters.SilentSmsCardData;
33-
import com.SecUpwN.AIMSICD.adapters.SilentSmsCardInflater;
3430
import com.SecUpwN.AIMSICD.adapters.UniqueBtsCardInflater;
3531
import com.SecUpwN.AIMSICD.adapters.UniqueBtsItemData;
3632
import com.SecUpwN.AIMSICD.constants.DBTableColumnIds;
@@ -41,28 +37,24 @@
4137
import com.SecUpwN.AIMSICD.smsdetection.DetectionStringsCardInflater;
4238
import com.SecUpwN.AIMSICD.smsdetection.DetectionStringsData;
4339

44-
import java.util.ArrayList;
45-
4640
/**
47-
* Description: Class that handles the display of the items in the 'Database Viewer' (DBV)
48-
*
49-
* Issues:
50-
*
51-
* Notes: See issue #234 for details on how to format the UI
52-
*
53-
* ChangeLog:
54-
*
55-
* 2015-07-14 E:V:A Changed the display names of several items (see issue #234)
56-
* 2015-07-31 E:V:A Added comments and changed some inflater data to avoid using:
57-
* DBTableColumnIds.java. More to do... Use string convert trick:
58-
* "" + int = "string" (See EventLog for example)
59-
*
41+
* Description: Class that handles the display of the items in the 'Database Viewer' (DBV)
42+
* <p/>
43+
* Issues:
44+
* <p/>
45+
* Notes: See issue #234 for details on how to format the UI
46+
* <p/>
47+
* ChangeLog:
48+
* <p/>
49+
* 2015-07-14 E:V:A Changed the display names of several items (see issue #234)
50+
* 2015-07-31 E:V:A Added comments and changed some inflater data to avoid using:
51+
* DBTableColumnIds.java. More to do... Use string convert trick:
52+
* "" + int = "string" (See EventLog for example)
6053
*/
61-
public class DbViewerFragment extends Fragment {
54+
public final class DbViewerFragment extends Fragment {
6255

6356
private AIMSICDDbAdapter mDb;
6457
private StatesDbViewer mTableSelected;
65-
private Context mContext;
6658

6759
// Layout items
6860
private Spinner tblSpinner;
@@ -75,35 +67,32 @@ public DbViewerFragment() {
7567
@Override
7668
public void onAttach(Activity activity) {
7769
super.onAttach(activity);
78-
mContext = activity.getBaseContext();
79-
mDb = new AIMSICDDbAdapter(mContext);
70+
mDb = new AIMSICDDbAdapter(activity.getBaseContext());
8071
}
8172

8273
@Override
8374
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
84-
8575
View view = inflater.inflate(R.layout.db_view, container, false);
8676

8777
lv = (ListView) view.findViewById(R.id.list_view);
8878
emptyView = view.findViewById(R.id.db_list_empty);
8979
tblSpinner = (Spinner) view.findViewById(R.id.table_spinner);
9080
DbViewerSpinnerAdapter mSpinnerAdapter = new DbViewerSpinnerAdapter(getActivity(), R.layout.item_spinner_db_viewer);
9181
tblSpinner.setAdapter(mSpinnerAdapter);
92-
93-
Spinner spnLocale = (Spinner) view.findViewById(R.id.table_spinner);
94-
spnLocale.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
82+
tblSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
9583
@Override
9684
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, final int position, long id) {
97-
98-
new AsyncTask<Void, Void, BaseInflaterAdapter> () {
85+
Object selectedItem = tblSpinner.getSelectedItem();
86+
if (!(selectedItem instanceof StatesDbViewer)) {
87+
return;
88+
}
89+
mTableSelected = (StatesDbViewer) selectedItem;
90+
new AsyncTask<Void, Void, BaseInflaterAdapter>() {
9991

10092
@Override
10193
protected BaseInflaterAdapter doInBackground(Void... params) {
10294
//# mDb.open();
10395
Cursor result;
104-
ArrayList<String> CellDetails = new ArrayList<String>();
105-
106-
mTableSelected = (StatesDbViewer)tblSpinner.getSelectedItem();
10796

10897
switch (position) {
10998
case 0: // UNIQUE_BTS_DATA ("DBi_bts")
@@ -156,9 +145,9 @@ protected BaseInflaterAdapter doInBackground(Void... params) {
156145
BaseInflaterAdapter adapter = null;
157146
if (result != null) {
158147
adapter = BuildTable(result);
148+
result.close();
159149
}
160-
//# mDb.close();
161-
result.close();
150+
162151
return adapter;
163152
}
164153

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

183172
@Override
184173
public void onNothingSelected(AdapterView<?> parentView) {
185-
return;
186174
}
187175
});
188176

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

192180
/**
193181
* Description: Content layout and presentation of the Database Viewer
194-
*
195-
* This is where the text labels are created for each column in
196-
* the Database Viewer (DBV). For details of how this should be presented, see:
197-
* https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/234
198-
*
182+
* <p/>
183+
* This is where the text labels are created for each column in
184+
* the Database Viewer (DBV). For details of how this should be presented, see:
185+
* https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/234
186+
* <p/>
199187
* Lat/Lng: Latitude / Longitude (We should use "Lon" instead of "Lng".)
200188
* AvgSignal: Average Signal Strength
201189
* RSSI: Received Signal Strength Indicator (previously "Signal Strength")
202-
* Can have different meanings on different RAN's, e.g. RSCP in UMTS.
190+
* Can have different meanings on different RAN's, e.g. RSCP in UMTS.
203191
* RAN: Radio Access Network (GSM, UMTS, LTE etc.)
204-
*
192+
* <p/>
205193
* Notes:
206-
*
207-
* 1. Although "RAN" is more correct here, we'll use "RAT" (Radio Access Technology),
208-
* which is the more common terminology. Thus reverting.
209-
*
210-
* 2. Since Signal is not an "indicator" we should just call it "RSS" or "RXS"
211-
*
194+
* <p/>
195+
* 1. Although "RAN" is more correct here, we'll use "RAT" (Radio Access Technology),
196+
* which is the more common terminology. Thus reverting.
197+
* <p/>
198+
* 2. Since Signal is not an "indicator" we should just call it "RSS" or "RXS"
212199
*/
213200
private BaseInflaterAdapter BuildTable(Cursor tableData) {
214201
if (tableData != null && tableData.getCount() > 0) {
@@ -235,7 +222,7 @@ private BaseInflaterAdapter BuildTable(Cursor tableData) {
235222
tableData.getString(tableData.getColumnIndex(DBTableColumnIds.DBI_BTS_LON)), // gps_lon
236223
(tableData.getPosition() + 1) + " / " + count // item: "n/X"
237224
);
238-
adapter.addItem(data,false);
225+
adapter.addItem(data, false);
239226
}
240227
if (!tableData.isClosed()) {
241228
tableData.close();
@@ -254,7 +241,7 @@ private BaseInflaterAdapter BuildTable(Cursor tableData) {
254241
// WARNING! The ORDER and number of these are crucial, and need to correspond
255242
// to what's found in: BtsMeasureCardInflater.java and BtsMeasureItemData.java
256243
BtsMeasureItemData data = new BtsMeasureItemData(
257-
"bts_id: " + String.valueOf(tableData.getInt(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_BTS_ID))), // TODO: Wrong! Should be DBi_bts:CID
244+
"bts_id: " + String.valueOf(tableData.getInt(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_BTS_ID))), // TODO: Wrong! Should be DBi_bts:CID
258245
"n/a", // + tableData.getString(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_NC_LIST)), // nc_list TODO: fix
259246
tableData.getString(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_TIME)), // time
260247
tableData.getString(tableData.getColumnIndex(DBTableColumnIds.DBI_MEASURE_GPSD_LAT)), // gpsd_lat
@@ -397,10 +384,10 @@ private BaseInflaterAdapter BuildTable(Cursor tableData) {
397384
//int count = tableData.getCount();
398385
while (tableData.moveToNext()) {
399386
MeasuredCellStrengthCardData data = new MeasuredCellStrengthCardData(
400-
tableData.getInt(tableData.getColumnIndex("bts_id")), // TODO: CID
401-
Integer.parseInt(tableData.getString(tableData.getColumnIndex("rx_signal"))), // rx_signal
402-
tableData.getString(tableData.getColumnIndex("time")) // time
403-
//"" + (tableData.getPosition() + 1) + " / " + count // item: "n/X"
387+
tableData.getInt(tableData.getColumnIndex("bts_id")), // TODO: CID
388+
Integer.parseInt(tableData.getString(tableData.getColumnIndex("rx_signal"))), // rx_signal
389+
tableData.getString(tableData.getColumnIndex("time")) // time
390+
//"" + (tableData.getPosition() + 1) + " / " + count // item: "n/X"
404391
);
405392
adapter.addItem(data, false);
406393
}
@@ -446,7 +433,6 @@ private BaseInflaterAdapter BuildTable(Cursor tableData) {
446433
// Storage of Abnormal SMS detection strings
447434
BaseInflaterAdapter<DetectionStringsData> adapter
448435
= new BaseInflaterAdapter<>(new DetectionStringsCardInflater());
449-
int count = tableData.getCount();
450436
while (tableData.moveToNext()) {
451437
DetectionStringsData data = new DetectionStringsData(
452438
tableData.getString(tableData.getColumnIndex("det_str")), // det_str

0 commit comments

Comments
 (0)