Skip to content

Commit 3219b85

Browse files
committed
Minor updates
Minor tweaks to a number of items including moving some packages to local, declaring some variables as final etc.
1 parent d651a66 commit 3219b85

File tree

4 files changed

+78
-76
lines changed

4 files changed

+78
-76
lines changed

app/src/main/java/com/SecUpwN/AIMSICD/activities/MapViewer.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import android.content.SharedPreferences;
2626
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
2727
import android.database.Cursor;
28-
import android.graphics.BitmapFactory;
2928
import android.location.Location;
3029
import android.os.Bundle;
3130
import android.os.IBinder;
@@ -45,7 +44,6 @@
4544
import com.google.android.gms.maps.GoogleMap;
4645
import com.google.android.gms.maps.MapFragment;
4746
import com.google.android.gms.maps.UiSettings;
48-
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
4947
import com.google.android.gms.maps.model.CameraPosition;
5048
import com.google.android.gms.maps.model.CircleOptions;
5149
import com.google.android.gms.maps.model.LatLng;
@@ -74,7 +72,7 @@ public class MapViewer extends FragmentActivity implements OnSharedPreferenceCha
7472
private AimsicdService mAimsicdService;
7573
private boolean mBound;
7674

77-
private Map<Marker, MarkerData> mMarkerMap = new HashMap<>();
75+
private final Map<Marker, MarkerData> mMarkerMap = new HashMap<>();
7876

7977
/**
8078
* Called when the activity is first created.
@@ -438,14 +436,14 @@ private void loadEntries() {
438436
}
439437

440438
public class MarkerData {
441-
public String cellID;
442-
public String lat;
443-
public String lng;
444-
public String lac;
445-
public String mcc;
446-
public String mnc;
447-
public String samples;
448-
public boolean openCellID;
439+
public final String cellID;
440+
public final String lat;
441+
public final String lng;
442+
public final String lac;
443+
public final String mcc;
444+
public final String mnc;
445+
public final String samples;
446+
public final boolean openCellID;
449447

450448
MarkerData(String cell_id, String latitude, String longitude,
451449
String local_area_code, String mobile_country_code, String mobile_network_code,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ public class CardItemData
1010
private String mSignal;
1111
private String mAvgSigStr;
1212
private String mSamples;
13-
private String mLat;
14-
private String mLng;
13+
private final String mLat;
14+
private final String mLng;
1515
private String mCountry;
16-
private String mRecordId;
16+
private final String mRecordId;
1717

1818
public CardItemData(String cellID, String lac, String mcc, String mnc, String lat, String lng,
1919
String avgSigStr, String samples, String recordId)

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

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,43 +111,28 @@ public void setUserVisibleHint(boolean isVisibleToUser) {
111111
private void updateUI() {
112112
if (mBound) {
113113
mAimsicdService.updateNeighbouringCells();
114-
Map neighborMapUMTS = mAimsicdService.getUMTSNeighbouringCells();
115-
Map neighborMapGSM = mAimsicdService.getGSMNeighbouringCells();
114+
Map neighborMap = mAimsicdService.getNeighbouringCells();
116115

117116
mNeighbouringTotal
118-
.setText(String.valueOf(mAimsicdService.getNeighbouringCellSize()) + "/"
119-
+ String.valueOf(neighborMapUMTS.size() + neighborMapGSM.size()));
117+
.setText(String.valueOf(mAimsicdService.getNeighbouringCellSize()));
120118

121119
StringBuilder sb = new StringBuilder();
122120
int i = 1;
123-
if (!neighborMapUMTS.isEmpty())
124-
for (Object key : neighborMapUMTS.keySet()) {
125-
sb.append(i)
126-
.append(") PSC: ")
127-
.append(key)
128-
.append(" RSCP: ")
129-
.append(neighborMapUMTS.get(key)) //TS25.133 section 9.1.1.3
130-
.append(" dBm");
131-
if (i < neighborMapUMTS.size() + neighborMapGSM.size())
132-
sb.append("\n");
133-
i++;
134-
}
135-
if (!neighborMapGSM.isEmpty())
136-
for (Object key : neighborMapGSM.keySet()) {
121+
if (!neighborMap.isEmpty())
122+
for (Object key : neighborMap.keySet()) {
137123
sb.append(i)
138124
.append(") LAC-CID: ")
139125
.append(key)
140126
.append(" RSSI: ")
141-
.append(neighborMapGSM.get(key)) //TS27.007 section 8.5
142-
.append(" dBm");
143-
if (i < neighborMapUMTS.size() + neighborMapGSM.size())
127+
.append(neighborMap.get(key)); //TS27.007 section 8.5
128+
if (i < neighborMap.size())
144129
sb.append("\n");
145130
i++;
146131
}
147132
mNeighbouringCells.setText(sb);
148133

149134
//Try SamSung MultiRil Implementation
150-
if (neighborMapGSM.isEmpty() && neighborMapUMTS.isEmpty()) {
135+
if (neighborMap.isEmpty()) {
151136
DetectResult rilStatus = mAimsicdService.getRilExecutorStatus();
152137
if (rilStatus.available) {
153138
//new RequestOemInfoTask().execute();

app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@
6161
import android.app.NotificationManager;
6262
import android.app.PendingIntent;
6363
import android.app.Service;
64+
import android.content.BroadcastReceiver;
6465
import android.content.Context;
6566
import android.content.DialogInterface;
6667
import android.content.Intent;
68+
import android.content.IntentFilter;
6769
import android.content.SharedPreferences;
6870
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
6971
import android.location.Location;
@@ -119,7 +121,6 @@
119121
import java.util.List;
120122
import java.util.Map;
121123
import java.util.Queue;
122-
import java.util.Timer;
123124

124125
public class AimsicdService extends Service implements OnSharedPreferenceChangeListener {
125126

@@ -132,6 +133,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL
132133
*/
133134
private final AimscidBinder mBinder = new AimscidBinder();
134135
private final AIMSICDDbAdapter dbHelper = new AIMSICDDbAdapter(this);
136+
private Context mContext;
135137
private final int NOTIFICATION_ID = 1;
136138
private long mDbResult;
137139
private TelephonyManager tm;
@@ -142,7 +144,6 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL
142144
private static final long GPS_MIN_UPDATE_TIME = 1000;
143145
private static final float GPS_MIN_UPDATE_DISTANCE = 10;
144146
public boolean mMultiRilCompatible;
145-
private Timer timer = new Timer();
146147

