NetworkRecord.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.io.Serializable;
  3. import android.os.Parcel;
  4. import android.os.Parcelable;
  5. /**
  6. * Holds all necessary information about a single network.
  7. */
  8. public class NetworkRecord implements Parcelable, Serializable {
  9. private static final long serialVersionUID = -1586629159904177836L;
  10. private String bssid;
  11. private String ssid;
  12. private long timestampLocation;
  13. private double latitude;
  14. private double longitude;
  15. private float accuracy;
  16. public static final Parcelable.Creator<NetworkRecord> CREATOR = new Parcelable.Creator<NetworkRecord>() {
  17. @Override
  18. public NetworkRecord createFromParcel(Parcel source) {
  19. return new NetworkRecord(source);
  20. }
  21. @Override
  22. public NetworkRecord[] newArray(int size) {
  23. return new NetworkRecord[size];
  24. }
  25. };
  26. public NetworkRecord() {
  27. }
  28. public NetworkRecord(Parcel source) {
  29. this.bssid = source.readString();
  30. this.ssid = source.readString();
  31. this.timestampLocation = source.readLong();
  32. this.latitude = source.readDouble();
  33. this.longitude = source.readDouble();
  34. this.accuracy = source.readFloat();
  35. }
  36. @Override
  37. public int describeContents() {
  38. return 0;
  39. }
  40. @Override
  41. public void writeToParcel(Parcel dest, int flags) {
  42. dest.writeString(bssid);
  43. dest.writeString(ssid);
  44. dest.writeLong(timestampLocation);
  45. dest.writeDouble(latitude);
  46. dest.writeDouble(longitude);
  47. dest.writeFloat(accuracy);
  48. }
  49. /**
  50. * @return the bssid
  51. */
  52. public String getBssid() {
  53. return bssid;
  54. }
  55. /**
  56. * @param bssid
  57. * the bssid to set
  58. */
  59. public void setBssid(String bssid) {
  60. this.bssid = bssid;
  61. }
  62. /**
  63. * @return the ssid
  64. */
  65. public String getSsid() {
  66. return ssid;
  67. }
  68. /**
  69. * @param ssid
  70. * the ssid to set
  71. */
  72. public void setSsid(String ssid) {
  73. this.ssid = ssid;
  74. }
  75. /**
  76. * @return the timestampLocation
  77. */
  78. public long getTimestampLocation() {
  79. return timestampLocation;
  80. }
  81. /**
  82. * @param timestampLocation
  83. * the timestampLocation to set
  84. */
  85. public void setTimestampLocation(long timestampLocation) {
  86. this.timestampLocation = timestampLocation;
  87. }
  88. /**
  89. * @return the latitude
  90. */
  91. public double getLatitude() {
  92. return latitude;
  93. }
  94. /**
  95. * @param latitude
  96. * the latitude to set
  97. */
  98. public void setLatitude(double latitude) {
  99. this.latitude = latitude;
  100. }
  101. /**
  102. * @return the longitude
  103. */
  104. public double getLongitude() {
  105. return longitude;
  106. }
  107. /**
  108. * @param longitude
  109. * the longitude to set
  110. */
  111. public void setLongitude(double longitude) {
  112. this.longitude = longitude;
  113. }
  114. /**
  115. * @return the accuracy
  116. */
  117. public float getAccuracy() {
  118. return accuracy;
  119. }
  120. /**
  121. * @param accuracy
  122. * the accuracy to set
  123. */
  124. public void setAccuracy(float accuracy) {
  125. this.accuracy = accuracy;
  126. }
  127. public String toJSON() {
  128. return String.format("{\"bssid\":\"%s\",\"ssid\":%s,\"latitude\":%s,\"longitude\":%s,\"timestamp\":%s,\"attacks\":%d,\"portscans\":%d}", bssid, ssid,
  129. latitude, longitude, timestampLocation, -1, -1);
  130. }
  131. }