Browse Source

added filter object which can be passed through different activities.
added new databasehandler function, which returns als records fitting in
the filter object parameter.

Julien 10 years ago
parent
commit
607775acc6

+ 2 - 1
AndroidManifest.xml

@@ -18,7 +18,8 @@
         android:allowBackup="true"
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
-        android:theme="@style/AppTheme" >
+        android:theme="@style/AppTheme"
+        android:debuggable="true" >
         <activity
             android:name="de.tudarmstadt.informatik.hostage.ui.MainActivity"
             android:configChanges="keyboardHidden|orientation|screenSize"

+ 76 - 3
src/de/tudarmstadt/informatik/hostage/logging/DatabaseHandler.java

@@ -4,15 +4,16 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 
-import de.tudarmstadt.informatik.hostage.R;
-import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
-import de.tudarmstadt.informatik.hostage.protocol.Protocol;
 import android.content.ContentValues;
 import android.content.Context;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
 import android.util.Log;
+import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
+import de.tudarmstadt.informatik.hostage.protocol.Protocol;
+import de.tudarmstadt.informatik.hostage.ui.LogFilter;
 /**
  * This class creates SQL tables and handles all access to the database.<br>
  * It contains several methods with predefined queries to extract different kinds of information from the database.<br>
@@ -289,6 +290,78 @@ public class DatabaseHandler extends SQLiteOpenHelper {
         return recordList;
     }
     
+    
+    /*
+    // Contacts Table Columns names
+	private static final String KEY_ID = "_id";
+	private static final String KEY_ATTACK_ID = "_attack_id";
+	private static final String KEY_TYPE = "type";
+	private static final String KEY_TIME = "timestamp";
+	private static final String KEY_PACKET = "packet";
+	private static final String KEY_PROTOCOL = "protocol";
+	private static final String KEY_EXTERNAL_IP ="externalIP";
+	private static final String KEY_LOCAL_IP = "localIP";
+	private static final String KEY_LOCAL_HOSTNAME = "localHostName";
+	private static final String KEY_LOCAL_PORT = "localPort";
+	private static final String KEY_REMOTE_IP = "remoteIP";
+	private static final String KEY_REMOTE_HOSTNAME = "remoteHostName";
+	private static final String KEY_REMOTE_PORT = "remotePort";
+	private static final String KEY_BSSID = "_bssid";
+	private static final String KEY_SSID = "ssid";
+	private static final String KEY_LATITUDE = "latitude";
+	private static final String KEY_LONGITUDE = "longitude";
+	private static final String KEY_ACCURACY = "accuracy";
+	*/
+    
+	/**
+	 * Gets all received {@link Record Records} for the specified information in the LogFilter ordered by date.
+	 * @return A ArrayList with all received {@link Record Records} for the LogFilter.
+	 */
+    public ArrayList<Record> getRecordsForFilter(LogFilter filter) {
+    	ArrayList<Record> recordList = new ArrayList<Record>();
+        String selectQuery = "SELECT  * FROM " + TABLE_RECORDS + " NATURAL JOIN " + TABLE_ATTACK_INFO + " NATURAL JOIN " + TABLE_BSSIDS + " NATURAL JOIN " + TABLE_PORTS;
+
+        // TIMESTAMPS
+        selectQuery = selectQuery + " WHERE " + KEY_TIME;
+        selectQuery = selectQuery + " < " + filter.getBelowTimestamp();
+        selectQuery = selectQuery + " AND " + KEY_TIME;
+        selectQuery = selectQuery + " > " + filter.getAboveTimestamp();
+        
+        if (filter.getBSSIDs() != null && filter.getBSSIDs().size() > 0) {
+            selectQuery = selectQuery + " AND ";
+            selectQuery = selectQuery + filter.getBSSIDQueryStatement(KEY_BSSID);
+		}
+        if (filter.getESSIDs() != null && filter.getESSIDs().size() > 0) {
+            selectQuery = selectQuery + " AND ";
+            selectQuery = selectQuery + filter.getESSIDQueryStatement(KEY_SSID);
+		}
+        if (filter.getProtocols() != null && filter.getProtocols().size() > 0) {
+            selectQuery = selectQuery + " AND ";
+            selectQuery = selectQuery + filter.getProtocolsQueryStatement(KEY_PROTOCOL);
+		}
+
+        
+        // ORDERED BY TIME
+        selectQuery = selectQuery + " ORDER BY " + filter.getSorttype();
+        System.out.println(selectQuery);
+        SQLiteDatabase db = this.getReadableDatabase();
+        Cursor cursor = db.rawQuery(selectQuery, null);
+		
+        // looping through all rows and adding to list
+		if (cursor.moveToFirst()) {
+			do {
+				Record record = createRecord(cursor);
+				// Adding record to list
+				recordList.add(record);
+			} while (cursor.moveToNext());
+		}       
+        cursor.close();
+ 
+        // return record list
+        db.close();
+        return recordList;
+    }
+    
 	/**
 	 * Gets a representative {@link Record} for every attack identified by its attack id.
 	 * @return A ArrayList with one {@link Record Records} for each attack id in the Database.

+ 198 - 0
src/de/tudarmstadt/informatik/hostage/ui/LogFilter.java

@@ -0,0 +1,198 @@
+package de.tudarmstadt.informatik.hostage.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import de.tudarmstadt.informatik.hostage.R;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+
+public class LogFilter implements Parcelable{
+	
+	public final static String LOG_FILTER_INTENT_KEY = "de.tudarmstadt.informatik.hostage.logfilter";
+	
+	private static final String TIMESTAMP_BELOW_KEY = "de.tudarmstadt.informatik.hostage.logfilter.timestampbelow";
+	private static final String TIMESTAMP_ABOVE_KEY = "de.tudarmstadt.informatik.hostage.logfilter.timestampabove";
+	private static final String PROTOCOLS_KEY = "de.tudarmstadt.informatik.hostage.logfilter.protocols";
+	private static final String ESSID_KEY = "de.tudarmstadt.informatik.hostage.logfilter.essid";
+	private static final String BSSID_KEY = "de.tudarmstadt.informatik.hostage.logfilter.bssid";
+	private static final String SORTTYPE_KEY = "de.tudarmstadt.informatik.hostage.logfilter.sorttype";
+
+	public enum SortType{
+				timestamp(0),
+				protocol(1),
+				_bssid(1),
+				ssid(3),
+				remoteHostName(5),
+				lcaolHostName(6),
+				_attack_id(7),
+				_id(8);
+		        private final int id;
+		        SortType(int id) {
+		        	this.id = id;
+		        }
+		        public int getValue() { 
+		        	return id; 
+		        }
+		    }
+	
+	public ArrayList<String> BSSIDs;
+	public ArrayList<String> ESSIDs;
+	public ArrayList<String> protocols;
+	
+	public boolean isNotEditable;
+	
+	public SortType sorttype;
+
+	public long belowTimestamp;
+	public long aboveTimestamp;
+	
+	
+	public LogFilter(){
+		this.belowTimestamp = Long.MAX_VALUE;
+		this.aboveTimestamp = Long.MIN_VALUE;
+		this.sorttype = SortType.timestamp;
+		this.BSSIDs = new ArrayList<String>();
+		this.ESSIDs = new ArrayList<String>();
+		this.protocols = new ArrayList<String>();
+
+	}
+	
+	
+	
+	    public int describeContents() {
+	        return 0;
+	    }
+
+	    // write your object's data to the passed-in Parcel
+	    public void writeToParcel(Parcel out, int flags) {
+	        HashMap<String, ArrayList<String>> values =new HashMap<String,  ArrayList<String>>();
+	        if(this.BSSIDs != null && this.BSSIDs.size() > 0){
+	        	values.put(BSSID_KEY , this.getBSSIDs() );
+	        }
+	        if(this.ESSIDs != null && this.ESSIDs.size() > 0){
+	        	values.put(ESSID_KEY , this.getESSIDs() );
+	        }
+	        if(this.protocols != null && this.protocols.size() > 0){
+	        	values.put(PROTOCOLS_KEY , this.getProtocols() );
+	        }
+	        long timeArray[] = new long[] {this.aboveTimestamp, this.belowTimestamp};
+
+	        out.writeMap(values);
+	        out.writeInt(this.sorttype.getValue());
+	        out.writeDouble(timeArray.length);
+	        out.writeLongArray(timeArray);
+	        out.writeString(this.isNotEditable? "true" : "false");
+	    }
+
+	    
+	    public static final Parcelable.Creator<LogFilter> CREATOR = new Parcelable.Creator<LogFilter>() {
+	        public LogFilter createFromParcel(Parcel in) {
+	            return new LogFilter(in);
+	        }
+
+	        public LogFilter[] newArray(int size) {
+	            return new LogFilter[size];
+	        }
+	    };
+
+	    // example constructor that takes a Parcel and gives you an object populated with it's values
+	    private LogFilter(Parcel in) {
+	        //mData = in.readInt();
+	    	HashMap<String, ArrayList<String>> values = new HashMap<String, ArrayList<String>>();
+	    	in.readMap(values, ArrayList.class.getClassLoader());
+	    	
+	    	this.BSSIDs = values.get(BSSID_KEY);
+	    	this.ESSIDs = values.get(ESSID_KEY);
+	    	this.protocols = values.get(protocols);
+	    	
+	    	if(this.BSSIDs == null) this.BSSIDs = new ArrayList<String>();
+	    	if(this.ESSIDs == null) this.ESSIDs = new ArrayList<String>();
+	    	if(this.protocols == null) this.protocols = new ArrayList<String>();
+	    	
+	    	this.sorttype = SortType.values()[Math.min(in.readInt(), SortType.values().length)];
+	    	
+	    	int size = (int)in.readDouble();
+	    	long timeArray[] = new long[size];
+	    	in.readLongArray(timeArray);
+	    	
+	    	this.belowTimestamp = timeArray[1];
+	    	this.aboveTimestamp = timeArray[0];
+	    	
+	    	String bool = in.readString();
+	    	if(bool.equals("true")) this.isNotEditable = true;
+	    }
+	    
+	public boolean isNotEditable(){
+		return this.isNotEditable;
+	}
+	public SortType getSorttype(){
+		return this.sorttype;
+	}
+	public ArrayList<String> getBSSIDs(){
+		return this.BSSIDs;
+	}
+	public ArrayList<String> getESSIDs(){
+		return this.ESSIDs;
+	}
+	public ArrayList<String> getProtocols(){
+		return this.protocols;
+	}
+	public void setIsNotEditable(boolean b){
+		this.isNotEditable = b;
+	}
+	
+	public long getBelowTimestamp(){
+		return this.belowTimestamp;
+	}
+	public long getAboveTimestamp(){
+		return this.aboveTimestamp;
+	}
+	public void setProtocols(ArrayList<String> protocols){
+		this.protocols = protocols;
+	}
+	public void setBSSIDs(ArrayList<String> bssids){
+		this.BSSIDs = bssids;
+	}
+	public void setESSIDs(ArrayList<String> essids){
+		this.ESSIDs = essids;
+	}
+	public void setAboveTimestamp(long timestamp){
+		this.aboveTimestamp = timestamp;
+	}
+	public void setBelowTimestamp(long timestamp){
+		this.belowTimestamp = timestamp;
+	}
+	public void setSorttype(SortType type){
+		this.sorttype = type;
+	}
+	
+	
+	public String getBSSIDQueryStatement(String key){
+		return this.convertArrayListToQueryString(this.BSSIDs, key);
+	}
+	public String getESSIDQueryStatement(String key){
+		return this.convertArrayListToQueryString(this.ESSIDs, key);
+	}
+	public String getProtocolsQueryStatement(String key){
+		return this.convertArrayListToQueryString(this.protocols, key);
+	}
+
+	
+	public String convertArrayListToQueryString(ArrayList<String> list, String key){
+		String statement = "";
+		if (list == null) return statement;
+		
+		int i = 0, max = list.size();
+		for (String element : list){
+			i++;
+			statement = statement + "key" + " LIKE " + "'%" + element + "%'";
+			if (i == max) continue;
+			statement = statement +" OR ";
+		}
+		return statement;
+	}
+	
+}

+ 13 - 6
src/de/tudarmstadt/informatik/hostage/ui/ViewLog.java

@@ -9,11 +9,6 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.Locale;
 
-import de.tudarmstadt.informatik.hostage.R;
-import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
-import de.tudarmstadt.informatik.hostage.logging.Logger;
-import de.tudarmstadt.informatik.hostage.logging.Record;
-import de.tudarmstadt.informatik.hostage.logging.SQLLogger;
 import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.app.AlertDialog;
@@ -38,11 +33,18 @@ import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.Filter;
 import android.widget.TableLayout;
 import android.widget.TableRow;
 import android.widget.TextView;
 import android.widget.TimePicker;
 import android.widget.Toast;
+import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
+import de.tudarmstadt.informatik.hostage.logging.Logger;
+import de.tudarmstadt.informatik.hostage.logging.Record;
+import de.tudarmstadt.informatik.hostage.logging.SQLLogger;
 /**
  * ViewLog shows Statistics about the recorded Attacks.
  * It also offers the user several options to perform actions with the database.
@@ -242,7 +244,12 @@ public class ViewLog extends Activity {
 	 * @see ViewLogTable
 	 */
 	public void showLog(View view) {
-		startActivity(new Intent(this, ViewLogTable.class));
+		LogFilter filter = new LogFilter();
+		
+		
+		Intent intent = new Intent(this, ViewLogTable.class);
+		intent.putExtra(LogFilter.LOG_FILTER_INTENT_KEY, filter);
+		startActivity(intent);
 	}
 
 	/**

+ 162 - 163
src/de/tudarmstadt/informatik/hostage/ui/ViewLogTable.java

@@ -14,6 +14,7 @@ import java.util.HashMap;
 import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.content.Context;
+import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.view.Menu;
@@ -30,108 +31,119 @@ import de.tudarmstadt.informatik.hostage.logging.Record;
 import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
 
 /**
- * Creates a simple log view. Shows the Information for every attack. The format ist defined in {@link Record#toString(int)}.
+ * Creates a simple log view. Shows the Information for every attack. The format
+ * ist defined in {@link Record#toString(int)}.
+ * 
  * @author Lars Pandikow
- *
+ * 
  */