147148
/*
148149
* Device Declarations
@@ -177,8 +178,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL
177178
private String mSimSubs = "";
178179
private String mDataActivityType = "";
179180
private String mDataActivityTypeShort = "";
180-
private final Map<Integer,Integer> mNeighborMapUMTS = new HashMap<>();
181-
private final Map<String,Integer> mNeighborMapGSM = new HashMap<>();
181+
private final Map<String, String> mNeighborMap = new HashMap<>();
182182

183183
/*
184184
* Tracking and Alert Declarations
@@ -237,6 +237,7 @@ public void onCreate() {
237237
//TelephonyManager provides system details
238238
tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
239239
lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
240+
mContext = getApplicationContext();
240241

241242
prefs = this.getSharedPreferences(
242243
AimsicdService.SHARED_PREFERENCES_BASENAME, 0);
@@ -265,6 +266,9 @@ public void onCreate() {
265266
}
266267
}
267268

269+
//Register receiver for Silent SMS Interception Notification
270+
mContext.registerReceiver(mMessageReceiver, new IntentFilter(SILENT_SMS));
271+
268272
Log.i(TAG, "Service launched successfully");
269273
}
270274

@@ -280,6 +284,7 @@ public void onDestroy() {
280284
prefs.unregisterOnSharedPreferenceChangeListener(this);
281285
cancelNotification();
282286
dbHelper.close();
287+
mContext.unregisterReceiver(mMessageReceiver);
283288

284289
//Samsung MultiRil Cleanup
285290
if (mRequestExecutor != null) {
@@ -289,9 +294,23 @@ public void onDestroy() {
289294
mHandler = null;
290295
mHandlerThread.quit();
291296
mHandlerThread = null;
297+
292298
Log.i(TAG, "Service destroyed");
293299
}
294300

301+
private final BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
302+
@Override
303+
public void onReceive(Context context, Intent intent) {
304+
final Bundle bundle = intent.getExtras();
305+
if (bundle != null) {
306+
dbHelper.open();
307+
dbHelper.insertSilentSms(bundle);
308+
dbHelper.close();
309+
setSilentSmsStatus(true);
310+
}
311+
}
312+
};
313+
295314
/**
296315
* Check the status of the Rill Executor
297316
*
@@ -411,7 +430,7 @@ private synchronized List<String> executeAtServiceModeCommand(int type, int subt
411430

412431
private static class KeyStep {
413432
public final char keychar;
414-
public boolean captureResponse;
433+
public final boolean captureResponse;
415434

416435
public KeyStep(char keychar, boolean captureResponse) {
417436
this.keychar = keychar;
@@ -1015,7 +1034,7 @@ public String getNetworkTypeName() {
10151034
return mNetType;
10161035
}
10171036

1018-
public void getDataActivity() {
1037+
void getDataActivity() {
10191038
int direction = tm.getDataActivity();
10201039
mDataActivityTypeShort = "un";
10211040
mDataActivityType = "undef";
@@ -1043,7 +1062,7 @@ public void getDataActivity() {
10431062
}
10441063
}
10451064

1046-
public void getDataState() {
1065+
void getDataState() {
10471066
int state = tm.getDataState();
10481067
mDataState = "undef";
10491068
mDataStateShort = "un";
@@ -1186,8 +1205,17 @@ public void updateCdmaLocation() {
11861205
mLastLocation.setLatitude(mLatitude);
11871206
}
11881207

1189-
public void setSilentSmsStatus(boolean state) {
1208+
void setSilentSmsStatus(boolean state) {
11901209
mClassZeroSmsDetected = state;
1210+
setNotification();
1211+
if (state) {
1212+
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
1213+
builder.setMessage(R.string.sms_message)
1214+
.setTitle(R.string.location_error_title);
1215+
AlertDialog alert = builder.create();
1216+
alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
1217+
alert.show();
1218+
}
11911219
}
11921220

11931221
/**
@@ -1275,11 +1303,11 @@ private void setNotification() {
12751303
break;
12761304
}
12771305

1278-
Context context = getApplicationContext();
1279-
Intent notificationIntent = new Intent(context, AIMSICD.class);
1306+
Intent notificationIntent = new Intent(mContext, AIMSICD.class);
1307+
notificationIntent.putExtra("silent_sms", mClassZeroSmsDetected);
12801308
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_FROM_BACKGROUND);
12811309
PendingIntent contentIntent = PendingIntent.getActivity(
1282-
context, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
1310+
mContext, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
12831311
Notification mBuilder =
12841312
new NotificationCompat.Builder(this)
12851313
.setSmallIcon(icon)
@@ -1313,24 +1341,25 @@ private void cancelNotification() {
13131341
*
13141342
*/
13151343
public void updateNeighbouringCells() {
1316-
//Update Neighbouring Cell Map
1317-
for (String key: mNeighborMapGSM.keySet())
1318-
mNeighborMapGSM.put(key,-113);
1319-
for (int key: mNeighborMapUMTS.keySet())
1320-
mNeighborMapUMTS.put(key,-115);
1321-
13221344
List<NeighboringCellInfo> neighboringCellInfo;
13231345
neighboringCellInfo = tm.getNeighboringCellInfo();
1324-
mNeighbouringCellSize = neighboringCellInfo.size();
1325-
for (NeighboringCellInfo i : neighboringCellInfo) {
1326-
int networktype = i.getNetworkType();
1327-
if ((networktype == TelephonyManager.NETWORK_TYPE_UMTS) ||
1328-
(networktype == TelephonyManager.NETWORK_TYPE_HSDPA) ||
1329-
(networktype == TelephonyManager.NETWORK_TYPE_HSUPA) ||
1330-
(networktype == TelephonyManager.NETWORK_TYPE_HSPA))
1331-
mNeighborMapUMTS.put(i.getPsc(), i.getRssi()-115);
1332-
else
1333-
mNeighborMapGSM.put(i.getLac()+"-"+i.getCid(), (-113+2*(i.getRssi())));
1346+
if (neighboringCellInfo != null) {
1347+
mNeighbouringCellSize = neighboringCellInfo.size();
1348+
for (int i = 0; i > neighboringCellInfo.size(); i++) {
1349+
if (neighboringCellInfo.get(i) != null) {
1350+
String dBm;
1351+
int rssi = neighboringCellInfo.get(i).getRssi();
1352+
1353+
if (rssi == NeighboringCellInfo.UNKNOWN_RSSI) {
1354+
dBm = "Unknown RSSI";
1355+
} else {
1356+
dBm = String.valueOf(-113 + 2 * rssi) + " dBm";
1357+
}
1358+
1359+
mNeighborMap.put(neighboringCellInfo.get(i).getLac() +
1360+
":" + neighboringCellInfo.get(i).getCid(), dBm);
1361+
}
1362+
}
13341363
}
13351364
}
13361365

@@ -1339,19 +1368,9 @@ public void updateNeighbouringCells() {
13391368
*
13401369
* @return Map of GSM Neighbouring Cell Information
13411370
*/
1342-
public Map getGSMNeighbouringCells() {
1343-
return mNeighborMapGSM;
1371+
public Map getNeighbouringCells() {
1372+
return mNeighborMap;
13441373
}
1345-
1346-
/**
1347-
* Neighbouring UMTS Cell Map
1348-
*
1349-
* @return Map of UMTS Neighbouring Cell Information
1350-
*/
1351-
public Map getUMTSNeighbouringCells() {
1352-
return mNeighborMapUMTS;
1353-
}
1354-
13551374
/**
13561375
* Neighbouring Cell Size
13571376
*
@@ -1665,7 +1684,7 @@ public void onStatusChanged(String provider, int status,
16651684
* @param location The new Location that you want to evaluate
16661685
* @param currentBestLocation The current Location fix, to which you want to compare the new one
16671686
*/
1668-
protected boolean isBetterLocation(Location location, Location currentBestLocation) {
1687+
boolean isBetterLocation(Location location, Location currentBestLocation) {
16691688
if (currentBestLocation == null) {
16701689
// A new location is always better than no location
16711690
return true;

0 commit comments

Comments
 (0)