|
@@ -5,6 +5,9 @@ import java.net.UnknownHostException;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
|
|
@@ -65,24 +68,47 @@ public class ViewLogTable extends Activity{
|
|
|
registerListClickCallback();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public class RecordComparator implements Comparator<Record> {
|
|
|
+ public int compare(Record o1, Record o2) {
|
|
|
+ long time1 = o1.getTimestamp();
|
|
|
+ long time2 = o2.getTimestamp();
|
|
|
+ if(time1<time2) return -1;
|
|
|
+ if(time1 > time2)return 1;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void addRecordToDB(){
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+
|
|
|
+ int maxProtocolsIndex = this.getResources().getStringArray( R.array.protocols).length;
|
|
|
+
|
|
|
+ int numberofRecords = (int) (Math.random() * ( 50 - 10 ));
|
|
|
+ for(int i = 0; i < numberofRecords; i++){
|
|
|
Record record = new Record();
|
|
|
- record.setBSSID("BSSID wwwww");
|
|
|
- record.setSSID("SSID wowy");
|
|
|
- record.setTimestamp(0);
|
|
|
- record.setProtocol("HTTP");
|
|
|
+ record.setBSSID("BSSID: " + i);
|
|
|
+ record.setSSID("SSID: w" + i);
|
|
|
+ record.setTimestamp(cal.getTimeInMillis() + ((i*60*60*60*24) * 1000 ) );
|
|
|
+
|
|
|
+ int index = i % maxProtocolsIndex;
|
|
|
+ String protocolName = this.getResources().getStringArray(R.array.protocols)[index];
|
|
|
+
|
|
|
+ record.setProtocol(protocolName);
|
|
|
+ record.setId(i);
|
|
|
+ record.setAttack_id(i);
|
|
|
try {
|
|
|
InetAddress localIP = InetAddress.getByAddress("Digga",new byte[]{127, 0, 0, 1}); //.getByName("192.168.2.1");
|
|
|
record.setLocalIP(localIP);
|
|
|
record.setRemoteIP(InetAddress.getByAddress("Digga",new byte[]{127, 1, 1, 1}));
|
|
|
record.setType(TYPE.SEND);
|
|
|
} catch (UnknownHostException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
dbh.addRecord(record);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -92,7 +118,9 @@ public class ViewLogTable extends Activity{
|
|
|
|
|
|
ArrayList<HashMap<String, String>> Items = new ArrayList<HashMap<String, String>>();
|
|
|
|
|
|
- ArrayList<Record> data = dbh.getAllRecords();
|
|
|
+ ArrayList<Record> data = dbh.getAllRecords();
|
|
|
+ Collections.sort(data, new RecordComparator());
|
|
|
+
|
|
|
|
|
|
for (Record val : data) {
|
|
|
String protocol = val.getProtocol();
|