+@SuppressLint("NewApi")
 public class ViewLogTable extends Activity{
 	DatabaseHandler dbh;
-	
+
 	private ArrayList<String> selectedProtocols;
 	
+	private LogFilter filter;
+	private boolean showFilterButton;
+	
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
 		
+	    // Get the message from the intent
+	    Intent intent = getIntent();
+	    LogFilter filter = intent.getParcelableExtra(LogFilter.LOG_FILTER_INTENT_KEY);
+
+	    if(filter == null){
+	    	this.filter = new LogFilter();
+	    } else {
+	    	this.filter = filter;
+	    }
+
+	    this.showFilterButton = !filter.isNotEditable();
+	    
+	    
 		this.selectedProtocols = new ArrayList<String>();
-		
-		for (String protocol : this.getResources().getStringArray( R.array.protocols)){
-	        this.selectedProtocols.add(protocol);
-		}
-		
+
+//		for (String protocol : this.getResources().getStringArray(
+//				R.array.protocols)) {
+//			this.selectedProtocols.add(protocol);
+//		}
+
 		dbh = new DatabaseHandler(getBaseContext());
 		setContentView(R.layout.activity_loglist);
-//		StringBuffer log = new StringBuffer();
-//		//Create a log entry for every attack in the Database
-//		for(Record record: dbh.getAllReceivedRecordsOfEachAttack()) {
-//			log.append(record.toString(0));
-//		}
-		
-//		ScrollView scroll = new ScrollView(this);
-//		TextView text = new TextView(getApplicationContext());
-//		text.setText(log);
-//		text.setTextAppearance(this, android.R.style.TextAppearance_Medium);
-//		scroll.addView(text);
+
 		this.addRecordToDB();
-		
+
 		populateListViewFromDB();
 		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;
-	    }
+		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(){
+	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: " + 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) {
-			e.printStackTrace();
-		}
-		
-		dbh.addRecord(record);
+
+		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: " + 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) {
+				e.printStackTrace();
+			}
+
+			dbh.addRecord(record);
 		}
 	}
 
