RecordOverviewFragment.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. package de.tudarmstadt.informatik.hostage.ui2.fragment;
  2. import android.annotation.SuppressLint;
  3. import android.app.Fragment;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.graphics.Color;
  7. import android.os.Bundle;
  8. import android.text.SpannableString;
  9. import android.text.style.ForegroundColorSpan;
  10. import android.view.LayoutInflater;
  11. import android.view.Menu;
  12. import android.view.MenuInflater;
  13. import android.view.MenuItem;
  14. import android.view.View;
  15. import android.view.ViewGroup;
  16. import android.widget.AdapterView;
  17. import android.widget.ExpandableListView;
  18. import android.widget.ImageButton;
  19. import android.widget.PopupMenu;
  20. import android.widget.PopupMenu.OnMenuItemClickListener;
  21. import android.widget.Toast;
  22. import java.text.DateFormat;
  23. import java.text.SimpleDateFormat;
  24. import java.util.ArrayList;
  25. import java.util.Calendar;
  26. import java.util.Collections;
  27. import java.util.Comparator;
  28. import java.util.Date;
  29. import java.util.HashMap;
  30. import de.tudarmstadt.informatik.hostage.R;
  31. import de.tudarmstadt.informatik.hostage.logging.Record;
  32. import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
  33. import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
  34. import de.tudarmstadt.informatik.hostage.ui.LogFilter;
  35. import de.tudarmstadt.informatik.hostage.ui.LogFilter.SortType;
  36. import de.tudarmstadt.informatik.hostage.ui2.adapter.RecordListAdapter;
  37. import de.tudarmstadt.informatik.hostage.ui2.dialog.ChecklistDialog;
  38. import de.tudarmstadt.informatik.hostage.ui2.dialog.DateTimeDialogFragment;
  39. import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
  40. public class RecordOverviewFragment extends Fragment implements ChecklistDialog.ChecklistDialogListener, DateTimeDialogFragment.DateTimeDialogFragmentListener {
  41. static final String SELECTED_KEY = "Selected";
  42. static final String OTHERS_KEY = "Other";
  43. static final String FILTER_MENU_TITLE_BSSID = "BSSID";
  44. static final String FILTER_MENU_TITLE_ESSID = "ESSID";
  45. static final String FILTER_MENU_TITLE_PROTOCOLS = "Protocols";
  46. static final String FILTER_MENU_TITLE_TIMESTAMP_BELOW = "To Date";
  47. static final String FILTER_MENU_TITLE_TIMESTAMP_ABOVE = "From Date";
  48. static final String FILTER_MENU_TITLE_SORTING = "Sort by";
  49. static final String FILTER_MENU_TITLE_REMOVE = "Reset Filter";
  50. static final String FILTER_MENU_TITLE_GROUP = "Group by";
  51. private boolean wasBelowTimePicker;
  52. private LogFilter filter;
  53. private boolean showFilterButton;
  54. public String groupingKey;
  55. private ExpandableListView expListView;
  56. UglyDbHelper dbh;
  57. public RecordOverviewFragment(){}
  58. @Override
  59. public void onCreate(Bundle savedInstanceState) {
  60. super.onCreate(savedInstanceState);
  61. setHasOptionsMenu(true);
  62. }
  63. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  64. Bundle savedInstanceState) {
  65. dbh = new UglyDbHelper(this.getActivity().getBaseContext());
  66. // Get the message from the intent
  67. if (this.filter == null){
  68. Intent intent = this.getActivity().getIntent();
  69. LogFilter filter = intent.getParcelableExtra(LogFilter.LOG_FILTER_INTENT_KEY);
  70. if(filter == null){
  71. this.clearFilter();
  72. } else {
  73. this.filter = filter;
  74. }
  75. }
  76. if (this.groupingKey == null) this.groupingKey = this.groupingTitles().get(0);
  77. this.setShowFilterButton(!this.filter.isNotEditable());
  78. this.addRecordToDB();
  79. View rootView = inflater.inflate(R.layout.fragment_record_list, container, false);
  80. ExpandableListView mylist = (ExpandableListView) rootView.findViewById(R.id.loglistview);
  81. this.expListView = mylist;
  82. populateListViewFromDB(mylist);
  83. registerListClickCallback(mylist);
  84. ImageButton filterButton = (ImageButton) rootView.findViewById(R.id.FilterButton);
  85. filterButton.setOnClickListener(new View.OnClickListener() {
  86. public void onClick(View v) {
  87. RecordOverviewFragment.this.openFilterPopupMenuOnView(v);
  88. }
  89. });
  90. filterButton.setVisibility(this.showFilterButton? View.VISIBLE : View.INVISIBLE);
  91. ImageButton sortButton = (ImageButton) rootView.findViewById(R.id.SortButton);
  92. sortButton.setOnClickListener(new View.OnClickListener() {
  93. public void onClick(View v) {
  94. // Open SortMenu
  95. RecordOverviewFragment.this.openSortingDialog();
  96. }
  97. });
  98. ImageButton groupButton = (ImageButton) rootView.findViewById(R.id.GroupButton);
  99. groupButton.setOnClickListener(new View.OnClickListener() {
  100. public void onClick(View v) {
  101. // Open SortMenu
  102. RecordOverviewFragment.this.openGroupingDialog();
  103. }
  104. });
  105. return rootView;
  106. }
  107. public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  108. super.onCreateOptionsMenu(menu, inflater);
  109. }
  110. public boolean onFilterMenuItemSelected(MenuItem item) {
  111. String title = item.getTitle().toString();
  112. if(title.equals(FILTER_MENU_TITLE_BSSID)){
  113. this.openBSSIDFilterDialog();
  114. }
  115. if(title.equals(FILTER_MENU_TITLE_ESSID)){
  116. this.openESSIDFilterDialog();
  117. }
  118. if(title.equals(FILTER_MENU_TITLE_PROTOCOLS)){
  119. this.openProtocolsFilterDialog();
  120. }
  121. if(title.equals(FILTER_MENU_TITLE_SORTING)){
  122. this.openSortingDialog();
  123. }
  124. if(title.equals(FILTER_MENU_TITLE_REMOVE)){
  125. this.clearFilter();
  126. }
  127. if(title.equals(FILTER_MENU_TITLE_TIMESTAMP_BELOW)){
  128. this.openTimestampToFilterDialog();
  129. }
  130. if(title.equals(FILTER_MENU_TITLE_TIMESTAMP_ABOVE)){
  131. this.openTimestampFromFilterDialog();
  132. }
  133. return super.onOptionsItemSelected(item);
  134. }
  135. /*****************************
  136. *
  137. * ListView Stuff
  138. *
  139. * ***************************/
  140. private void populateListViewFromDB(ExpandableListView mylist) {
  141. HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
  142. ArrayList<Record> data = dbh.getRecordsForFilter(this.filter);
  143. // Adding Items to ListView
  144. String keys[] = new String[] { this.getString(R.string.RecordBSSID), this.getString(R.string.RecordSSID), this.getString(R.string.RecordProtocol), this.getString(R.string.RecordTimestamp)};
  145. int ids[] = new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp };
  146. HashMap<String, Integer> mapping = new HashMap<String, Integer>();
  147. int i = 0;
  148. for(String key : keys){
  149. mapping.put(key, ids[i]);
  150. i++;
  151. }
  152. ArrayList<String>groupTitle = new ArrayList<String>();
  153. for (Record val : data) {
  154. // DO GROUPING IN HERE
  155. HashMap<String, String> map = new HashMap<String, String>();
  156. map.put(this.getString(R.string.RecordBSSID), val.getBssid());
  157. map.put(this.getString(R.string.RecordSSID), val.getSsid());
  158. map.put(this.getString(R.string.RecordProtocol), val.getProtocol());
  159. map.put(this.getString(R.string.RecordTimestamp),
  160. this.getDateAsString(val.getTimestamp()));
  161. ExpandableListItem item = new ExpandableListItem();
  162. item.setData(map);
  163. item.setId_Mapping(mapping);
  164. String groupID = this.getGroupValue(val);
  165. ArrayList<ExpandableListItem> items = sectionData.get(groupID);
  166. if (items == null) {
  167. items = new ArrayList<ExpandableListItem>();
  168. sectionData.put(groupID, items);
  169. groupTitle.add(groupID);
  170. }
  171. items.add(item);
  172. }
  173. Collections.sort(groupTitle, new Comparator<String>() {
  174. @Override
  175. public int compare(String s1, String s2) {
  176. return s1.compareToIgnoreCase(s2);
  177. }
  178. });
  179. RecordListAdapter adapter = new RecordListAdapter(this.getApplicationContext(), groupTitle, sectionData);
  180. mylist.setAdapter(adapter);
  181. }
  182. private Context getBaseContext(){
  183. return this.getActivity().getBaseContext();
  184. }
  185. private Context getApplicationContext(){
  186. return this.getActivity().getApplicationContext();
  187. }
  188. private void registerListClickCallback(ExpandableListView mylist) {
  189. mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  190. public void onItemClick(AdapterView<?> parent, View viewClicked,
  191. int position, long idInDB) {
  192. UglyDbHelper dbh = new UglyDbHelper(getBaseContext());
  193. Record rec = dbh.getRecord((int) idInDB);
  194. String message = createInformationStringFromRecord(rec);
  195. Toast.makeText(getApplicationContext(), message,
  196. Toast.LENGTH_LONG).show();
  197. }
  198. private String createInformationStringFromRecord(Record rec) {
  199. String message = "id: " + rec.getId() + "\n" + "attack_id: "
  200. + rec.getAttack_id() + "\n" + "protocol: "
  201. + rec.getProtocol() + "\n" + "type: " + rec.getType()
  202. + "\n" + "externalIP: " + rec.getExternalIP() + "\n"
  203. + "localIP: " + rec.getLocalIP() + "\n"
  204. + "local port: " + rec.getLocalPort() + "\n"
  205. + "remoteIP: " + rec.getRemoteIP() + "\n" + "BSSID: "
  206. + rec.getBssid() + "\n" + "SSID: " + rec.getSsid()
  207. + "\n" + "latitude: " + rec.getLatitude() + "\n"
  208. + "longitude: " + rec.getLongitude() + "\n"
  209. + "accuracy: " + rec.getAccuracy() + "\n" + "packet: "
  210. + rec.getPacket() + "\n"
  211. + getDateAsString(rec.getTimestamp()) + "";
  212. return message;
  213. }
  214. });
  215. }
  216. /*****************************
  217. *
  218. * Date Transform
  219. *
  220. * ***************************/
  221. @SuppressLint("SimpleDateFormat")
  222. private String getDateAsString(long timeStamp) {
  223. try {
  224. DateFormat sdf = new SimpleDateFormat("H:mm dd/MM/yyyy");
  225. Date netDate = (new Date(timeStamp));
  226. return sdf.format(netDate);
  227. } catch (Exception ex) {
  228. return "xx";
  229. }
  230. }
  231. /*****************************
  232. *
  233. * Getter / Setter
  234. *
  235. * ***************************/
  236. public boolean isShowFilterButton() {
  237. return showFilterButton;
  238. }
  239. public void setShowFilterButton(boolean showFilterButton) {
  240. this.showFilterButton = showFilterButton;
  241. }
  242. /*****************************
  243. *
  244. * Open Dialog Methods
  245. *
  246. * ***************************/
  247. private void openGroupingDialog(){
  248. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_GROUP, this.groupingTitles(), this.selectedGroup(), false , this);
  249. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_GROUP);
  250. }
  251. private void openBSSIDFilterDialog(){
  252. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_BSSID,this.bssids(), this.selectedBSSIDs(), true , this);
  253. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_BSSID);
  254. }
  255. private void openESSIDFilterDialog(){
  256. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_ESSID,this.essids(), this.selectedESSIDs(), true , this);
  257. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_ESSID);
  258. }
  259. private void openProtocolsFilterDialog(){
  260. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,this.protocolTitles(), this.selectedProtocols(), true , this);
  261. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
  262. }
  263. private void openTimestampFromFilterDialog(){
  264. this.wasBelowTimePicker = false;
  265. DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
  266. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
  267. if (this.filter.aboveTimestamp != Long.MIN_VALUE)newFragment.setDate(this.filter.aboveTimestamp);
  268. }
  269. private void openTimestampToFilterDialog(){
  270. this.wasBelowTimePicker = true;
  271. DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
  272. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
  273. if (this.filter.belowTimestamp != Long.MAX_VALUE) newFragment.setDate(this.filter.belowTimestamp);
  274. }
  275. private void openSortingDialog(){
  276. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_SORTING,this.sortTypeTtiles(), this.selectedSorttype(), false , this);
  277. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
  278. }
  279. /*****************************
  280. *
  281. * Grouping Stuff
  282. *
  283. * ***************************/
  284. public String getGroupValue(Record rec){
  285. int index = this.groupingTitles().indexOf(this.groupingKey);
  286. switch (index){
  287. case 0:
  288. return rec.getProtocol();
  289. case 1:
  290. return rec.getBssid();
  291. case 2:
  292. return rec.getSsid();
  293. default:
  294. return rec.getProtocol();
  295. }
  296. }
  297. public ArrayList<String> getGroupTitle(){
  298. int index = this.groupingTitles().indexOf(this.groupingKey);
  299. switch (index){
  300. case 0:
  301. return this.protocolTitles();
  302. case 1:
  303. return this.bssids();
  304. case 2:
  305. return this.essids();
  306. default:
  307. return this.protocolTitles();
  308. }
  309. }
  310. /*****************************
  311. *
  312. * Filter Stuff
  313. *
  314. * ***************************/
  315. private void openFilterPopupMenuOnView(View v){
  316. // Open FilterMenu
  317. PopupMenu filterMenu = new PopupMenu(getBaseContext(), v);
  318. for(String title : RecordOverviewFragment.this.filterMenuTitles()){
  319. // Set a white Title
  320. SpannableString styledMenuTitle = new SpannableString(title);
  321. styledMenuTitle.setSpan(new ForegroundColorSpan(Color.parseColor("#FFFFFF")), 0, title.length(), 0);
  322. filterMenu.getMenu().add(styledMenuTitle);
  323. }
  324. filterMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
  325. public boolean onMenuItemClick(MenuItem item) {
  326. RecordOverviewFragment.this.onFilterMenuItemSelected(item);
  327. return true;
  328. }
  329. });
  330. filterMenu.show();
  331. }
  332. private void clearFilter(){
  333. if(filter == null) this.filter = new LogFilter();
  334. this.filter.clear();
  335. }
  336. public ArrayList<String> groupingTitles(){
  337. ArrayList<String> titles = new ArrayList<String>();
  338. for (String groupTitle : this.getResources().getStringArray(
  339. R.array.Grouping)) {
  340. titles.add(groupTitle);
  341. }
  342. return titles;
  343. }
  344. public boolean[] selectedGroup(){
  345. ArrayList<String> groups = this.groupingTitles();
  346. boolean[] selected = new boolean[groups.size()];
  347. int i = 0;
  348. for(String group : groups){
  349. selected[i] =(group.equals(this.groupingKey));
  350. i++;
  351. }
  352. return selected;
  353. }
  354. public ArrayList<String> protocolTitles(){
  355. ArrayList<String> titles = new ArrayList<String>();
  356. for (String protocol : this.getResources().getStringArray(
  357. R.array.protocols)) {
  358. titles.add(protocol);
  359. }
  360. return titles;
  361. }
  362. public boolean[] selectedProtocols(){
  363. ArrayList<String> protocols = this.protocolTitles();
  364. boolean[] selected = new boolean[protocols.size()];
  365. int i = 0;
  366. for(String protocol : protocols){
  367. selected[i] =(this.filter.protocols.contains(protocol));
  368. i++;
  369. }
  370. return selected;
  371. }
  372. public ArrayList<String> sortTypeTtiles(){
  373. ArrayList<String> titles = new ArrayList<String>();
  374. titles.add("Time");
  375. titles.add("Protocol");
  376. titles.add("BSSID");
  377. titles.add("ESSID");
  378. //titles.add("Remote Host Name");
  379. //titles.add("Local Host Name");
  380. //titles.add("Attack ID");
  381. //titles.add("ID");
  382. return titles;
  383. }
  384. public boolean[] selectedSorttype(){
  385. ArrayList<String> types = this.sortTypeTtiles();
  386. boolean[] selected = new boolean[types.size()];
  387. int i = 0;
  388. for(String sorttype : types){
  389. selected[i] =(this.filter.sorttype.toString() == sorttype);
  390. i++;
  391. }
  392. return selected;
  393. }
  394. public ArrayList<String> bssids(){
  395. ArrayList<String> records = dbh.getUniqueBSSIDRecords();
  396. return records;
  397. }
  398. public boolean[] selectedBSSIDs(){
  399. ArrayList<String> bssids = this.bssids();
  400. boolean[] selected = new boolean[bssids.size()];
  401. int i = 0;
  402. for(String bssid : bssids){
  403. selected[i] =(this.filter.BSSIDs.contains(bssid));
  404. i++;
  405. }
  406. return selected;
  407. }
  408. public ArrayList<String> essids(){
  409. ArrayList<String> records = dbh.getUniqueESSIDRecords();
  410. return records;
  411. }
  412. public boolean[] selectedESSIDs(){
  413. ArrayList<String> essids = this.essids();
  414. boolean[] selected = new boolean[essids.size()];
  415. int i = 0;
  416. for(String essid : essids){
  417. selected[i] =(this.filter.ESSIDs.contains(essid));
  418. i++;
  419. }
  420. return selected;
  421. }
  422. private ArrayList<String> filterMenuTitles(){
  423. ArrayList<String> titles = new ArrayList<String>();
  424. titles.add(FILTER_MENU_TITLE_BSSID);
  425. titles.add(FILTER_MENU_TITLE_ESSID);
  426. titles.add(FILTER_MENU_TITLE_PROTOCOLS);
  427. titles.add(FILTER_MENU_TITLE_TIMESTAMP_ABOVE);
  428. titles.add(FILTER_MENU_TITLE_TIMESTAMP_BELOW);
  429. if (this.filter.isSet())titles.add(FILTER_MENU_TITLE_REMOVE);
  430. return titles;
  431. }
  432. /*****************************
  433. *
  434. * Listener Actions
  435. *
  436. * ***************************/
  437. public void onDateTimePickerPositiveClick(DateTimeDialogFragment dialog) {
  438. if(this.wasBelowTimePicker){
  439. this.filter.setBelowTimestamp(dialog.getDate());
  440. } else {
  441. this.filter.setAboveTimestamp(dialog.getDate());
  442. }
  443. this.populateListViewFromDB(this.expListView);
  444. }
  445. public void onDateTimePickerNegativeClick(DateTimeDialogFragment dialog) {
  446. if(this.wasBelowTimePicker){
  447. this.filter.setBelowTimestamp(Long.MAX_VALUE);
  448. } else {
  449. this.filter.setAboveTimestamp(Long.MIN_VALUE);
  450. }
  451. }
  452. public void onDialogPositiveClick(ChecklistDialog dialog) {
  453. String title = dialog.getTitle();
  454. if(title.equals(FILTER_MENU_TITLE_BSSID)){
  455. ArrayList<String> titles =dialog.getSelectedItemTitles();
  456. if (titles.size() == this.bssids().size()){
  457. this.filter.setBSSIDs(new ArrayList<String>());
  458. } else {
  459. this.filter.setBSSIDs(titles);
  460. }
  461. }
  462. if(title.equals(FILTER_MENU_TITLE_ESSID)){
  463. ArrayList<String> titles =dialog.getSelectedItemTitles();
  464. if (titles.size() == this.essids().size()){
  465. this.filter.setESSIDs(new ArrayList<String>());
  466. } else {
  467. this.filter.setESSIDs(titles);
  468. }
  469. }
  470. if(title.equals(FILTER_MENU_TITLE_PROTOCOLS)){
  471. ArrayList<String> protocols = dialog.getSelectedItemTitles();
  472. if (protocols.size() == this.protocolTitles().size()){
  473. this.filter.setProtocols(new ArrayList<String>());
  474. } else {
  475. this.filter.setProtocols(dialog.getSelectedItemTitles());
  476. }
  477. }
  478. if(title.equals(FILTER_MENU_TITLE_SORTING)){
  479. ArrayList<String> titles = dialog.getSelectedItemTitles();
  480. String t = titles.get(0);
  481. int sortType = this.sortTypeTtiles().indexOf(t);
  482. this.filter.setSorttype(SortType.values()[sortType]);
  483. }
  484. if (title.equals(FILTER_MENU_TITLE_GROUP)){
  485. ArrayList<String> titles = dialog.getSelectedItemTitles();
  486. this.groupingKey = titles.get(0);
  487. }
  488. this.populateListViewFromDB(this.expListView);
  489. }
  490. public void onDialogNegativeClick(ChecklistDialog dialog) {
  491. }
  492. /*****************************
  493. *
  494. * TEST
  495. *
  496. * ***************************/
  497. private void addRecordToDB() {
  498. if ((dbh.getRecordCount() > 0)) return;
  499. Calendar cal = Calendar.getInstance();
  500. int maxProtocolsIndex = this.getResources().getStringArray(
  501. R.array.protocols).length;
  502. int numberofRecords = (int) (Math.random() * (50 - 10));
  503. for (int i = 0; i < numberofRecords; i++) {
  504. Record record = new Record();
  505. record.setId(i);
  506. record.setAttack_id(i);
  507. record.setBssid("BSSID: " + i);
  508. record.setSsid("SSID: w" + i);
  509. record.setTimestamp(cal.getTimeInMillis()
  510. + ((i * 60 * 60 * 60 * 24) * 1000));
  511. int index = i % maxProtocolsIndex;
  512. String protocolName = this.getResources().getStringArray(
  513. R.array.protocols)[index];
  514. record.setProtocol(protocolName);
  515. record.setLocalIP("127.0.0.1");
  516. record.setType(TYPE.SEND);
  517. dbh.addRecord(record);
  518. }
  519. int countAllLogs = dbh.getAllRecords().size();
  520. int countRecords = dbh.getRecordCount();
  521. int countAttacks = dbh.getAttackCount();
  522. if ((countRecords == 0)) {
  523. Record rec = dbh.getRecordOfAttackId(0);
  524. Record rec2 = dbh.getRecord(0);
  525. System.out.println("" + "Could not create logs!");
  526. }
  527. }
  528. }