|
@@ -836,7 +836,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
return networkInformation;
|
|
|
}
|
|
|
|
|
|
- private NetworkRecord createNetworkRecord(Cursor cursor){
|
|
|
+ private synchronized NetworkRecord createNetworkRecord(Cursor cursor){
|
|
|
NetworkRecord record = new NetworkRecord();
|
|
|
record.setBssid(cursor.getString(0));
|
|
|
record.setSsid(cursor.getString(1));
|
|
@@ -852,7 +852,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* @param networkInformation ArrayList of {@link NetworkRecord NetworkRecords}
|
|
|
* @see {@link HostageDBOpenHelper#updateNetworkInformation(NetworkRecord record)}
|
|
|
*/
|
|
|
- public void updateNetworkInformation(ArrayList<NetworkRecord> networkInformation) {
|
|
|
+ public synchronized void updateNetworkInformation(ArrayList<NetworkRecord> networkInformation) {
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
|
|
|
db.beginTransaction();
|
|
@@ -888,7 +888,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* has a newer location time stamp.
|
|
|
* @param record The new {@link NetworkRecord}.
|
|
|
*/
|
|
|
- public void updateNetworkInformation(NetworkRecord record) {
|
|
|
+ public synchronized void updateNetworkInformation(NetworkRecord record) {
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
String bssid = record.getBssid();
|
|
|
String bssidQuery = "SELECT * FROM " + NetworkEntry.TABLE_NAME + " WHERE " + NetworkEntry.COLUMN_NAME_BSSID + " = ?";
|
|
@@ -913,7 +913,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* @param deviceID The Device id
|
|
|
* @param timestamp The synchronization timestamp
|
|
|
*/
|
|
|
- public void updateTimestampOfSyncDevice(String deviceID, long timestamp){
|
|
|
+ public synchronized void updateTimestampOfSyncDevice(String deviceID, long timestamp){
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
ContentValues deviceValues = new ContentValues();
|
|
|
deviceValues.put(SyncDeviceEntry.COLUMN_NAME_DEVICE_ID, deviceID);
|
|
@@ -926,7 +926,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* Updates the Timestamps of synchronization devices from a HashMap.
|
|
|
* @param devices HashMap of device ids and their synchronization timestamps.
|
|
|
*/
|
|
|
- public void updateSyncDevices(HashMap<String, Long> devices){
|
|
|
+ public synchronized void updateSyncDevices(HashMap<String, Long> devices){
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
db.beginTransaction();
|
|
|
|
|
@@ -945,13 +945,13 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
db.close();
|
|
|
}
|
|
|
|
|
|
- public void updateSyncDevices(ArrayList<SyncDevice> devices){
|
|
|
+ public synchronized void updateSyncDevices(ArrayList<SyncDevice> devices){
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
this.updateSyncDevices(devices, db);
|
|
|
db.close();
|
|
|
}
|
|
|
|
|
|
- public void updateSyncDevices(ArrayList<SyncDevice> devices, SQLiteDatabase db){
|
|
|
+ public synchronized void updateSyncDevices(ArrayList<SyncDevice> devices, SQLiteDatabase db){
|
|
|
db.beginTransaction();
|
|
|
|
|
|
try {
|
|
@@ -972,7 +972,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* Returns the own state containing all registered devices ids and their max sync_id
|
|
|
* @return {@link de.tudarmstadt.informatik.hostage.logging.SyncInfo}
|
|
|
*/
|
|
|
- public SyncInfo getOwnState(){
|
|
|
+ public synchronized SyncInfo getOwnState(){
|
|
|
ArrayList<SyncDevice> devices = this.getSyncDevices();
|
|
|
|
|
|
HashMap<String, Long> deviceMap = new HashMap<String, Long>();
|
|
@@ -1107,7 +1107,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
/**
|
|
|
* Deletes a device with given id from the device {@link de.tudarmstadt.informatik.hostage.persistence.HostageDBContract.SyncDeviceEntry} and also all data captured by this device in {@link SyncInfoEntry}
|
|
|
*/
|
|
|
- public void clearSyncInfos(){
|
|
|
+ public synchronized void clearSyncInfos(){
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
db.delete(SyncDeviceEntry.TABLE_NAME, null, null);
|
|
|
db.delete(SyncInfoEntry.TABLE_NAME, null, null);
|
|
@@ -1118,7 +1118,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
/**
|
|
|
* Deletes all records from {@link PacketEntry}s and {@link de.tudarmstadt.informatik.hostage.logging.AttackRecord}.
|
|
|
*/
|
|
|
- public void clearData() {
|
|
|
+ public synchronized void clearData() {
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
|
db.delete(PacketEntry.TABLE_NAME, null, null);
|
|
|
db.delete(AttackEntry.TABLE_NAME, null, null);
|
|
@@ -1800,7 +1800,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* @param includeMissing boolean
|
|
|
* @return array of {@link de.tudarmstadt.informatik.hostage.logging.SyncDevice}s
|
|
|
*/
|
|
|
- public ArrayList<SyncDevice> getUpdatedDevicesFor(HashMap<String, Long> oldDeviceMap, boolean includeMissing){
|
|
|
+ public synchronized ArrayList<SyncDevice> getUpdatedDevicesFor(HashMap<String, Long> oldDeviceMap, boolean includeMissing){
|
|
|
|
|
|
ArrayList<SyncDevice> recordList = new ArrayList<SyncDevice>();
|
|
|
String selectQuery = "SELECT * FROM " + SyncDeviceEntry.TABLE_NAME;
|
|
@@ -1834,7 +1834,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* Returns all device ids.
|
|
|
* @return list of all device ids.
|
|
|
*/
|
|
|
- public ArrayList<String> getAllDevicesIds(){
|
|
|
+ public synchronized ArrayList<String> getAllDevicesIds(){
|
|
|
|
|
|
String selectQuery = "SELECT "+ SyncDeviceEntry.COLUMN_NAME_DEVICE_ID+" FROM " + SyncDeviceEntry.TABLE_NAME;
|
|
|
SQLiteDatabase db = this.getReadableDatabase();
|
|
@@ -1860,7 +1860,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* @param devices owned device ids
|
|
|
* @return list of missing devices ids
|
|
|
*/
|
|
|
- public ArrayList<String> getMissingDeviceIds(ArrayList<String> devices){
|
|
|
+ public synchronized ArrayList<String> getMissingDeviceIds(ArrayList<String> devices){
|
|
|
ArrayList<String> ids = new ArrayList<String>();
|
|
|
String prefix = " D WHERE " + SyncDeviceEntry.COLUMN_NAME_DEVICE_ID + " NOT IN ";
|
|
|
String selectQuery = "SELECT "+ SyncDeviceEntry.COLUMN_NAME_DEVICE_ID +" FROM " + SyncDeviceEntry.TABLE_NAME + this.arrayToSQLString(devices,prefix);
|
|
@@ -1886,7 +1886,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* @param includeMissingDevices boolean
|
|
|
* @return list of {@link de.tudarmstadt.informatik.hostage.logging.AttackRecord}s
|
|
|
*/
|
|
|
- public ArrayList<SyncRecord> getUnsyncedAttacksFor(HashMap<String,Long> deviceMap, boolean includeMissingDevices){
|
|
|
+ public synchronized ArrayList<SyncRecord> getUnsyncedAttacksFor(HashMap<String,Long> deviceMap, boolean includeMissingDevices){
|
|
|
|
|
|
ArrayList<SyncDevice> updatedDevices = this.getUpdatedDevicesFor(deviceMap, includeMissingDevices);
|
|
|
|
|
@@ -1968,7 +1968,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
* Inserts the given devices in the database with save.
|
|
|
* @param devices list of {@link de.tudarmstadt.informatik.hostage.logging.SyncDevice}s
|
|
|
*/
|
|
|
- public void insertSyncDevices(List<SyncDevice> devices){
|
|
|
+ public synchronized void insertSyncDevices(List<SyncDevice> devices){
|
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
|
|
|
|
db.beginTransaction();
|