-
 	private void populateListViewFromDB() {
 		
 		ListView mylist = (ListView) findViewById(R.id.loglistview);
 	    
 		ArrayList<HashMap<String, String>> Items = new ArrayList<HashMap<String, String>>();
 
-		ArrayList<Record> data = dbh.getAllRecords();    
+		ArrayList<Record> data = dbh.getRecordsForFilter(this.filter);    
 		Collections.sort(data, new RecordComparator());
 		
 
 	        for (Record val : data) {
-	        	String protocol = val.getProtocol();
-	    		if (this.selectedProtocols.contains(protocol)){
 		            HashMap<String, String> map = new HashMap<String, String>();
 		            map.put(this.getString(R.string.RecordBSSID), val.getBSSID() );
 		            map.put(this.getString(R.string.RecordSSID), val.getSSID());
 		            map.put(this.getString(R.string.RecordProtocol), val.getProtocol());
 		            map.put(this.getString(R.string.RecordTimestamp), this.getDateAsString(val.getTimestamp()));
 		            Items.add(map);  
-	    		}
 	        }
 	        
 	     // Adding Items to ListView
@@ -139,125 +151,112 @@ public class ViewLogTable extends Activity{
 	        int ids[] = new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp };
 	        
 	        ListAdapter adapter = new SimpleAdapter(this, Items, R.layout.loglist_row, keys, ids);
-
-	        mylist.setAdapter(adapter);
-
 	        
+	        mylist.setAdapter(adapter);
 	}
