|
@@ -899,7 +899,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));
|
|
@@ -915,7 +915,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.getWritableDatabase();
|
|
|
|
|
|
db.beginTransaction();
|
|
@@ -951,7 +951,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.getWritableDatabase();
|
|
|
String bssid = record.getBssid();
|
|
|
String bssidQuery = "SELECT * FROM " + NetworkEntry.TABLE_NAME + " WHERE " + NetworkEntry.COLUMN_NAME_BSSID + " = ?";
|
|
@@ -976,7 +976,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.getWritableDatabase();
|
|
|
ContentValues deviceValues = new ContentValues();
|
|
|
deviceValues.put(SyncDeviceEntry.COLUMN_NAME_DEVICE_ID, deviceID);
|
|
@@ -989,7 +989,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.getWritableDatabase();
|
|
|
db.beginTransaction();
|
|
|
|
|
@@ -1008,13 +1008,13 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
|
|
|
db.close();
|
|
|
}
|
|
|
|
|
|
- public void updateSyncDevices(ArrayList<SyncDevice> devices){
|
|
|
+ public synchronized void updateSyncDevices(ArrayList<SyncDevice> devices){
|
|
|
SQLiteDatabase db = this.getWritableDatabase();
|
|
|
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 {
|
|
@@ -1035,7 +1035,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>();
|
|
@@ -1170,7 +1170,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.getWritableDatabase();
|
|
|
db.delete(SyncDeviceEntry.TABLE_NAME, null, null);
|
|
|
db.delete(SyncInfoEntry.TABLE_NAME, null, null);
|
|
@@ -1181,7 +1181,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.getWritableDatabase();
|
|
|
db.delete(PacketEntry.TABLE_NAME, null, null);
|
|
|
db.delete(AttackEntry.TABLE_NAME, null, null);
|
|
@@ -1864,7 +1864,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;
|
|
@@ -1898,7 +1898,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();
|
|
@@ -1924,7 +1924,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);
|
|
@@ -1950,7 +1950,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);
|
|
|
|
|
@@ -2032,7 +2032,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();
|