Browse Source

fixed some db bugs

Alexander Brakowski 9 years ago
parent
commit
1b2f7bf862

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/persistence/HostageDBOpenHelper.java

@@ -1915,7 +1915,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
         SQLiteDatabase db = this.getReadableDatabase();
 
         for (SyncDevice sDevice : updatedDevices){
-            String selectQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + " A " + " NATURAL JOIN " + PacketEntry.TABLE_NAME + " P "
+            String selectQuery = "SELECT * FROM " + AttackEntry.TABLE_NAME + " A " + ", " + PacketEntry.TABLE_NAME + " P "
                     + " WHERE "
                     +" ( "
                     + "A." + AttackEntry.COLUMN_NAME_ATTACK_ID + " = " + " P."+ PacketEntry.COLUMN_NAME_ATTACK_ID
@@ -1923,7 +1923,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
                     + " AND " + " A." + AttackEntry.COLUMN_NAME_SYNC_ID + " > " + sDevice.getHighest_attack_id()
                     + " ) "
                     //+ " GROUP BY " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_DEVICE
-                    + " ORDER BY " + AttackEntry.TABLE_NAME + "." + AttackEntry.COLUMN_NAME_SYNC_ID + " DESC ";
+                    + " ORDER BY A." + AttackEntry.COLUMN_NAME_SYNC_ID + " DESC ";
             Cursor cursor = db.rawQuery(selectQuery, null);
 
             // looping through all rows and adding to list

+ 12 - 2
src/de/tudarmstadt/informatik/hostage/sync/bluetooth/CommunicationThread.java

@@ -4,6 +4,7 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
 
@@ -44,7 +45,6 @@ public class CommunicationThread extends Thread {
 
 		ObjectInputStream tmpIn = null;
 		ObjectOutputStream tmpOut = null;
-		
 
 		// Get the input and output streams, using temp objects because
 		// member streams are final
@@ -100,16 +100,26 @@ public class CommunicationThread extends Thread {
 		switch(message.getMessage_code()){
 			case SyncMessage.SYNC_REQUEST:
                 SyncInfo thisSyncInfo = synchronizer.getSyncInfo();
-				write(new SyncMessage(SyncMessage.SYNC_RESPONSE_INFO, thisSyncInfo));
+
+                System.out.println("----------------------- Sent: " + Arrays.toString(thisSyncInfo.bssids.toArray()));
+                write(new SyncMessage(SyncMessage.SYNC_RESPONSE_INFO, thisSyncInfo));
 				break;			
 			case SyncMessage.SYNC_RESPONSE_INFO:
                 SyncInfo otherSyncInfo = (SyncInfo) message.getPayload();
+
+                System.out.println("----------------------- Received: " + Arrays.toString(otherSyncInfo.bssids.toArray()));
+                System.out.println("----------------------- Received: " + otherSyncInfo.deviceMap.toString());
+
                 SyncData thisSyncData = synchronizer.getSyncData(otherSyncInfo);
                 write(new SyncMessage(SyncMessage.SYNC_RESPONSE_DATA, thisSyncData));
 
 				break;
             case SyncMessage.SYNC_RESPONSE_DATA:
                 SyncData otherData = (SyncData) message.getPayload();
+
+                System.out.println("----------------------- Received: " + otherData.syncRecords.toString());
+                System.out.println("----------------------- Received: " + otherData.networkRecords.toString());
+
                 synchronizer.updateFromSyncData(otherData);
 
                 mHandler.obtainMessage(BluetoothSyncActivity.SYNC_SUCCESSFUL).sendToTarget();