-	
-	
+
 	@SuppressLint("SimpleDateFormat")
-	private String getDateAsString(long timeStamp){
+	private String getDateAsString(long timeStamp) {
+
+		try {
+			DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+			Date netDate = (new Date(timeStamp));
+			return sdf.format(netDate);
+		} catch (Exception ex) {
+			return "xx";
+		}
+	}
 
-	    try{
-	        DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
-	        Date netDate = (new Date(timeStamp));
-	        return sdf.format(netDate);
-	    }
-	    catch(Exception ex){
-	        return "xx";
-	    }
-	} 
-	
-	
 	private void registerListClickCallback() {
 		ListView mylist = (ListView) findViewById(R.id.loglistview);
-		
+
 		mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-			public void onItemClick(AdapterView<?> parent, View viewClicked, int position,
-					long idInDB) {
+			public void onItemClick(AdapterView<?> parent, View viewClicked,
+					int position, long idInDB) {
 				DatabaseHandler dbh = new DatabaseHandler(getBaseContext());
 				Record rec = dbh.getRecord((int) idInDB);
 				String message = createInformationStringFromRecord(rec);
-				Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
+				Toast.makeText(getApplicationContext(), message,
+						Toast.LENGTH_LONG).show();
 			}
-			
-			private String createInformationStringFromRecord(Record rec){
-				String message = "id: " + rec.getId() + "\n" +
-								"attack_id: " + rec.getAttack_id() +"\n" +
-								"protocol: " + rec.getProtocol() +"\n" +
-								"type: " + rec.getType() + "\n" +
-								"externalIP: " + rec.getExternalIP() +"\n" +
-								"localIP: " + rec.getLocalIP() +"\n" +
-								"local port: " + rec.getLocalPort() +"\n" +
-								"remoteIP: " + rec.getRemoteIP() +"\n" +
-								"BSSID: " + rec.getBSSID() + "\n" +
-								"SSID: " + rec.getSSID() +"\n" +
-								"latitude: " + rec.getLatitude() +"\n" +
-								"longitude: " + rec.getLongitude() + "\n" +
-								"accuracy: " + rec.getAccuracy() +"\n" +
-								"packet: " + rec.getPacket() + "\n" +
-								getDateAsString(rec.getTimestamp()) +
-								"";
+
+			private String createInformationStringFromRecord(Record rec) {
+				String message = "id: " + rec.getId() + "\n" + "attack_id: "
+						+ rec.getAttack_id() + "\n" + "protocol: "
+						+ rec.getProtocol() + "\n" + "type: " + rec.getType()
+						+ "\n" + "externalIP: " + rec.getExternalIP() + "\n"
+						+ "localIP: " + rec.getLocalIP() + "\n"
+						+ "local port: " + rec.getLocalPort() + "\n"
+						+ "remoteIP: " + rec.getRemoteIP() + "\n" + "BSSID: "
+						+ rec.getBSSID() + "\n" + "SSID: " + rec.getSSID()
+						+ "\n" + "latitude: " + rec.getLatitude() + "\n"
+						+ "longitude: " + rec.getLongitude() + "\n"
+						+ "accuracy: " + rec.getAccuracy() + "\n" + "packet: "
+						+ rec.getPacket() + "\n"
+						+ getDateAsString(rec.getTimestamp()) + "";
 				return message;
 			}
-			
+
 			@SuppressLint("SimpleDateFormat")
-			private String getDateAsString(long timeStamp){
-
-			    try{
-			        DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
-			        Date netDate = (new Date(timeStamp));
-			        return sdf.format(netDate);
-			    }
-			    catch(Exception ex){
-			        return "xx";
-			    }
-			} 
-			
+			private String getDateAsString(long timeStamp) {
+
+				try {
+					DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
+					Date netDate = (new Date(timeStamp));
+					return sdf.format(netDate);
+				} catch (Exception ex) {
+					return "xx";
+				}
+			}
+
 		});
 	}
