|
@@ -11,9 +11,13 @@ import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
|
|
|
|
|
|
+import com.echo.holographlibrary.Bar;
|
|
import com.echo.holographlibrary.BarGraph;
|
|
import com.echo.holographlibrary.BarGraph;
|
|
|
|
+import com.echo.holographlibrary.Line;
|
|
import com.echo.holographlibrary.LineGraph;
|
|
import com.echo.holographlibrary.LineGraph;
|
|
|
|
+import com.echo.holographlibrary.LinePoint;
|
|
import com.echo.holographlibrary.PieGraph;
|
|
import com.echo.holographlibrary.PieGraph;
|
|
|
|
+import com.echo.holographlibrary.PieSlice;
|
|
|
|
|
|
import java.text.DateFormat;
|
|
import java.text.DateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -65,8 +69,7 @@ public class StatisticsFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
private ArrayList<Integer> colorList;
|
|
private ArrayList<Integer> colorList;
|
|
-
|
|
|
|
- private ArrayList<Record> fetchedRecords;
|
|
|
|
|
|
+ private ArrayList<PlotComparisonItem> currentData;
|
|
|
|
|
|
private UglyDbHelper dbh;
|
|
private UglyDbHelper dbh;
|
|
|
|
|
|
@@ -143,9 +146,21 @@ public class StatisticsFragment extends Fragment {
|
|
|
|
|
|
public void configureRootView(View rootView){
|
|
public void configureRootView(View rootView){
|
|
LinearLayout plotLayout = (LinearLayout) rootView.findViewById(R.id.plot_layout);
|
|
LinearLayout plotLayout = (LinearLayout) rootView.findViewById(R.id.plot_layout);
|
|
|
|
+ // DEFAULT
|
|
|
|
+ this.actualiseCurrentPlot();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * PLOT TOUCH HANDLING
|
|
|
|
+ *
|
|
|
|
+ * */
|
|
|
|
+ public void onSliceClick(int index){
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ public void onBarClick(int index){
|
|
|
|
|
|
|
|
+ }
|
|
/*
|
|
/*
|
|
*
|
|
*
|
|
* PLOT TYPES
|
|
* PLOT TYPES
|
|
@@ -154,6 +169,13 @@ public class StatisticsFragment extends Fragment {
|
|
public PieGraph getPieGraphView(){
|
|
public PieGraph getPieGraphView(){
|
|
if (this.pieGraph == null) {
|
|
if (this.pieGraph == null) {
|
|
this.pieGraph = new PieGraph(this.getApplicationContext());
|
|
this.pieGraph = new PieGraph(this.getApplicationContext());
|
|
|
|
+ this.pieGraph.setOnSliceClickedListener(new PieGraph.OnSliceClickedListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(int index) {
|
|
|
|
+ StatisticsFragment.this.onSliceClick(index);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ });
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
* ACTUALISE INPUT DATA
|
|
* ACTUALISE INPUT DATA
|
|
@@ -174,6 +196,12 @@ public class StatisticsFragment extends Fragment {
|
|
if (this.barGraph == null) {
|
|
if (this.barGraph == null) {
|
|
this.barGraph = new BarGraph(this.getApplicationContext());
|
|
this.barGraph = new BarGraph(this.getApplicationContext());
|
|
this.barGraph.setPopupImageID(R.drawable.popup_black);
|
|
this.barGraph.setPopupImageID(R.drawable.popup_black);
|
|
|
|
+ this.barGraph.setOnBarClickedListener(new BarGraph.OnBarClickedListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(int i) {
|
|
|
|
+ StatisticsFragment.this.onBarClick(i);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
this.setBarGraphData(this.barGraph);
|
|
this.setBarGraphData(this.barGraph);
|
|
return this.barGraph;
|
|
return this.barGraph;
|
|
@@ -183,15 +211,57 @@ public class StatisticsFragment extends Fragment {
|
|
* FEED PLOTS WITH DATA
|
|
* FEED PLOTS WITH DATA
|
|
* */
|
|
* */
|
|
public void setPieGraphData(PieGraph piegraph){
|
|
public void setPieGraphData(PieGraph piegraph){
|
|
-
|
|
|
|
|
|
+ this.currentData = this.getPieData();
|
|
|
|
+ int index = 0;
|
|
|
|
+
|
|
|
|
+ this.pieGraph.removeSlices();
|
|
|
|
+
|
|
|
|
+ for (PlotComparisonItem item : this.currentData){
|
|
|
|
+ PieSlice slice = new PieSlice();
|
|
|
|
+ slice.setColor(this.getColor(index));
|
|
|
|
+ slice.setValue((Float) item.getValue2());
|
|
|
|
+ slice.setTitle(item.getTitle());
|
|
|
|
+ this.pieGraph.addSlice(slice);
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ this.pieGraph.invalidate();
|
|
}
|
|
}
|
|
|
|
|
|
public void setLineGraphData(LineGraph linegraph){
|
|
public void setLineGraphData(LineGraph linegraph){
|
|
|
|
+ this.currentData = this.getLinedata();
|
|
|
|
+ int index = 0;
|
|
|
|
|
|
|
|
+ this.lineGraph.removeAllLines();
|
|
|
|
+ Line l = new Line();
|
|
|
|
+
|
|
|
|
+ for (PlotComparisonItem item : this.currentData){
|
|
|
|
+ LinePoint p = new LinePoint();
|
|
|
|
+ p.setX(index);
|
|
|
|
+ p.setY((Float) item.getValue2());
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ this.lineGraph.addLine(l);
|
|
|
|
+ this.lineGraph.setRangeY(0, index);
|
|
|
|
+ this.lineGraph.setLineToFill(0);
|
|
|
|
+ this.lineGraph.invalidate();
|
|
}
|
|
}
|
|
|
|
|
|
public void setBarGraphData(BarGraph bargraph){
|
|
public void setBarGraphData(BarGraph bargraph){
|
|
|
|
+ this.currentData = this.getLinedata();
|
|
|
|
+ int index = 0;
|
|
|
|
|
|
|
|
+ ArrayList<Bar> bars = new ArrayList<Bar>();
|
|
|
|
+
|
|
|
|
+ for (PlotComparisonItem item : this.currentData){
|
|
|
|
+ Bar d = new Bar();
|
|
|
|
+ d.setColor(this.getColor(index));
|
|
|
|
+ d.setName(item.getTitle());
|
|
|
|
+ d.setValue((Float)item.getValue2());
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.barGraph.setBars(bars);
|
|
|
|
+ this.barGraph.invalidate();
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -206,9 +276,16 @@ public class StatisticsFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
public void actualiseCurrentPlot(){
|
|
public void actualiseCurrentPlot(){
|
|
- this.actualiseRecords();
|
|
|
|
- this.actualisePlotData();
|
|
|
|
View plot = this.currentPlotView;
|
|
View plot = this.currentPlotView;
|
|
|
|
+ if (plot == null){
|
|
|
|
+ if (this.pieGraph == null){
|
|
|
|
+ this.currentPlotView = this.getPieGraphView();
|
|
|
|
+ // AVOID RELOADING THE DATA ON INITIAL LOAD
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.currentPlotView = this.getPieGraphView();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
if (plot instanceof PieGraph){
|
|
if (plot instanceof PieGraph){
|
|
this.setPieGraphData((PieGraph)plot);
|
|
this.setPieGraphData((PieGraph)plot);
|
|
}
|
|
}
|
|
@@ -218,16 +295,27 @@ public class StatisticsFragment extends Fragment {
|
|
if (plot instanceof LineGraph){
|
|
if (plot instanceof LineGraph){
|
|
this.setLineGraphData((LineGraph) plot);
|
|
this.setLineGraphData((LineGraph) plot);
|
|
}
|
|
}
|
|
- plot.invalidate();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public void actualiseRecords(){
|
|
|
|
-
|
|
|
|
|
|
+ public ArrayList<PlotComparisonItem> getPieData(){
|
|
|
|
+ // DEFAULT
|
|
|
|
+ return this.attacksPerProtocols();
|
|
}
|
|
}
|
|
|
|
+ public ArrayList<PlotComparisonItem> getBarData(){
|
|
|
|
+ ArrayList<String> protocolTitles = this.getSelectedProtocolTitles();
|
|
|
|
|
|
|
|
+ // DEFAULT
|
|
|
|
+ if (protocolTitles != null && protocolTitles.size() != 0){
|
|
|
|
+ String protocol = this.getSelectedProtocolTitles().get(0);
|
|
|
|
+ return this.attacksPerBSSID(protocol);
|
|
|
|
+ }
|
|
|
|
|
|
- public void actualisePlotData(){
|
|
|
|
-
|
|
|
|
|
|
+ // Nothing available
|
|
|
|
+ return new ArrayList<PlotComparisonItem>();
|
|
|
|
+ }
|
|
|
|
+ public ArrayList<PlotComparisonItem> getLinedata(){
|
|
|
|
+ // DEFAULT
|
|
|
|
+ return this.attacksPerDate();
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -264,7 +352,7 @@ public class StatisticsFragment extends Fragment {
|
|
});
|
|
});
|
|
return plotItems;
|
|
return plotItems;
|
|
}
|
|
}
|
|
- /*BAR PLOT DATA*/
|
|
|
|
|
|
+ /*LINE PLOT DATA*/
|
|
public ArrayList<PlotComparisonItem> attacksPerDate(){
|
|
public ArrayList<PlotComparisonItem> attacksPerDate(){
|
|
ArrayList<PlotComparisonItem> plotItems = new ArrayList<PlotComparisonItem>();
|
|
ArrayList<PlotComparisonItem> plotItems = new ArrayList<PlotComparisonItem>();
|
|
HashMap<Long, ArrayList<Record> > recordMap = new HashMap<Long, ArrayList<Record> >();
|
|
HashMap<Long, ArrayList<Record> > recordMap = new HashMap<Long, ArrayList<Record> >();
|
|
@@ -317,6 +405,62 @@ public class StatisticsFragment extends Fragment {
|
|
});
|
|
});
|
|
return plotItems;
|
|
return plotItems;
|
|
}
|
|
}
|
|
|
|
+ // BAR PLOT DATA
|
|
|
|
+ public ArrayList<PlotComparisonItem> attacksPerBSSID(String protocol){
|
|
|
|
+ LogFilter filter = new LogFilter();
|
|
|
|
+ ArrayList<String> protocollist = new ArrayList<String>();
|
|
|
|
+ protocollist.add(protocol);
|
|
|
|
+ filter.setProtocols(protocollist);
|
|
|
|
+
|
|
|
|
+ ArrayList<PlotComparisonItem> plotItems = new ArrayList<PlotComparisonItem>();
|
|
|
|
+
|
|
|
|
+ HashMap<String, Integer> recordMap = new HashMap<String, Integer>();
|
|
|
|
+ ArrayList<Record> records = this.dbh.getRecordsForFilter(filter);
|
|
|
|
+ for (Record record : records){
|
|
|
|
+ int count = recordMap.get(record.getBssid());
|
|
|
|
+ count++;
|
|
|
|
+ recordMap.put(record.getBssid(), count);
|
|
|
|
+ }
|
|
|
|
+ for (String key : recordMap.keySet()){
|
|
|
|
+ PlotComparisonItem item = new PlotComparisonItem(key, key, recordMap.get(key));
|
|
|
|
+ plotItems.add(item);
|
|
|
|
+ }
|
|
|
|
+ Collections.sort(plotItems, new Comparator<PlotComparisonItem>() {
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(PlotComparisonItem s1, PlotComparisonItem s2) {
|
|
|
|
+ return s1.getTitle().compareToIgnoreCase(s2.getTitle());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return plotItems;
|
|
|
|
+ }
|
|
|
|
+ public ArrayList<PlotComparisonItem> attacksPerESSID(String protocol){
|
|
|
|
+ LogFilter filter = new LogFilter();
|
|
|
|
+ ArrayList<String> protocollist = new ArrayList<String>();
|
|
|
|
+ protocollist.add(protocol);
|
|
|
|
+ filter.setProtocols(protocollist);
|
|
|
|
+
|
|
|
|
+ ArrayList<PlotComparisonItem> plotItems = new ArrayList<PlotComparisonItem>();
|
|
|
|
+
|
|
|
|
+ HashMap<String, Integer> recordMap = new HashMap<String, Integer>();
|
|
|
|
+ ArrayList<Record> records = this.dbh.getRecordsForFilter(filter);
|
|
|
|
+ for (Record record : records){
|
|
|
|
+ int count = recordMap.get(record.getSsid());
|
|
|
|
+ count++;
|
|
|
|
+ recordMap.put(record.getSsid(), count);
|
|
|
|
+ }
|
|
|
|
+ for (String key : recordMap.keySet()){
|
|
|
|
+ PlotComparisonItem item = new PlotComparisonItem(key, key, recordMap.get(key));
|
|
|
|
+ plotItems.add(item);
|
|
|
|
+ }
|
|
|
|
+ Collections.sort(plotItems, new Comparator<PlotComparisonItem>() {
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(PlotComparisonItem s1, PlotComparisonItem s2) {
|
|
|
|
+ return s1.getTitle().compareToIgnoreCase(s2.getTitle());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return plotItems;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/*
|
|
/*
|
|
* FILTER STUFF
|
|
* FILTER STUFF
|