|
@@ -9,7 +9,6 @@ import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
import android.content.SharedPreferences;
|
|
import android.content.SharedPreferences;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
-import android.os.Environment;
|
|
|
|
import android.preference.PreferenceManager;
|
|
import android.preference.PreferenceManager;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
@@ -25,8 +24,6 @@ import android.widget.Toast;
|
|
|
|
|
|
import com.google.android.gms.maps.model.LatLng;
|
|
import com.google.android.gms.maps.model.LatLng;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
import java.text.DateFormat;
|
|
import java.text.DateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -35,27 +32,27 @@ import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Locale;
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
-import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
|
|
|
|
import de.tudarmstadt.informatik.hostage.logging.AttackRecord;
|
|
import de.tudarmstadt.informatik.hostage.logging.AttackRecord;
|
|
import de.tudarmstadt.informatik.hostage.logging.LogExport;
|
|
import de.tudarmstadt.informatik.hostage.logging.LogExport;
|
|
import de.tudarmstadt.informatik.hostage.logging.MessageRecord;
|
|
import de.tudarmstadt.informatik.hostage.logging.MessageRecord;
|
|
import de.tudarmstadt.informatik.hostage.logging.NetworkRecord;
|
|
import de.tudarmstadt.informatik.hostage.logging.NetworkRecord;
|
|
import de.tudarmstadt.informatik.hostage.logging.Record;
|
|
import de.tudarmstadt.informatik.hostage.logging.Record;
|
|
-import de.tudarmstadt.informatik.hostage.logging.formatter.TraCINgFormatter;
|
|
|
|
import de.tudarmstadt.informatik.hostage.persistence.HostageDBOpenHelper;
|
|
import de.tudarmstadt.informatik.hostage.persistence.HostageDBOpenHelper;
|
|
import de.tudarmstadt.informatik.hostage.sync.bluetooth.BluetoothSyncActivity;
|
|
import de.tudarmstadt.informatik.hostage.sync.bluetooth.BluetoothSyncActivity;
|
|
import de.tudarmstadt.informatik.hostage.sync.nfc.NFCSync;
|
|
import de.tudarmstadt.informatik.hostage.sync.nfc.NFCSync;
|
|
import de.tudarmstadt.informatik.hostage.sync.tracing.TracingSyncActivity;
|
|
import de.tudarmstadt.informatik.hostage.sync.tracing.TracingSyncActivity;
|
|
-import de.tudarmstadt.informatik.hostage.ui.LogFilter;
|
|
|
|
-import de.tudarmstadt.informatik.hostage.ui.LogFilter.SortType;
|
|
|
|
import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
|
|
import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
|
|
import de.tudarmstadt.informatik.hostage.ui2.adapter.RecordListAdapter;
|
|
import de.tudarmstadt.informatik.hostage.ui2.adapter.RecordListAdapter;
|
|
import de.tudarmstadt.informatik.hostage.ui2.dialog.ChecklistDialog;
|
|
import de.tudarmstadt.informatik.hostage.ui2.dialog.ChecklistDialog;
|
|
import de.tudarmstadt.informatik.hostage.ui2.dialog.DateTimeDialogFragment;
|
|
import de.tudarmstadt.informatik.hostage.ui2.dialog.DateTimeDialogFragment;
|
|
import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
|
|
import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
|
|
|
|
+import de.tudarmstadt.informatik.hostage.ui2.model.LogFilter;
|
|
|
|
+import de.tudarmstadt.informatik.hostage.ui2.model.LogFilter.SortType;
|
|
import de.tudarmstadt.informatik.hostage.ui2.popup.AbstractPopup;
|
|
import de.tudarmstadt.informatik.hostage.ui2.popup.AbstractPopup;
|
|
import de.tudarmstadt.informatik.hostage.ui2.popup.AbstractPopupItem;
|
|
import de.tudarmstadt.informatik.hostage.ui2.popup.AbstractPopupItem;
|
|
import de.tudarmstadt.informatik.hostage.ui2.popup.SimplePopupItem;
|
|
import de.tudarmstadt.informatik.hostage.ui2.popup.SimplePopupItem;
|
|
@@ -64,8 +61,8 @@ import de.tudarmstadt.informatik.hostage.ui2.popup.SplitPopupItem;
|
|
|
|
|
|
public class RecordOverviewFragment extends UpNavigatibleFragment implements ChecklistDialog.ChecklistDialogListener, DateTimeDialogFragment.DateTimeDialogFragmentListener {
|
|
public class RecordOverviewFragment extends UpNavigatibleFragment implements ChecklistDialog.ChecklistDialogListener, DateTimeDialogFragment.DateTimeDialogFragmentListener {
|
|
|
|
|
|
- static final String FILTER_MENU_TITLE_BSSID = "BSSID";
|
|
|
|
- static final String FILTER_MENU_TITLE_ESSID = "ESSID";
|
|
|
|
|
|
+ static final String FILTER_MENU_TITLE_BSSID = MainActivity.getContext().getString(R.string.BSSID);
|
|
|
|
+ static final String FILTER_MENU_TITLE_ESSID = MainActivity.getContext().getString(R.string.ESSID);
|
|
static final String FILTER_MENU_TITLE_PROTOCOLS = MainActivity.getContext().getString(R.string.rec_protocol);
|
|
static final String FILTER_MENU_TITLE_PROTOCOLS = MainActivity.getContext().getString(R.string.rec_protocol);
|
|
static final String FILTER_MENU_TITLE_TIMESTAMP_BELOW = MainActivity.getContext().getString(
|
|
static final String FILTER_MENU_TITLE_TIMESTAMP_BELOW = MainActivity.getContext().getString(
|
|
R.string.rec_latest);
|
|
R.string.rec_latest);
|
|
@@ -78,6 +75,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
static final String FILTER_MENU_POPUP_TITLE = MainActivity.getContext().getString(
|
|
static final String FILTER_MENU_POPUP_TITLE = MainActivity.getContext().getString(
|
|
R.string.rec_filter_by);
|
|
R.string.rec_filter_by);
|
|
|
|
|
|
|
|
+ static final int DEFAULT_GROUPING_KEY_INDEX = 0;
|
|
|
|
+
|
|
private boolean wasBelowTimePicker;
|
|
private boolean wasBelowTimePicker;
|
|
|
|
|
|
private LogFilter filter;
|
|
private LogFilter filter;
|
|
@@ -130,7 +129,6 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
|
|
|
|
dbh = new HostageDBOpenHelper(this.getActivity().getBaseContext());
|
|
dbh = new HostageDBOpenHelper(this.getActivity().getBaseContext());
|
|
pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
|
pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
|
- //this.addRecordToDB(5, 2);
|
|
|
|
|
|
|
|
// Get the message from the intent
|
|
// Get the message from the intent
|
|
|
|
|
|
@@ -146,7 +144,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (this.groupingKey == null) this.groupingKey = this.groupingTitles().get(0);
|
|
|
|
|
|
+ if (this.groupingKey == null) this.groupingKey = this.groupingTitles().get(DEFAULT_GROUPING_KEY_INDEX);
|
|
|
|
|
|
this.setShowFilterButton(!this.filter.isNotEditable());
|
|
this.setShowFilterButton(!this.filter.isNotEditable());
|
|
|
|
|
|
@@ -215,8 +213,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
if (adapter != null){
|
|
if (adapter != null){
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
|
- if (adapter.getGroupCount() == 1){
|
|
|
|
- RecordOverviewFragment.this.expListView.expandGroup(0);
|
|
|
|
|
|
+ if (adapter.getGroupCount() >= 1){
|
|
|
|
+ RecordOverviewFragment.this.expListView.expandGroup(DEFAULT_GROUPING_KEY_INDEX);
|
|
} else {
|
|
} else {
|
|
RecordOverviewFragment.this.setSectionToOpen(RecordOverviewFragment.this.sectionToOpen);
|
|
RecordOverviewFragment.this.setSectionToOpen(RecordOverviewFragment.this.sectionToOpen);
|
|
}
|
|
}
|
|
@@ -253,7 +251,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
@Override
|
|
@Override
|
|
public void run()
|
|
public void run()
|
|
{
|
|
{
|
|
- //RecordOverviewFragment.this.addRecordToDB(5, 10);
|
|
|
|
|
|
+ //RecordOverviewFragment.this.addRecordToDB(5, 10, 6);
|
|
updateUI(doInBackground());
|
|
updateUI(doInBackground());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -412,7 +410,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
int ESSID_INDEX = 2;
|
|
int ESSID_INDEX = 2;
|
|
ArrayList<String> ssids = new ArrayList<String>();
|
|
ArrayList<String> ssids = new ArrayList<String>();
|
|
this.sectionToOpen = SSID;
|
|
this.sectionToOpen = SSID;
|
|
- this.groupingKey = this.groupingTitles(context).get(ESSID_INDEX);
|
|
|
|
|
|
+ this.groupingKey = this.groupingTitles().get(ESSID_INDEX);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -427,10 +425,26 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
* @param mylist {@link ExpandableListView ExpandableListView}
|
|
* @param mylist {@link ExpandableListView ExpandableListView}
|
|
* */
|
|
* */
|
|
private RecordListAdapter populateListViewFromDB(ExpandableListView mylist) {
|
|
private RecordListAdapter populateListViewFromDB(ExpandableListView mylist) {
|
|
|
|
+ ArrayList<String> groupTitle = new ArrayList<String>();
|
|
|
|
+
|
|
|
|
+ HashMap<String, ArrayList<ExpandableListItem>> sectionData = this.fetchDataForFilter(this.filter, groupTitle);
|
|
|
|
+
|
|
|
|
+ RecordListAdapter adapter = null;
|
|
|
|
+ if (mylist.getAdapter() != null && mylist.getAdapter() instanceof RecordListAdapter){
|
|
|
|
+ adapter = (RecordListAdapter) mylist.getAdapter();
|
|
|
|
+ adapter.setData(sectionData);
|
|
|
|
+ adapter.setSectionHeader(groupTitle);
|
|
|
|
+ } else {
|
|
|
|
+ adapter = new RecordListAdapter( RecordOverviewFragment.this.getApplicationContext(), groupTitle, sectionData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return adapter;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private HashMap<String, ArrayList<ExpandableListItem>> fetchDataForFilter(LogFilter filter, ArrayList<String> groupTitle){
|
|
HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
|
|
HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
|
|
|
|
|
|
- ArrayList<Record> data = dbh.getRecordsForFilter(RecordOverviewFragment.this.filter);
|
|
|
|
|
|
+ ArrayList<Record> data = dbh.getRecordsForFilter(filter == null ? this.filter : filter);
|
|
|
|
|
|
// Adding Items to ListView
|
|
// Adding Items to ListView
|
|
String keys[] = new String[] { RecordOverviewFragment.this.getString(R.string.RecordBSSID), RecordOverviewFragment.this.getString(R.string.RecordSSID), RecordOverviewFragment.this.getString(R.string.RecordProtocol), RecordOverviewFragment.this.getString(R.string.RecordTimestamp)};
|
|
String keys[] = new String[] { RecordOverviewFragment.this.getString(R.string.RecordBSSID), RecordOverviewFragment.this.getString(R.string.RecordSSID), RecordOverviewFragment.this.getString(R.string.RecordProtocol), RecordOverviewFragment.this.getString(R.string.RecordTimestamp)};
|
|
@@ -443,7 +457,12 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
|
|
|
|
- ArrayList<String>groupTitle = new ArrayList<String>();
|
|
|
|
|
|
+ if (groupTitle == null){
|
|
|
|
+ groupTitle = new ArrayList<String>();
|
|
|
|
+ } else {
|
|
|
|
+ groupTitle.clear();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
for (Record val : data) {
|
|
for (Record val : data) {
|
|
// DO GROUPING IN HERE
|
|
// DO GROUPING IN HERE
|
|
@@ -474,25 +493,41 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
items.add(item);
|
|
items.add(item);
|
|
}
|
|
}
|
|
|
|
|
|
- Collections.sort(groupTitle, new Comparator<String>() {
|
|
|
|
- @Override
|
|
|
|
- public int compare(String s1, String s2) {
|
|
|
|
- return s1.compareToIgnoreCase(s2);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- RecordListAdapter adapter = null;
|
|
|
|
- if (mylist.getAdapter() != null && mylist.getAdapter() instanceof RecordListAdapter){
|
|
|
|
- adapter = (RecordListAdapter) mylist.getAdapter();
|
|
|
|
- adapter.setData(sectionData);
|
|
|
|
- adapter.setSectionHeader(groupTitle);
|
|
|
|
|
|
+ if (this.groupingKey.equals(this.groupingTitles().get(DEFAULT_GROUPING_KEY_INDEX))){
|
|
|
|
+ Collections.sort(groupTitle,new StringDateComparator());
|
|
} else {
|
|
} else {
|
|
- adapter = new RecordListAdapter( RecordOverviewFragment.this.getApplicationContext(), groupTitle, sectionData);
|
|
|
|
|
|
+ Collections.sort(groupTitle, new Comparator<String>() {
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(String s1, String s2) {
|
|
|
|
+ return s1.compareToIgnoreCase(s2);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
- return adapter;
|
|
|
|
- }
|
|
|
|
|
|
+ return sectionData;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ class StringDateComparator implements Comparator<String>
|
|
|
|
+ {
|
|
|
|
+ DateFormat formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
|
|
|
|
+ //String pattern = ((SimpleDateFormat)formatter).toPattern();
|
|
|
|
+ String localPattern = ((SimpleDateFormat)formatter).toLocalizedPattern();
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat(localPattern);
|
|
|
|
+
|
|
|
|
+ public int compare(String lhs, String rhs)
|
|
|
|
+ {
|
|
|
|
+ Date date1;
|
|
|
|
+ Date date2;
|
|
|
|
+ try {
|
|
|
|
+ date1 = dateFormat.parse(lhs);
|
|
|
|
+ date2 = dateFormat.parse(rhs);
|
|
|
|
+ } catch (java.text.ParseException e ) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return date2.compareTo(date1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Actualises the list in a background thread
|
|
* Actualises the list in a background thread
|
|
@@ -645,6 +680,41 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns the timestamp in a localised format.
|
|
|
|
+ * if the date is today, it returns today,
|
|
|
|
+ * if the date was yesterday it returns yesterday, otherwise the format is localised.
|
|
|
|
+ * @param timestamp long
|
|
|
|
+ * @return formatted date String
|
|
|
|
+ */
|
|
|
|
+ public String getFormattedDate(long timestamp) {
|
|
|
|
+ Calendar smsTime = Calendar.getInstance();
|
|
|
|
+ smsTime.setTimeInMillis(timestamp);
|
|
|
|
+
|
|
|
|
+ Calendar now = Calendar.getInstance();
|
|
|
|
+
|
|
|
|
+ if(now.get(Calendar.DATE) == smsTime.get(Calendar.DATE) ){
|
|
|
|
+ return this.getDateAsDayString(timestamp) + " - " + this.getResources().getString( R.string.TODAY);
|
|
|
|
+ }else if(now.get(Calendar.DATE) - smsTime.get(Calendar.DATE) == 1 ){
|
|
|
|
+ return this.getDateAsDayString(timestamp) + " - " + this.getResources().getString( R.string.YESTERDAY);
|
|
|
|
+ }
|
|
|
|
+ return this.getDateAsDayString(timestamp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**Returns a date as a formated string
|
|
|
|
+ * @param timeStamp date
|
|
|
|
+ * @return String date format is localised*/
|
|
|
|
+ @SuppressLint("SimpleDateFormat")
|
|
|
|
+ private String getDateAsDayString(long timeStamp) {
|
|
|
|
+ try {
|
|
|
|
+ Date netDate = (new Date(timeStamp));
|
|
|
|
+ DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(this.getActivity());
|
|
|
|
+ return dateFormat.format(netDate);
|
|
|
|
+ //return dateFormat.format(netDate);
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ return "xx";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/*****************************
|
|
/*****************************
|
|
*
|
|
*
|
|
@@ -727,31 +797,38 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
public String getGroupValue(Record rec){
|
|
public String getGroupValue(Record rec){
|
|
int index = this.groupingTitles().indexOf(this.groupingKey);
|
|
int index = this.groupingTitles().indexOf(this.groupingKey);
|
|
switch (index){
|
|
switch (index){
|
|
- case 0:
|
|
|
|
- return rec.getProtocol();
|
|
|
|
case 1:
|
|
case 1:
|
|
- return rec.getBssid();
|
|
|
|
|
|
+ return rec.getProtocol();
|
|
case 2:
|
|
case 2:
|
|
return rec.getSsid();
|
|
return rec.getSsid();
|
|
|
|
+ case 3:
|
|
|
|
+ return rec.getBssid();
|
|
|
|
+ case 0:
|
|
|
|
+ return this.getFormattedDate(rec.getTimestamp());
|
|
default:
|
|
default:
|
|
- return rec.getProtocol();
|
|
|
|
|
|
+ return this.getFormattedDate(rec.getTimestamp());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**Returns the Group titles for the specified grouping key. e.g. groupingKey is "ESSID" it returns all available essids.
|
|
/**Returns the Group titles for the specified grouping key. e.g. groupingKey is "ESSID" it returns all available essids.
|
|
* @return ArrayList<String> grouptitles*/
|
|
* @return ArrayList<String> grouptitles*/
|
|
- public ArrayList<String> getGroupTitles(){
|
|
|
|
|
|
+ public List<String> getGroupTitles(){
|
|
int index = this.groupingTitles().indexOf(this.groupingKey);
|
|
int index = this.groupingTitles().indexOf(this.groupingKey);
|
|
switch (index){
|
|
switch (index){
|
|
- case 0:
|
|
|
|
- return this.protocolTitles();
|
|
|
|
case 1:
|
|
case 1:
|
|
- return this.bssids();
|
|
|
|
|
|
+ return this.protocolTitles();
|
|
case 2:
|
|
case 2:
|
|
return this.essids();
|
|
return this.essids();
|
|
|
|
+ case 3:
|
|
|
|
+ return this.bssids();
|
|
|
|
+ case 0:
|
|
default:
|
|
default:
|
|
- return this.protocolTitles();
|
|
|
|
- }
|
|
|
|
|
|
+ RecordListAdapter adapter = (RecordListAdapter) this.expListView.getExpandableListAdapter();
|
|
|
|
+ if (adapter != null){
|
|
|
|
+ return adapter.getSectionHeaders();
|
|
|
|
+ }
|
|
|
|
+ return new ArrayList<String>();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -834,25 +911,14 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
this.filter.clear();
|
|
this.filter.clear();
|
|
}
|
|
}
|
|
|
|
|
|
- /**Returns all grouping titles
|
|
|
|
- * @param context Context
|
|
|
|
- * @return ArrayList<String> titles*/
|
|
|
|
- public ArrayList<String> groupingTitles(Context context){
|
|
|
|
- ArrayList<String> titles = new ArrayList<String>();
|
|
|
|
- for (String groupTitle : context.getResources().getStringArray(
|
|
|
|
- R.array.Grouping)) {
|
|
|
|
- titles.add(groupTitle);
|
|
|
|
- }
|
|
|
|
- return titles;
|
|
|
|
- }
|
|
|
|
/**Returns all grouping titles.
|
|
/**Returns all grouping titles.
|
|
* @return ArrayList<String> tiles*/
|
|
* @return ArrayList<String> tiles*/
|
|
public ArrayList<String> groupingTitles(){
|
|
public ArrayList<String> groupingTitles(){
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
- for (String groupTitle : this.getResources().getStringArray(
|
|
|
|
- R.array.Grouping)) {
|
|
|
|
- titles.add(groupTitle);
|
|
|
|
- }
|
|
|
|
|
|
+ titles.add(MainActivity.getContext().getString(R.string.date));
|
|
|
|
+ titles.add(MainActivity.getContext().getString(R.string.rec_protocol));
|
|
|
|
+ titles.add(MainActivity.getContext().getString(R.string.ESSID));
|
|
|
|
+ titles.add(MainActivity.getContext().getString(R.string.BSSID));
|
|
return titles;
|
|
return titles;
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
@@ -905,8 +971,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
titles.add(MainActivity.getContext().getString(R.string.rec_time));
|
|
titles.add(MainActivity.getContext().getString(R.string.rec_time));
|
|
titles.add(MainActivity.getContext().getString(R.string.rec_protocol));
|
|
titles.add(MainActivity.getContext().getString(R.string.rec_protocol));
|
|
- titles.add(MainActivity.getContext().getString(R.string.BSSID));
|
|
|
|
- titles.add(MainActivity.getContext().getString(R.string.ESSID));
|
|
|
|
|
|
+ titles.add(MainActivity.getContext().getString(R.string.ESSID));
|
|
|
|
+ titles.add(MainActivity.getContext().getString(R.string.BSSID));
|
|
return titles;
|
|
return titles;
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
@@ -1020,6 +1086,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
} else {
|
|
} else {
|
|
this.filter.setAboveTimestamp(Long.MIN_VALUE);
|
|
this.filter.setAboveTimestamp(Long.MIN_VALUE);
|
|
}
|
|
}
|
|
|
|
+ this.actualiseListViewInBackground();
|
|
this.actualiseFilterButton();
|
|
this.actualiseFilterButton();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1056,13 +1123,15 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
if(title.equals(FILTER_MENU_TITLE_SORTING)){
|
|
if(title.equals(FILTER_MENU_TITLE_SORTING)){
|
|
ArrayList<String> titles = dialog.getSelectedItemTitles();
|
|
ArrayList<String> titles = dialog.getSelectedItemTitles();
|
|
if (titles.size() == 0) return;
|
|
if (titles.size() == 0) return;
|
|
- String t = titles.get(0);
|
|
|
|
|
|
+ // ALWAYS GET THE FIRST ELEMENT (SHOULD BE ALWAYS ONE)
|
|
|
|
+ String t = titles.get(0);
|
|
int sortType = this.sortTypeTiles().indexOf(t);
|
|
int sortType = this.sortTypeTiles().indexOf(t);
|
|
this.filter.setSorttype(SortType.values()[sortType]);
|
|
this.filter.setSorttype(SortType.values()[sortType]);
|
|
}
|
|
}
|
|
if (title.equals(FILTER_MENU_TITLE_GROUP)){
|
|
if (title.equals(FILTER_MENU_TITLE_GROUP)){
|
|
ArrayList<String> titles = dialog.getSelectedItemTitles();
|
|
ArrayList<String> titles = dialog.getSelectedItemTitles();
|
|
if (titles.size() == 0) return;
|
|
if (titles.size() == 0) return;
|
|
|
|
+ // ALWAYS GET THE FIRST ELEMENT (SHOULD BE ALWAYS ONE)
|
|
this.groupingKey = titles.get(0);
|
|
this.groupingKey = titles.get(0);
|
|
}
|
|
}
|
|
this.actualiseListViewInBackground();
|
|
this.actualiseListViewInBackground();
|
|
@@ -1104,8 +1173,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
* This will clear the database at first and than add new attacks.
|
|
* This will clear the database at first and than add new attacks.
|
|
* @param createNetworks number of networks to create
|
|
* @param createNetworks number of networks to create
|
|
* @param attacksPerNetwork maximal number of attack per network
|
|
* @param attacksPerNetwork maximal number of attack per network
|
|
|
|
+ * @param maxMessagePerAttack maximal number of messages per attack
|
|
* */
|
|
* */
|
|
- private void addRecordToDB( int createNetworks, int attacksPerNetwork) {
|
|
|
|
|
|
+ private void addRecordToDB( int createNetworks, int attacksPerNetwork, int maxMessagePerAttack) {
|
|
if ((dbh.getRecordCount() > 0)) dbh.clearData();
|
|
if ((dbh.getRecordCount() > 0)) dbh.clearData();
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
Calendar cal = Calendar.getInstance();
|
|
@@ -1131,7 +1201,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
String protocolName = this.getResources().getStringArray(
|
|
String protocolName = this.getResources().getStringArray(
|
|
R.array.protocols)[protocolIndex];
|
|
R.array.protocols)[protocolIndex];
|
|
|
|
|
|
- int numOfAttackPerNetwork = (Math.abs(random.nextInt()) % attacksPerNetwork) + 1;
|
|
|
|
|
|
+ int numOfAttackPerNetwork = (Math.abs(random.nextInt()) % Math.max(1, attacksPerNetwork + 1));
|
|
|
|
|
|
NetworkRecord network = new NetworkRecord();
|
|
NetworkRecord network = new NetworkRecord();
|
|
network.setBssid(bssidName);
|
|
network.setBssid(bssidName);
|
|
@@ -1152,10 +1222,11 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
// ATTACKS PER NETWORK
|
|
// ATTACKS PER NETWORK
|
|
for (int attackNumber = 0; attackNumber < numOfAttackPerNetwork; attackNumber++) {
|
|
for (int attackNumber = 0; attackNumber < numOfAttackPerNetwork; attackNumber++) {
|
|
|
|
|
|
- int numRecordsPerAttack = (Math.abs(random.nextInt()) % 5) + 1;
|
|
|
|
- /*
|
|
|
|
- * ADD A ATTACK*/
|
|
|
|
|
|
+ int numRecordsPerAttack = (Math.abs(random.nextInt()) % (Math.max( maxMessagePerAttack, 1))) + 1;
|
|
|
|
+
|
|
|
|
+ if (maxMessagePerAttack <= 0) numRecordsPerAttack = 0;
|
|
|
|
|
|
|
|
+ /* ADD A ATTACK*/
|
|
AttackRecord attack = new AttackRecord();
|
|
AttackRecord attack = new AttackRecord();
|
|
attack.setAttack_id(attackId);
|
|
attack.setAttack_id(attackId);
|
|
|
|
|
|
@@ -1167,7 +1238,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
|
|
|
|
|
|
dbh.addAttackRecord(attack);
|
|
dbh.addAttackRecord(attack);
|
|
|
|
|
|
- // RECORDS PER ATTACK
|
|
|
|
|
|
+ // MESSAGE PER ATTACK
|
|
for (int messageID = attackId; messageID < attackId + numRecordsPerAttack; messageID++) {
|
|
for (int messageID = attackId; messageID < attackId + numRecordsPerAttack; messageID++) {
|
|
MessageRecord message = new MessageRecord();
|
|
MessageRecord message = new MessageRecord();
|
|
message.setId(messageID);
|
|
message.setId(messageID);
|