diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/activities/MapViewer.java b/app/src/main/java/com/SecUpwN/AIMSICD/activities/MapViewer.java index 2340160d9..dfbd62c63 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/activities/MapViewer.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/activities/MapViewer.java @@ -25,7 +25,6 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.database.Cursor; -import android.graphics.BitmapFactory; import android.location.Location; import android.os.Bundle; import android.os.IBinder; @@ -45,7 +44,6 @@ import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.UiSettings; -import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.CircleOptions; import com.google.android.gms.maps.model.LatLng; @@ -74,7 +72,7 @@ public class MapViewer extends FragmentActivity implements OnSharedPreferenceCha private AimsicdService mAimsicdService; private boolean mBound; - private Map mMarkerMap = new HashMap<>(); + private final Map mMarkerMap = new HashMap<>(); /** * Called when the activity is first created. @@ -438,14 +436,14 @@ private void loadEntries() { } public class MarkerData { - public String cellID; - public String lat; - public String lng; - public String lac; - public String mcc; - public String mnc; - public String samples; - public boolean openCellID; + public final String cellID; + public final String lat; + public final String lng; + public final String lac; + public final String mcc; + public final String mnc; + public final String samples; + public final boolean openCellID; MarkerData(String cell_id, String latitude, String longitude, String local_area_code, String mobile_country_code, String mobile_network_code, diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/adapters/CardItemData.java b/app/src/main/java/com/SecUpwN/AIMSICD/adapters/CardItemData.java index 0ae8198dc..1179ad48f 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/adapters/CardItemData.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/adapters/CardItemData.java @@ -10,10 +10,10 @@ public class CardItemData private String mSignal; private String mAvgSigStr; private String mSamples; - private String mLat; - private String mLng; + private final String mLat; + private final String mLng; private String mCountry; - private String mRecordId; + private final String mRecordId; public CardItemData(String cellID, String lac, String mcc, String mnc, String lat, String lng, String avgSigStr, String samples, String recordId) diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/fragments/CellInfoFragment.java b/app/src/main/java/com/SecUpwN/AIMSICD/fragments/CellInfoFragment.java index 44f9a768d..089aaefbe 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/fragments/CellInfoFragment.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/fragments/CellInfoFragment.java @@ -111,43 +111,28 @@ public void setUserVisibleHint(boolean isVisibleToUser) { private void updateUI() { if (mBound) { mAimsicdService.updateNeighbouringCells(); - Map neighborMapUMTS = mAimsicdService.getUMTSNeighbouringCells(); - Map neighborMapGSM = mAimsicdService.getGSMNeighbouringCells(); + Map neighborMap = mAimsicdService.getNeighbouringCells(); mNeighbouringTotal - .setText(String.valueOf(mAimsicdService.getNeighbouringCellSize()) + "/" - + String.valueOf(neighborMapUMTS.size() + neighborMapGSM.size())); + .setText(String.valueOf(mAimsicdService.getNeighbouringCellSize())); StringBuilder sb = new StringBuilder(); int i = 1; - if (!neighborMapUMTS.isEmpty()) - for (Object key : neighborMapUMTS.keySet()) { - sb.append(i) - .append(") PSC: ") - .append(key) - .append(" RSCP: ") - .append(neighborMapUMTS.get(key)) //TS25.133 section 9.1.1.3 - .append(" dBm"); - if (i < neighborMapUMTS.size() + neighborMapGSM.size()) - sb.append("\n"); - i++; - } - if (!neighborMapGSM.isEmpty()) - for (Object key : neighborMapGSM.keySet()) { + if (!neighborMap.isEmpty()) + for (Object key : neighborMap.keySet()) { sb.append(i) .append(") LAC-CID: ") .append(key) .append(" RSSI: ") - .append(neighborMapGSM.get(key)) //TS27.007 section 8.5 - .append(" dBm"); - if (i < neighborMapUMTS.size() + neighborMapGSM.size()) + .append(neighborMap.get(key)); //TS27.007 section 8.5 + if (i < neighborMap.size()) sb.append("\n"); i++; } mNeighbouringCells.setText(sb); //Try SamSung MultiRil Implementation - if (neighborMapGSM.isEmpty() && neighborMapUMTS.isEmpty()) { + if (neighborMap.isEmpty()) { DetectResult rilStatus = mAimsicdService.getRilExecutorStatus(); if (rilStatus.available) { //new RequestOemInfoTask().execute(); diff --git a/app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java b/app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java index 07c1620c5..d5a1f8e80 100644 --- a/app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java +++ b/app/src/main/java/com/SecUpwN/AIMSICD/service/AimsicdService.java @@ -61,9 +61,11 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; +import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.location.Location; @@ -119,7 +121,6 @@ import java.util.List; import java.util.Map; import java.util.Queue; -import java.util.Timer; public class AimsicdService extends Service implements OnSharedPreferenceChangeListener { @@ -132,6 +133,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL */ private final AimscidBinder mBinder = new AimscidBinder(); private final AIMSICDDbAdapter dbHelper = new AIMSICDDbAdapter(this); + private Context mContext; private final int NOTIFICATION_ID = 1; private long mDbResult; private TelephonyManager tm; @@ -142,7 +144,6 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL private static final long GPS_MIN_UPDATE_TIME = 1000; private static final float GPS_MIN_UPDATE_DISTANCE = 10; public boolean mMultiRilCompatible; - private Timer timer = new Timer(); /* * Device Declarations @@ -177,8 +178,7 @@ public class AimsicdService extends Service implements OnSharedPreferenceChangeL private String mSimSubs = ""; private String mDataActivityType = ""; private String mDataActivityTypeShort = ""; - private final Map mNeighborMapUMTS = new HashMap<>(); - private final Map mNeighborMapGSM = new HashMap<>(); + private final Map mNeighborMap = new HashMap<>(); /* * Tracking and Alert Declarations @@ -237,6 +237,7 @@ public void onCreate() { //TelephonyManager provides system details tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); lm = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); + mContext = getApplicationContext(); prefs = this.getSharedPreferences( AimsicdService.SHARED_PREFERENCES_BASENAME, 0); @@ -265,6 +266,9 @@ public void onCreate() { } } + //Register receiver for Silent SMS Interception Notification + mContext.registerReceiver(mMessageReceiver, new IntentFilter(SILENT_SMS)); + Log.i(TAG, "Service launched successfully"); } @@ -280,6 +284,7 @@ public void onDestroy() { prefs.unregisterOnSharedPreferenceChangeListener(this); cancelNotification(); dbHelper.close(); + mContext.unregisterReceiver(mMessageReceiver); //Samsung MultiRil Cleanup if (mRequestExecutor != null) { @@ -289,9 +294,23 @@ public void onDestroy() { mHandler = null; mHandlerThread.quit(); mHandlerThread = null; + Log.i(TAG, "Service destroyed"); } + private final BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + final Bundle bundle = intent.getExtras(); + if (bundle != null) { + dbHelper.open(); + dbHelper.insertSilentSms(bundle); + dbHelper.close(); + setSilentSmsStatus(true); + } + } + }; + /** * Check the status of the Rill Executor * @@ -411,7 +430,7 @@ private synchronized List executeAtServiceModeCommand(int type, int subt private static class KeyStep { public final char keychar; - public boolean captureResponse; + public final boolean captureResponse; public KeyStep(char keychar, boolean captureResponse) { this.keychar = keychar; @@ -1015,7 +1034,7 @@ public String getNetworkTypeName() { return mNetType; } - public void getDataActivity() { + void getDataActivity() { int direction = tm.getDataActivity(); mDataActivityTypeShort = "un"; mDataActivityType = "undef"; @@ -1043,7 +1062,7 @@ public void getDataActivity() { } } - public void getDataState() { + void getDataState() { int state = tm.getDataState(); mDataState = "undef"; mDataStateShort = "un"; @@ -1186,8 +1205,17 @@ public void updateCdmaLocation() { mLastLocation.setLatitude(mLatitude); } - public void setSilentSmsStatus(boolean state) { + void setSilentSmsStatus(boolean state) { mClassZeroSmsDetected = state; + setNotification(); + if (state) { + final AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(R.string.sms_message) + .setTitle(R.string.location_error_title); + AlertDialog alert = builder.create(); + alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + alert.show(); + } } /** @@ -1275,11 +1303,11 @@ private void setNotification() { break; } - Context context = getApplicationContext(); - Intent notificationIntent = new Intent(context, AIMSICD.class); + Intent notificationIntent = new Intent(mContext, AIMSICD.class); + notificationIntent.putExtra("silent_sms", mClassZeroSmsDetected); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_FROM_BACKGROUND); PendingIntent contentIntent = PendingIntent.getActivity( - context, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); + mContext, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Notification mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(icon) @@ -1313,24 +1341,25 @@ private void cancelNotification() { * */ public void updateNeighbouringCells() { - //Update Neighbouring Cell Map - for (String key: mNeighborMapGSM.keySet()) - mNeighborMapGSM.put(key,-113); - for (int key: mNeighborMapUMTS.keySet()) - mNeighborMapUMTS.put(key,-115); - List neighboringCellInfo; neighboringCellInfo = tm.getNeighboringCellInfo(); - mNeighbouringCellSize = neighboringCellInfo.size(); - for (NeighboringCellInfo i : neighboringCellInfo) { - int networktype = i.getNetworkType(); - if ((networktype == TelephonyManager.NETWORK_TYPE_UMTS) || - (networktype == TelephonyManager.NETWORK_TYPE_HSDPA) || - (networktype == TelephonyManager.NETWORK_TYPE_HSUPA) || - (networktype == TelephonyManager.NETWORK_TYPE_HSPA)) - mNeighborMapUMTS.put(i.getPsc(), i.getRssi()-115); - else - mNeighborMapGSM.put(i.getLac()+"-"+i.getCid(), (-113+2*(i.getRssi()))); + if (neighboringCellInfo != null) { + mNeighbouringCellSize = neighboringCellInfo.size(); + for (int i = 0; i > neighboringCellInfo.size(); i++) { + if (neighboringCellInfo.get(i) != null) { + String dBm; + int rssi = neighboringCellInfo.get(i).getRssi(); + + if (rssi == NeighboringCellInfo.UNKNOWN_RSSI) { + dBm = "Unknown RSSI"; + } else { + dBm = String.valueOf(-113 + 2 * rssi) + " dBm"; + } + + mNeighborMap.put(neighboringCellInfo.get(i).getLac() + + ":" + neighboringCellInfo.get(i).getCid(), dBm); + } + } } } @@ -1339,19 +1368,9 @@ public void updateNeighbouringCells() { * * @return Map of GSM Neighbouring Cell Information */ - public Map getGSMNeighbouringCells() { - return mNeighborMapGSM; + public Map getNeighbouringCells() { + return mNeighborMap; } - - /** - * Neighbouring UMTS Cell Map - * - * @return Map of UMTS Neighbouring Cell Information - */ - public Map getUMTSNeighbouringCells() { - return mNeighborMapUMTS; - } - /** * Neighbouring Cell Size * @@ -1665,7 +1684,7 @@ public void onStatusChanged(String provider, int status, * @param location The new Location that you want to evaluate * @param currentBestLocation The current Location fix, to which you want to compare the new one */ - protected boolean isBetterLocation(Location location, Location currentBestLocation) { + boolean isBetterLocation(Location location, Location currentBestLocation) { if (currentBestLocation == null) { // A new location is always better than no location return true;