-	
-	
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu)
-    {
-        super.onCreateOptionsMenu(menu);
-        
-		for (String protocol : this.getResources().getStringArray( R.array.protocols)){
-	        MenuItem item = menu.add(protocol);
-	        item.setCheckable(true);
-	        boolean isChecked = this.selectedProtocols.contains(item.getTitle());
-	        item.setChecked(isChecked);
-		}
-    	
-//    	MenuInflater inflater = getMenuInflater();
-//        inflater.inflate(R.menu.listview_detail_menu, menu);
-        return true;
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item)
-    {
-        boolean isChecked = this.selectedProtocols.contains(item.getTitle());
-
-		if (isChecked){
-           this.selectedProtocols.remove(item.getTitle());
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		super.onCreateOptionsMenu(menu);
+		if(this.showFilterButton){
+			MenuItem item = menu.add("Filter");
+			
+
+			// MenuInflater inflater = getMenuInflater();
+			// inflater.inflate(R.menu.listview_detail_menu, menu);
+			return true;
 		} else {
-	       this.selectedProtocols.add(item.getTitle().toString());
+			return false;
 		}
-        item.setChecked(!isChecked);
-        
-        this.populateListViewFromDB();
-        
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		
+		this.openFilterMenu(item.getActionView());
+
+		this.populateListViewFromDB();
 		return super.onOptionsItemSelected(item);
-    }
-    
-    private void saveInSharedPreferences(String key, boolean value){
-    	//--SAVE Data
-    	SharedPreferences preferences =  this.getSharedPreferences();
-    	SharedPreferences.Editor editor = preferences.edit();
-    	editor.putBoolean(key, value);
-    	editor.commit();
-    }
-    
-    private boolean getBooleanInSharedPreferences(String key){
-    	SharedPreferences preferences =  this.getSharedPreferences();
-    	return preferences.getBoolean(key, true);
-    }
-    
-    private SharedPreferences getSharedPreferences(){
-    	return  this.getSharedPreferences("HostagePreferences", Context.MODE_PRIVATE);
-    }
+	}
+	
+
+	private void openFilterMenu(View anchorView){
+		
+	}
+
+	private void saveInSharedPreferences(String key, boolean value) {
+		// --SAVE Data
+		SharedPreferences preferences = this.getSharedPreferences();
+		SharedPreferences.Editor editor = preferences.edit();
+		editor.putBoolean(key, value);
+		editor.commit();
+	}
+
+	private boolean getBooleanInSharedPreferences(String key) {
+		SharedPreferences preferences = this.getSharedPreferences();
+		return preferences.getBoolean(key, true);
+	}
+
+	private SharedPreferences getSharedPreferences() {
+		return this.getSharedPreferences("HostagePreferences",
+				Context.MODE_PRIVATE);
+	}
 
 }