RecordOverviewFragment.java 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  1. package de.tudarmstadt.informatik.hostage.ui2.fragment;
  2. import android.annotation.SuppressLint;
  3. import android.app.Activity;
  4. import android.app.AlertDialog;
  5. import android.app.FragmentManager;
  6. import android.content.Context;
  7. import android.content.DialogInterface;
  8. import android.content.Intent;
  9. import android.content.SharedPreferences;
  10. import android.os.Bundle;
  11. import android.os.Environment;
  12. import android.os.Message;
  13. import android.preference.PreferenceManager;
  14. import android.util.Log;
  15. import android.view.LayoutInflater;
  16. import android.view.Menu;
  17. import android.view.MenuInflater;
  18. import android.view.MenuItem;
  19. import android.view.View;
  20. import android.view.ViewGroup;
  21. import android.widget.ExpandableListView;
  22. import android.widget.ImageButton;
  23. import android.widget.ProgressBar;
  24. import android.widget.Toast;
  25. import com.google.android.gms.maps.model.LatLng;
  26. import java.io.File;
  27. import java.io.FileOutputStream;
  28. import java.text.DateFormat;
  29. import java.text.SimpleDateFormat;
  30. import java.util.ArrayList;
  31. import java.util.Calendar;
  32. import java.util.Collections;
  33. import java.util.Comparator;
  34. import java.util.Date;
  35. import java.util.HashMap;
  36. import java.util.Random;
  37. import de.tudarmstadt.informatik.hostage.R;
  38. import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
  39. import de.tudarmstadt.informatik.hostage.logging.AttackRecord;
  40. import de.tudarmstadt.informatik.hostage.logging.MessageRecord;
  41. import de.tudarmstadt.informatik.hostage.logging.NetworkRecord;
  42. import de.tudarmstadt.informatik.hostage.logging.Record;
  43. import de.tudarmstadt.informatik.hostage.logging.formatter.TraCINgFormatter;
  44. import de.tudarmstadt.informatik.hostage.persistence.HostageDBOpenHelper;
  45. import de.tudarmstadt.informatik.hostage.sync.bluetooth.BluetoothSync;
  46. import de.tudarmstadt.informatik.hostage.sync.nfc.NFCSync;
  47. import de.tudarmstadt.informatik.hostage.sync.tracing.TracingSyncActivity;
  48. import de.tudarmstadt.informatik.hostage.ui.LogFilter;
  49. import de.tudarmstadt.informatik.hostage.ui.LogFilter.SortType;
  50. import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
  51. import de.tudarmstadt.informatik.hostage.ui2.adapter.RecordListAdapter;
  52. import de.tudarmstadt.informatik.hostage.ui2.dialog.ChecklistDialog;
  53. import de.tudarmstadt.informatik.hostage.ui2.dialog.DateTimeDialogFragment;
  54. import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
  55. import de.tudarmstadt.informatik.hostage.ui2.popup.AbstractPopup;
  56. import de.tudarmstadt.informatik.hostage.ui2.popup.AbstractPopupItem;
  57. import de.tudarmstadt.informatik.hostage.ui2.popup.SimplePopupItem;
  58. import de.tudarmstadt.informatik.hostage.ui2.popup.SimplePopupTable;
  59. import de.tudarmstadt.informatik.hostage.ui2.popup.SplitPopupItem;
  60. public class RecordOverviewFragment extends UpNavigatibleFragment implements ChecklistDialog.ChecklistDialogListener, DateTimeDialogFragment.DateTimeDialogFragmentListener {
  61. static final String FILTER_MENU_TITLE_BSSID = "BSSID";
  62. static final String FILTER_MENU_TITLE_ESSID = "ESSID";
  63. static final String FILTER_MENU_TITLE_PROTOCOLS = MainActivity.getContext().getString(R.string.rec_protocol);
  64. static final String FILTER_MENU_TITLE_TIMESTAMP_BELOW = MainActivity.getContext().getString(
  65. R.string.rec_latest);
  66. static final String FILTER_MENU_TITLE_TIMESTAMP_ABOVE = MainActivity.getContext().getString(
  67. R.string.rec_earliest);
  68. static final String FILTER_MENU_TITLE_SORTING = MainActivity.getContext().getString(R.string.rec_sortby);
  69. static final String FILTER_MENU_TITLE_REMOVE = MainActivity.getContext().getString(R.string.rec_reset_filter);
  70. static final String FILTER_MENU_TITLE_GROUP = MainActivity.getContext().getString(
  71. R.string.rec_group_by);
  72. static final String FILTER_MENU_POPUP_TITLE = MainActivity.getContext().getString(
  73. R.string.rec_filter_by);
  74. private boolean wasBelowTimePicker;
  75. private LogFilter filter;
  76. private boolean showFilterButton;
  77. private View rootView;
  78. private int mListPosition = -1;
  79. private int mItemPosition = -1;
  80. public String groupingKey;
  81. private ExpandableListView expListView;
  82. private ProgressBar spinner;
  83. HostageDBOpenHelper dbh;
  84. private String sectionToOpen = "";
  85. private ArrayList<Integer> openSections;
  86. private SharedPreferences pref;
  87. public void setFilter(LogFilter filter){
  88. this.filter = filter;
  89. }
  90. Thread loader;
  91. public RecordOverviewFragment(){}
  92. public void setGroupKey(String key){
  93. this.groupingKey = key;
  94. }
  95. @Override
  96. public void onCreate(Bundle savedInstanceState) {
  97. super.onCreate(savedInstanceState);
  98. setHasOptionsMenu(true);
  99. }
  100. @Override
  101. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  102. Bundle savedInstanceState) {
  103. setHasOptionsMenu(true);
  104. getActivity().setTitle(getResources().getString(R.string.drawer_records));
  105. dbh = new HostageDBOpenHelper(this.getActivity().getBaseContext());
  106. pref = PreferenceManager.getDefaultSharedPreferences(getActivity());
  107. //this.addRecordToDB(5, 2);
  108. // Get the message from the intent
  109. if (this.filter == null){
  110. Intent intent = this.getActivity().getIntent();
  111. LogFilter filter = intent.getParcelableExtra(LogFilter.LOG_FILTER_INTENT_KEY);
  112. if(filter == null){
  113. this.clearFilter();
  114. } else {
  115. this.filter = filter;
  116. }
  117. }
  118. if (this.groupingKey == null) this.groupingKey = this.groupingTitles().get(0);
  119. this.setShowFilterButton(!this.filter.isNotEditable());
  120. View rootView = inflater.inflate(this.getLayoutId(), container, false);
  121. this.rootView = rootView;
  122. ExpandableListView mylist = (ExpandableListView) rootView.findViewById(R.id.loglistview);
  123. this.spinner =(ProgressBar) rootView.findViewById(R.id.progressBar1);
  124. this.spinner.setVisibility(View.GONE);
  125. this.expListView = mylist;
  126. this.initialiseListView();
  127. ImageButton filterButton = (ImageButton) rootView.findViewById(R.id.FilterButton);
  128. filterButton.setOnClickListener(new View.OnClickListener() {
  129. public void onClick(View v) {
  130. RecordOverviewFragment.this.openFilterPopupMenuOnView(v);
  131. }
  132. });
  133. filterButton.setVisibility(this.showFilterButton? View.VISIBLE : View.INVISIBLE);
  134. ImageButton sortButton = (ImageButton) rootView.findViewById(R.id.SortButton);
  135. sortButton.setOnClickListener(new View.OnClickListener() {
  136. public void onClick(View v) {
  137. // Open SortMenu
  138. RecordOverviewFragment.this.openSortingDialog();
  139. }
  140. });
  141. ImageButton groupButton = (ImageButton) rootView.findViewById(R.id.GroupButton);
  142. groupButton.setOnClickListener(new View.OnClickListener() {
  143. public void onClick(View v) {
  144. // Open SortMenu
  145. RecordOverviewFragment.this.openGroupingDialog();
  146. }
  147. });
  148. return rootView;
  149. }
  150. /**Initialises the expandable list view in a backgorund thread*/
  151. private void initialiseListView(){
  152. if (loader != null) loader.interrupt();
  153. this.spinner.setVisibility(View.VISIBLE);
  154. loader = new Thread(new Runnable(){
  155. private void updateUI(final RecordListAdapter currentAdapter)
  156. {
  157. if(loader.isInterrupted()){
  158. return;
  159. }
  160. Activity activity = RecordOverviewFragment.this.getActivity();
  161. if (activity != null){
  162. activity.runOnUiThread(new Runnable() {
  163. @Override
  164. public void run() {
  165. RecordOverviewFragment.this.expListView.setAdapter(currentAdapter);
  166. // Update view and remove loading spinner etc...
  167. RecordListAdapter adapter = (RecordListAdapter) RecordOverviewFragment.this.expListView.getExpandableListAdapter();
  168. if (adapter != null){
  169. adapter.notifyDataSetChanged();
  170. if (adapter.getGroupCount() == 1){
  171. RecordOverviewFragment.this.expListView.expandGroup(0);
  172. } else {
  173. RecordOverviewFragment.this.setSectionToOpen(RecordOverviewFragment.this.sectionToOpen);
  174. }
  175. }
  176. if (RecordOverviewFragment.this.openSections != null && RecordOverviewFragment.this.openSections.size() != 0){
  177. for (int i = 0; i < RecordOverviewFragment.this.openSections.size(); i++){
  178. int index = RecordOverviewFragment.this.openSections.get(i);
  179. RecordOverviewFragment.this.expListView.expandGroup(index);
  180. }
  181. } else {
  182. RecordOverviewFragment.this.openSections = new ArrayList<Integer>();
  183. }
  184. if (mListPosition != -1 && mItemPosition != -1)
  185. RecordOverviewFragment.this.expListView.setSelectedChild(mListPosition, mItemPosition, true);
  186. mListPosition = -1;
  187. mItemPosition = -1;
  188. registerListClickCallback(RecordOverviewFragment.this.expListView);
  189. RecordOverviewFragment.this.spinner.setVisibility(View.GONE);
  190. RecordOverviewFragment.this.actualiseFilterButton();
  191. }
  192. });
  193. }
  194. }
  195. private RecordListAdapter doInBackground()
  196. {
  197. return populateListViewFromDB(RecordOverviewFragment.this.expListView);
  198. }
  199. @Override
  200. public void run()
  201. {
  202. //RecordOverviewFragment.this.addRecordToDB(5, 10);
  203. updateUI(doInBackground());
  204. }
  205. });
  206. loader.start();
  207. this.actualiseFilterButton();
  208. }
  209. /**
  210. * Returns the Fragment layout ID
  211. * @return int The fragment layout ID
  212. * */
  213. public int getLayoutId(){
  214. return R.layout.fragment_record_list;
  215. }
  216. /**
  217. * Gets called if the user clicks on item in the filter menu.
  218. *
  219. * @param AbstractPopupItem item
  220. * */
  221. public void onFilterMenuItemSelected(AbstractPopupItem item) {
  222. String title = item.getTitle();
  223. if (item instanceof SplitPopupItem){
  224. SplitPopupItem splitItem = (SplitPopupItem)item;
  225. if (splitItem.wasRightTouch){
  226. this.openTimestampToFilterDialog();
  227. } else {
  228. this.openTimestampFromFilterDialog();
  229. }
  230. return;
  231. }
  232. if (title != null){
  233. if(title.equals(FILTER_MENU_TITLE_BSSID)){
  234. this.openBSSIDFilterDialog();
  235. }
  236. if(title.equals(FILTER_MENU_TITLE_ESSID)){
  237. this.openESSIDFilterDialog();
  238. }
  239. if(title.equals(FILTER_MENU_TITLE_PROTOCOLS)){
  240. this.openProtocolsFilterDialog();
  241. }
  242. if(title.equals(FILTER_MENU_TITLE_SORTING)){
  243. this.openSortingDialog();
  244. }
  245. if(title.equals(FILTER_MENU_TITLE_REMOVE)){
  246. this.clearFilter();
  247. this.actualiseListViewInBackground();
  248. }
  249. if(title.equals(FILTER_MENU_TITLE_TIMESTAMP_BELOW)){
  250. this.openTimestampToFilterDialog();
  251. }
  252. if(title.equals(FILTER_MENU_TITLE_TIMESTAMP_ABOVE)){
  253. this.openTimestampFromFilterDialog();
  254. }
  255. }
  256. //return super.onOptionsItemSelected(item);
  257. }
  258. @Override
  259. public void onStart() {
  260. super.onStart();
  261. if (this.expListView.getExpandableListAdapter() != null){
  262. if (this.expListView.getExpandableListAdapter().getGroupCount() == 1){
  263. this.expListView.expandGroup(0);
  264. } else {
  265. this.setSectionToOpen(this.sectionToOpen);
  266. }
  267. }
  268. }
  269. @Override
  270. public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  271. // Inflate the menu items for use in the action bar
  272. inflater.inflate(R.menu.records_overview_actions, menu);
  273. }
  274. @Override
  275. public boolean onOptionsItemSelected(MenuItem item) {
  276. switch (item.getItemId()) {
  277. case R.id.records_action_synchronize:
  278. AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
  279. builder.setTitle("Synchronize records");
  280. builder.setItems(new String[]{
  281. "Via Bluetooth",
  282. "Via NFC",
  283. "Via Online Database"
  284. }, new DialogInterface.OnClickListener() {
  285. @Override
  286. public void onClick(DialogInterface dialog, int position) {
  287. switch(position){
  288. case 0:
  289. getActivity().startActivity(new Intent(getActivity(), BluetoothSync.class));
  290. break;
  291. case 1:
  292. getActivity().startActivity(new Intent(getActivity(), NFCSync.class));
  293. break;
  294. case 2:
  295. getActivity().startActivity(new Intent(getActivity(), TracingSyncActivity.class));
  296. break;
  297. }
  298. }
  299. });
  300. builder.create();
  301. builder.show();
  302. return true;
  303. case R.id.records_action_export:
  304. AlertDialog.Builder builderExport = new AlertDialog.Builder(getActivity());
  305. builderExport.setTitle("Choose export format");
  306. builderExport.setItems(R.array.format, new DialogInterface.OnClickListener() {
  307. @Override
  308. public void onClick(DialogInterface dialog, int position) {
  309. RecordOverviewFragment.this.exportDatabase(position);
  310. }
  311. });
  312. builderExport.create();
  313. builderExport.show();
  314. return true;
  315. }
  316. return false;
  317. }
  318. private void exportDatabase(int format) {
  319. try {
  320. FileOutputStream log;
  321. String filename = "hostage_" + format + "_" + System.currentTimeMillis() + ".log";
  322. String externalLocation = pref.getString("pref_external_location",
  323. "");
  324. String root = Environment.getExternalStorageDirectory()
  325. .toString();
  326. if (root != null && HelperUtils.isExternalStorageWritable()) {
  327. File dir = new File(root + externalLocation);
  328. dir.mkdirs();
  329. File file = new File(dir, filename);
  330. log = new FileOutputStream(file);
  331. } else {
  332. Toast.makeText(getActivity(), "Could not write to SD Card",
  333. Toast.LENGTH_SHORT).show();
  334. return;
  335. }
  336. ArrayList<Record> records = dbh.getAllRecords();
  337. for (Record record : records) {
  338. log.write((record.toString((format == 1) ? TraCINgFormatter
  339. .getInstance() : null)).getBytes());
  340. }
  341. log.flush();
  342. log.close();
  343. Toast.makeText(
  344. getActivity(),
  345. "Exported records to " + externalLocation + filename, Toast.LENGTH_LONG)
  346. .show();
  347. } catch (Exception e) {
  348. Toast.makeText(getActivity(), "Could not write to SD Card",
  349. Toast.LENGTH_SHORT).show();
  350. e.printStackTrace();
  351. }
  352. }
  353. /*****************************
  354. *
  355. * Public API
  356. *
  357. * ***************************/
  358. /**
  359. * Group records by SSID and expand given SSID
  360. *
  361. * @param SSID the SSID
  362. */
  363. public void showDetailsForSSID(Context context, String SSID) {
  364. Log.e("RecordOverviewFragment", "Implement showDetailsForSSID!!");
  365. this.clearFilter();
  366. int ESSID_INDEX = 2;
  367. ArrayList<String> ssids = new ArrayList<String>();
  368. this.sectionToOpen = SSID;
  369. this.groupingKey = this.groupingTitles(context).get(ESSID_INDEX);
  370. }
  371. /*****************************
  372. *
  373. * ListView Stuff
  374. *
  375. * ***************************/
  376. /**
  377. * Reloads the data in the ExpandableListView for the given filter object.
  378. * @param ExpandableListView listview
  379. * */
  380. private RecordListAdapter populateListViewFromDB(ExpandableListView mylist) {
  381. HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
  382. ArrayList<Record> data = dbh.getRecordsForFilter(RecordOverviewFragment.this.filter);
  383. // Adding Items to ListView
  384. 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)};
  385. int ids[] = new int[] {R.id.RecordTextFieldBSSID, R.id.RecordTextFieldSSID, R.id.RecordTextFieldProtocol, R.id.RecordTextFieldTimestamp };
  386. HashMap<String, Integer> mapping = new HashMap<String, Integer>();
  387. int i = 0;
  388. for(String key : keys){
  389. mapping.put(key, ids[i]);
  390. i++;
  391. }
  392. ArrayList<String>groupTitle = new ArrayList<String>();
  393. for (Record val : data) {
  394. // DO GROUPING IN HERE
  395. HashMap<String, String> map = new HashMap<String, String>();
  396. map.put(RecordOverviewFragment.this.getString(R.string.RecordBSSID), val.getBssid());
  397. map.put(RecordOverviewFragment.this.getString(R.string.RecordSSID), val.getSsid());
  398. map.put(RecordOverviewFragment.this.getString(R.string.RecordProtocol), val.getProtocol());
  399. map.put(RecordOverviewFragment.this.getString(R.string.RecordTimestamp),
  400. RecordOverviewFragment.this.getDateAsString(val.getTimestamp()));
  401. ExpandableListItem item = new ExpandableListItem();
  402. item.setData(map);
  403. item.setId_Mapping(mapping);
  404. item.setTag(val.getAttack_id());
  405. String groupID = RecordOverviewFragment.this.getGroupValue(val);
  406. ArrayList<ExpandableListItem> items = sectionData.get(groupID);
  407. if (items == null) {
  408. items = new ArrayList<ExpandableListItem>();
  409. sectionData.put(groupID, items);
  410. groupTitle.add(groupID);
  411. }
  412. items.add(item);
  413. }
  414. Collections.sort(groupTitle, new Comparator<String>() {
  415. @Override
  416. public int compare(String s1, String s2) {
  417. return s1.compareToIgnoreCase(s2);
  418. }
  419. });
  420. RecordListAdapter adapter = null;
  421. if (mylist.getAdapter() != null && mylist.getAdapter() instanceof RecordListAdapter){
  422. adapter = (RecordListAdapter) mylist.getAdapter();
  423. adapter.setData(sectionData);
  424. adapter.setSectionHeader(groupTitle);
  425. } else {
  426. adapter = new RecordListAdapter( RecordOverviewFragment.this.getApplicationContext(), groupTitle, sectionData);
  427. }
  428. return adapter;
  429. }
  430. /**
  431. * Actualises the list in a background thread
  432. */
  433. private void actualiseListViewInBackground(){
  434. if (loader != null && loader.isAlive()) loader.interrupt();
  435. loader = null;
  436. this.spinner.setVisibility(View.VISIBLE);
  437. this.actualiseFilterButton();
  438. loader = new Thread(new Runnable() {
  439. @Override
  440. public void run() {
  441. this.runOnUiThread(this.doInBackground());
  442. }
  443. private RecordListAdapter doInBackground(){
  444. return RecordOverviewFragment.this.populateListViewFromDB(RecordOverviewFragment.this.expListView);
  445. }
  446. private void runOnUiThread(final RecordListAdapter adapter){
  447. Activity actv = RecordOverviewFragment.this.getActivity();
  448. if (actv != null){
  449. actv.runOnUiThread(new Runnable() {
  450. @Override
  451. public void run() {
  452. this.actualiseUI();
  453. }
  454. private void actualiseUI(){
  455. if (adapter != null){
  456. RecordOverviewFragment.this.expListView.setAdapter(adapter);
  457. adapter.notifyDataSetChanged();
  458. RecordOverviewFragment.this.spinner.setVisibility(View.GONE);
  459. }
  460. }
  461. });
  462. }
  463. }
  464. });
  465. loader.start();
  466. }
  467. /**This will open a section in the ExpandableListView with the same title as the parameter s.
  468. *
  469. * @param String s (the section title to open)
  470. *
  471. * */
  472. private void setSectionToOpen(String s){
  473. this.sectionToOpen = s;
  474. if (this.sectionToOpen != null && this.sectionToOpen.length() != 0){
  475. if (this.getGroupTitles().contains(this.sectionToOpen)){
  476. int section = this.getGroupTitles().indexOf(this.sectionToOpen);
  477. this.expListView.expandGroup(section);
  478. this.sectionToOpen = "";
  479. }
  480. }
  481. }
  482. /**
  483. * Returns the base context.
  484. * @return Context baseContext
  485. * */
  486. private Context getBaseContext(){
  487. return this.getActivity().getBaseContext();
  488. }
  489. /**Returns the application context.
  490. * @return Context application context
  491. * */
  492. private Context getApplicationContext(){
  493. return this.getActivity().getApplicationContext();
  494. }
  495. /**Sets the list view listener on the given ExpandableListView.
  496. *
  497. * @param ExpandableListView listview
  498. * */
  499. private void registerListClickCallback(ExpandableListView mylist) {
  500. mylist.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
  501. @Override
  502. public boolean onChildClick(ExpandableListView expandableListView, View view, int i, int i2, long l) {
  503. RecordListAdapter adapter = (RecordListAdapter)expandableListView.getExpandableListAdapter();
  504. ExpandableListItem item = (ExpandableListItem)adapter.getChild(i,i2);
  505. mListPosition = i;
  506. mItemPosition = i2;
  507. HostageDBOpenHelper dbh = new HostageDBOpenHelper(getBaseContext());
  508. Record rec = dbh.getRecordOfAttackId((int) item.getTag());
  509. RecordOverviewFragment.this.pushRecordDetailViewForRecord(rec);
  510. return true;
  511. }
  512. });
  513. mylist.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
  514. @Override
  515. public void onGroupExpand(int i) {
  516. RecordOverviewFragment.this.openSections.add(new Integer(i));
  517. }
  518. });
  519. mylist.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
  520. @Override
  521. public void onGroupCollapse(int i) {
  522. RecordOverviewFragment.this.openSections.remove(new Integer(i));
  523. }
  524. });
  525. }
  526. /*****************************
  527. *
  528. * Date Transform
  529. *
  530. * ***************************/
  531. /**Returns the date format "H:mm d.M.yy" for the given timestamp (long)
  532. * @param Long timestamp*/
  533. @SuppressLint("SimpleDateFormat")
  534. private String getDateAsString(long timeStamp) {
  535. try {
  536. DateFormat sdf = new SimpleDateFormat("H:mm d.M.yy");
  537. Date netDate = (new Date(timeStamp));
  538. return sdf.format(netDate);
  539. } catch (Exception ex) {
  540. return "xx";
  541. }
  542. }
  543. /*****************************
  544. *
  545. * Getter / Setter
  546. *
  547. * ***************************/
  548. public boolean isShowFilterButton() {
  549. return showFilterButton;
  550. }
  551. public void setShowFilterButton(boolean showFilterButton) {
  552. this.showFilterButton = showFilterButton;
  553. }
  554. /*****************************
  555. *
  556. * Open Dialog Methods
  557. *
  558. * ***************************/
  559. /**Opens the grouping dialog*/
  560. private void openGroupingDialog(){
  561. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_GROUP, this.groupingTitles(), this.selectedGroup(), false , this);
  562. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_GROUP);
  563. }
  564. /**opens the bssid filter dialog*/
  565. private void openBSSIDFilterDialog(){
  566. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_BSSID,this.bssids(), this.selectedBSSIDs(), true , this);
  567. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_BSSID);
  568. }
  569. /**opens the essid filter dialog*/
  570. private void openESSIDFilterDialog(){
  571. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_ESSID,this.essids(), this.selectedESSIDs(), true , this);
  572. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_ESSID);
  573. }
  574. /**opens the protocol filter dialog*/
  575. private void openProtocolsFilterDialog(){
  576. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,this.protocolTitles(), this.selectedProtocols(), true , this);
  577. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
  578. }
  579. /**opens the timestamp filter dialog (minimal timestamp required)*/
  580. private void openTimestampFromFilterDialog(){
  581. this.wasBelowTimePicker = false;
  582. DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
  583. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
  584. if (this.filter.aboveTimestamp != Long.MIN_VALUE)newFragment.setDate(this.filter.aboveTimestamp);
  585. }
  586. /**opens time timestamp filter dialog (maximal timestamp required)*/
  587. private void openTimestampToFilterDialog(){
  588. this.wasBelowTimePicker = true;
  589. DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
  590. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
  591. if (this.filter.belowTimestamp != Long.MAX_VALUE) newFragment.setDate(this.filter.belowTimestamp);
  592. }
  593. /**opens the sorting dialog*/
  594. private void openSortingDialog(){
  595. ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_SORTING,this.sortTypeTiles(), this.selectedSorttype(), false , this);
  596. newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
  597. }
  598. /*****************************
  599. *
  600. * Grouping Stuff
  601. *
  602. * ***************************/
  603. /**returns the group title for the given record. Uses the groupingKey to decied which value of the record should be used.
  604. * @param Record rec
  605. * @return String grouptitle*/
  606. public String getGroupValue(Record rec){
  607. int index = this.groupingTitles().indexOf(this.groupingKey);
  608. switch (index){
  609. case 0:
  610. return rec.getProtocol();
  611. case 1:
  612. return rec.getBssid();
  613. case 2:
  614. return rec.getSsid();
  615. default:
  616. return rec.getProtocol();
  617. }
  618. }
  619. /**Returns the Group titles for the specified grouping key. e.g. groupingKey is "ESSID" it returns all available essids.
  620. * @return ArrayList<String> grouptitles*/
  621. public ArrayList<String> getGroupTitles(){
  622. int index = this.groupingTitles().indexOf(this.groupingKey);
  623. switch (index){
  624. case 0:
  625. return this.protocolTitles();
  626. case 1:
  627. return this.bssids();
  628. case 2:
  629. return this.essids();
  630. default:
  631. return this.protocolTitles();
  632. }
  633. }
  634. /*****************************
  635. *
  636. * Filter Stuff
  637. *
  638. * ***************************/
  639. /**Returns the FilterButton.
  640. * @return ImageButton filterButton*/
  641. private ImageButton getFilterButton(){
  642. return (ImageButton) this.rootView.findViewById(R.id.FilterButton);
  643. }
  644. /**Opens the filter menu on a anchor view. The filter menu will always be on top of the anchor.
  645. * @param View anchorView*/
  646. private void openFilterPopupMenuOnView(View v){
  647. SimplePopupTable filterMenu = new SimplePopupTable(this.getActivity(), new AbstractPopup.OnPopupItemClickListener() {
  648. public void onItemClick(Object ob) {
  649. if (ob instanceof AbstractPopupItem){
  650. AbstractPopupItem item = (AbstractPopupItem) ob;
  651. RecordOverviewFragment.this.onFilterMenuItemSelected(item);
  652. }
  653. }
  654. });
  655. filterMenu.setTitle(FILTER_MENU_POPUP_TITLE);
  656. for(String title : RecordOverviewFragment.this.filterMenuTitles()){
  657. AbstractPopupItem item = null;
  658. if (title.equals(FILTER_MENU_TITLE_TIMESTAMP_BELOW)) continue;
  659. if (title.equals(FILTER_MENU_TITLE_TIMESTAMP_ABOVE)){
  660. item = new SplitPopupItem(this.getActivity());
  661. item.setValue(SplitPopupItem.RIGHT_TITLE, FILTER_MENU_TITLE_TIMESTAMP_BELOW);
  662. item.setValue(SplitPopupItem.LEFT_TITLE, FILTER_MENU_TITLE_TIMESTAMP_ABOVE);
  663. if (this.filter.hasBelowTimestamp()){
  664. item.setValue(SplitPopupItem.RIGHT_SUBTITLE, this.getDateAsString(this.filter.belowTimestamp));
  665. }
  666. if (this.filter.hasAboveTimestamp()){
  667. item.setValue(SplitPopupItem.LEFT_SUBTITLE, this.getDateAsString(this.filter.aboveTimestamp));
  668. }
  669. } else {
  670. item = new SimplePopupItem(this.getActivity());
  671. item.setTitle(title);
  672. ((SimplePopupItem)item).setSelected(this.isFilterSetForTitle(title));
  673. }
  674. filterMenu.addItem(item);
  675. }
  676. filterMenu.showOnView(v);
  677. }
  678. /**Returns true if the filter object is set for the given title otherwise false. e.g. the filter object has protocols,
  679. * so the method will return for the title FILTER_MENU_TITLE_PROTOCOLS TRUE.
  680. * @param String title
  681. * @return boolean value
  682. * */
  683. private boolean isFilterSetForTitle(String title){
  684. if (title.equals(FILTER_MENU_TITLE_BSSID)){
  685. return this.filter.hasBSSIDs();
  686. }
  687. if (title.equals(FILTER_MENU_TITLE_ESSID)){
  688. return this.filter.hasESSIDs();
  689. }
  690. if (title.equals(FILTER_MENU_TITLE_PROTOCOLS)){
  691. return this.filter.hasProtocols();
  692. }
  693. if (title.equals(FILTER_MENU_TITLE_TIMESTAMP_BELOW)){
  694. return this.filter.hasBelowTimestamp();
  695. }
  696. if (title.equals(FILTER_MENU_TITLE_TIMESTAMP_ABOVE)){
  697. return this.filter.hasAboveTimestamp();
  698. }
  699. return false;
  700. }
  701. /**clears the filter. Does not invoke populatelistview!*/
  702. private void clearFilter(){
  703. if(filter == null) this.filter = new LogFilter();
  704. this.filter.clear();
  705. }
  706. /**Returns all grouping titles
  707. * @param Context context
  708. * @return ArrayList<String> titles*/
  709. public ArrayList<String> groupingTitles(Context context){
  710. ArrayList<String> titles = new ArrayList<String>();
  711. for (String groupTitle : context.getResources().getStringArray(
  712. R.array.Grouping)) {
  713. titles.add(groupTitle);
  714. }
  715. return titles;
  716. }
  717. /**Returns all grouping titles.
  718. * @return ArrayList<String> tiles*/
  719. public ArrayList<String> groupingTitles(){
  720. ArrayList<String> titles = new ArrayList<String>();
  721. for (String groupTitle : this.getResources().getStringArray(
  722. R.array.Grouping)) {
  723. titles.add(groupTitle);
  724. }
  725. return titles;
  726. }
  727. /**
  728. * Returns a bool array. This array is true at the index of the groupingKey in groupingTitles(), otherwise false.
  729. * @return boolean[] selection
  730. * */
  731. public boolean[] selectedGroup(){
  732. ArrayList<String> groups = this.groupingTitles();
  733. boolean[] selected = new boolean[groups.size()];
  734. int i = 0;
  735. for(String group : groups){
  736. selected[i] =(group.equals(this.groupingKey));
  737. i++;
  738. }
  739. return selected;
  740. }
  741. /**Returns all protocol titles / names.
  742. * @return ArrayList<String> protocolTitles
  743. * */
  744. public ArrayList<String> protocolTitles(){
  745. ArrayList<String> titles = new ArrayList<String>();
  746. for (String protocol : this.getResources().getStringArray(
  747. R.array.protocols)) {
  748. titles.add(protocol);
  749. }
  750. return titles;
  751. }
  752. /**Return a boolean array of the selected / filtered protocols. If the filter object has
  753. * an protocol from the protocolTitles() array, the index of it will be true, otherwise false.
  754. * @return boolean[] protocol selection
  755. * */
  756. public boolean[] selectedProtocols(){
  757. ArrayList<String> protocols = this.protocolTitles();
  758. boolean[] selected = new boolean[protocols.size()];
  759. int i = 0;
  760. for(String protocol : protocols){
  761. selected[i] =(this.filter.protocols.contains(protocol));
  762. i++;
  763. }
  764. return selected;
  765. }
  766. /**
  767. * Returns the Sorttype Titles
  768. * @return ArayList<String> Sort type titles
  769. * */
  770. public ArrayList<String> sortTypeTiles(){
  771. ArrayList<String> titles = new ArrayList<String>();
  772. titles.add(MainActivity.getContext().getString(R.string.rec_time));
  773. titles.add(MainActivity.getContext().getString(R.string.rec_protocol));
  774. titles.add(MainActivity.getContext().getString(R.string.BSSID));
  775. titles.add(MainActivity.getContext().getString(R.string.ESSID));
  776. return titles;
  777. }
  778. /**
  779. * Returns an boolean array. The array is true at the index of the selected sort type..
  780. * The index of the selected sort type is the same index in the sortTypeTiles array.
  781. * @return boolean array, length == sortTypeTiles().length
  782. * */
  783. public boolean[] selectedSorttype(){
  784. ArrayList<String> types = this.sortTypeTiles();
  785. boolean[] selected = new boolean[types.size()];
  786. int i = 0;
  787. for(String sorttype : types){
  788. selected[i] =(this.filter.sorttype.toString().equals(sorttype));
  789. i++;
  790. }
  791. return selected;
  792. }
  793. /**
  794. * Returns all unique bssids.
  795. * @return ArrayList<String>
  796. * */
  797. public ArrayList<String> bssids(){
  798. ArrayList<String> records = dbh.getUniqueBSSIDRecords();
  799. return records;
  800. }
  801. /**
  802. * Returns an boolean array. The array is true at the indices of the selected bssids.
  803. * The index of the selected bssid is the same index in the bssids() array.
  804. * @return boolean array, length == bssids().length
  805. * */
  806. public boolean[] selectedBSSIDs(){
  807. ArrayList<String> bssids = this.bssids();
  808. boolean[] selected = new boolean[bssids.size()];
  809. int i = 0;
  810. for(String bssid : bssids){
  811. selected[i] =(this.filter.BSSIDs.contains(bssid));
  812. i++;
  813. }
  814. return selected;
  815. }
  816. /**
  817. * Returns all unique essids.
  818. * @return ArrayList<String>
  819. * */
  820. public ArrayList<String> essids(){
  821. ArrayList<String> records = dbh.getUniqueESSIDRecords();
  822. return records;
  823. }
  824. /**
  825. * Returns an boolean array. The array is true at the indices of the selected essids.
  826. * The index of the selected essid is the same index in the essids() array.
  827. * @return boolean array, length == essids().length
  828. * */
  829. public boolean[] selectedESSIDs(){
  830. ArrayList<String> essids = this.essids();
  831. boolean[] selected = new boolean[essids.size()];
  832. int i = 0;
  833. for(String essid : essids){
  834. selected[i] =(this.filter.ESSIDs.contains(essid));
  835. i++;
  836. }
  837. return selected;
  838. }
  839. /**
  840. * Returns all filter menu titles.
  841. * @return ArrayList<String>
  842. * */
  843. private ArrayList<String> filterMenuTitles(){
  844. ArrayList<String> titles = new ArrayList<String>();
  845. titles.add(FILTER_MENU_TITLE_BSSID);
  846. titles.add(FILTER_MENU_TITLE_ESSID);
  847. titles.add(FILTER_MENU_TITLE_PROTOCOLS);
  848. titles.add(FILTER_MENU_TITLE_TIMESTAMP_ABOVE);
  849. titles.add(FILTER_MENU_TITLE_TIMESTAMP_BELOW);
  850. if (this.filter.isSet())titles.add(FILTER_MENU_TITLE_REMOVE);
  851. return titles;
  852. }
  853. /*****************************
  854. *
  855. * Listener Actions
  856. *
  857. * ***************************/
  858. /**
  859. * Will be called if the users selects a timestamp.
  860. * @param DateTimeDialogFragment dialog
  861. * */
  862. public void onDateTimePickerPositiveClick(DateTimeDialogFragment dialog) {
  863. if(this.wasBelowTimePicker){
  864. this.filter.setBelowTimestamp(dialog.getDate());
  865. } else {
  866. this.filter.setAboveTimestamp(dialog.getDate());
  867. }
  868. this.actualiseListViewInBackground();
  869. this.actualiseFilterButton();
  870. }
  871. /**
  872. * Will be called if the users cancels a timestamp selection.
  873. * @param DateTimeDialogFragment dialog
  874. * */
  875. public void onDateTimePickerNegativeClick(DateTimeDialogFragment dialog) {
  876. if(this.wasBelowTimePicker){
  877. this.filter.setBelowTimestamp(Long.MAX_VALUE);
  878. } else {
  879. this.filter.setAboveTimestamp(Long.MIN_VALUE);
  880. }
  881. this.actualiseFilterButton();
  882. }
  883. /**
  884. * Will be called if the users clicks the positiv button on a ChechlistDialog.
  885. * @param ChecklistDialog dialog
  886. */
  887. public void onDialogPositiveClick(ChecklistDialog dialog) {
  888. String title = dialog.getTitle();
  889. if(title.equals(FILTER_MENU_TITLE_BSSID)){
  890. ArrayList<String> titles =dialog.getSelectedItemTitles();
  891. if (titles.size() == this.bssids().size()){
  892. this.filter.setBSSIDs(new ArrayList<String>());
  893. } else {
  894. this.filter.setBSSIDs(titles);
  895. }
  896. }
  897. if(title.equals(FILTER_MENU_TITLE_ESSID)){
  898. ArrayList<String> titles =dialog.getSelectedItemTitles();
  899. if (titles.size() == this.essids().size()){
  900. this.filter.setESSIDs(new ArrayList<String>());
  901. } else {
  902. this.filter.setESSIDs(titles);
  903. }
  904. }
  905. if(title.equals(FILTER_MENU_TITLE_PROTOCOLS)){
  906. ArrayList<String> protocols = dialog.getSelectedItemTitles();
  907. if (protocols.size() == this.protocolTitles().size()){
  908. this.filter.setProtocols(new ArrayList<String>());
  909. } else {
  910. this.filter.setProtocols(dialog.getSelectedItemTitles());
  911. }
  912. }
  913. if(title.equals(FILTER_MENU_TITLE_SORTING)){
  914. ArrayList<String> titles = dialog.getSelectedItemTitles();
  915. if (titles.size() == 0) return;
  916. String t = titles.get(0);
  917. int sortType = this.sortTypeTiles().indexOf(t);
  918. this.filter.setSorttype(SortType.values()[sortType]);
  919. }
  920. if (title.equals(FILTER_MENU_TITLE_GROUP)){
  921. ArrayList<String> titles = dialog.getSelectedItemTitles();
  922. if (titles.size() == 0) return;
  923. this.groupingKey = titles.get(0);
  924. }
  925. this.actualiseListViewInBackground();
  926. this.actualiseFilterButton();
  927. }
  928. /**Paints the filter button if the current filter object is set.*/
  929. private void actualiseFilterButton(){
  930. if (this.filter.isSet() ){
  931. ImageButton filterButton = this.getFilterButton();
  932. if (filterButton != null){
  933. filterButton.setImageResource(R.drawable.ic_filter_pressed);
  934. filterButton.invalidate();
  935. }
  936. } else {
  937. ImageButton filterButton = this.getFilterButton();
  938. if (filterButton != null){
  939. filterButton.setImageResource(R.drawable.ic_filter);
  940. filterButton.invalidate();
  941. }
  942. }
  943. }
  944. /**
  945. * Will be called if the users clicks the negativ button on a ChechlistDialog.
  946. * @param ChecklistDialog dialog
  947. */
  948. public void onDialogNegativeClick(ChecklistDialog dialog) {}
  949. /*****************************
  950. *
  951. * TEST
  952. *
  953. * ***************************/
  954. /**
  955. * This will clear the database at first and than add new attacks.
  956. * @param int number of networks to create
  957. * @param int maximal number of attack per network
  958. * */
  959. private void addRecordToDB( int createNetworks, int attacksPerNetwork) {
  960. if ((dbh.getRecordCount() > 0)) dbh.clearData();
  961. Calendar cal = Calendar.getInstance();
  962. int maxProtocolsIndex = this.getResources().getStringArray(
  963. R.array.protocols).length;
  964. Random random = new Random();
  965. LatLng tudarmstadtLoc = new LatLng(49.86923, 8.6632768);
  966. final double ssidRadius = 0.1;
  967. final double bssidRadius = 0.004;
  968. int attackId = 0;
  969. for (int numOfNetworks = 0; numOfNetworks < createNetworks; numOfNetworks++){
  970. String ssidName = "WiFi" + ((numOfNetworks) + 1);
  971. String bssidName = "127.0.0." + ((numOfNetworks) + 1);
  972. int protocolIndex = numOfNetworks % maxProtocolsIndex;
  973. String protocolName = this.getResources().getStringArray(
  974. R.array.protocols)[protocolIndex];
  975. int numOfAttackPerNetwork = (Math.abs(random.nextInt()) % attacksPerNetwork) + 1;
  976. NetworkRecord network = new NetworkRecord();
  977. network.setBssid(bssidName);
  978. network.setSsid(ssidName);
  979. LatLng ssidLocation = new LatLng(tudarmstadtLoc.latitude - ssidRadius + 2.0 * ssidRadius * Math.random(), tudarmstadtLoc.longitude - ssidRadius + 2.0 * ssidRadius * Math.random());
  980. double latitude = ssidLocation.latitude - bssidRadius + 2.0 * bssidRadius * Math.random();
  981. double longitude = ssidLocation.longitude - bssidRadius + 2.0 * bssidRadius * Math.random();
  982. long timestamp = cal.getTimeInMillis();
  983. network.setTimestampLocation(timestamp);
  984. network.setLongitude(longitude);
  985. network.setLatitude(latitude);
  986. network.setAccuracy(0.f);
  987. dbh.updateNetworkInformation(network);
  988. // ATTACKS PER NETWORK
  989. for (int attackNumber = 0; attackNumber < numOfAttackPerNetwork; attackNumber++) {
  990. int numRecordsPerAttack = (Math.abs(random.nextInt()) % 5) + 1;
  991. /*
  992. * ADD A ATTACK*/
  993. AttackRecord attack = new AttackRecord();
  994. attack.setAttack_id(attackId);
  995. attack.setBssid(bssidName);
  996. attack.setProtocol(protocolName);
  997. attack.setLocalIP(bssidName);
  998. dbh.addAttackRecord(attack);
  999. // RECORDS PER ATTACK
  1000. for (int messageID = attackId; messageID < attackId + numRecordsPerAttack; messageID++) {
  1001. MessageRecord message = new MessageRecord();
  1002. message.setId(messageID);
  1003. message.setAttack_id(attackId);
  1004. // GO BACK IN TIME
  1005. message.setTimestamp(cal.getTimeInMillis()
  1006. - ((messageID * 60 * 60 * 24) * 1000) + (1000 * ((messageID - attackId) + 1)));
  1007. message.setType(MessageRecord.TYPE.SEND);
  1008. message.setPacket("");
  1009. dbh.addMessageRecord(message);
  1010. }
  1011. attackId+=numRecordsPerAttack;
  1012. }
  1013. }
  1014. // int countAllLogs = dbh.getAllRecords().size();
  1015. // int countRecords = dbh.getRecordCount();
  1016. // int countAttacks = dbh.getAttackCount();
  1017. //
  1018. // if ((countRecords == 0)) {
  1019. // Record rec = dbh.getRecordOfAttackId(0);
  1020. // Record rec2 = dbh.getRecord(0);
  1021. //
  1022. // System.out.println("" + "Could not create logs!");
  1023. // }
  1024. }
  1025. /**Navigation. Shows the record detail view for the given record
  1026. * @param Record record to show
  1027. * */
  1028. private void pushRecordDetailViewForRecord(Record record){
  1029. FragmentManager fm = this.getActivity().getFragmentManager();
  1030. if (fm != null){
  1031. RecordDetailFragment newFragment = new RecordDetailFragment();
  1032. newFragment.setRecord(record);
  1033. newFragment.setUpNavigatible(true);
  1034. MainActivity.getInstance().injectFragment(newFragment);
  1035. }
  1036. }
  1037. }