Browse Source

updapte own device in updated devices for dbh

Julien Clauter 9 years ago
parent
commit
8a0960738e

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

@@ -1854,6 +1854,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
      * @param includeMissing boolean
      * @return array of {@link de.tudarmstadt.informatik.hostage.logging.SyncDevice}s
      */
+    /*
     public ArrayList<SyncDevice> getUpdatedDevicesFor(List<SyncDevice> oldDevices, boolean includeMissing){
 
         HashMap<String, Long> oldDeviceMap = new HashMap<String, Long>();
@@ -1888,7 +1889,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
         // return record list
         db.close();
         return recordList;
-    }
+    }*/
 
 
     /**
@@ -1904,11 +1905,20 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
         SQLiteDatabase db = this.getReadableDatabase();
         Cursor cursor = db.rawQuery(selectQuery, null);
 
+        boolean actualiseOwnDevice = false;
+        if (oldDeviceMap.keySet().contains(currentDevice().getDeviceID()) || includeMissing){
+            actualiseOwnDevice = true;
+        }
+
         // looping through all rows and adding to list
         if (cursor.moveToFirst()) {
             do {
                 SyncDevice record = createSyncDevice(cursor);
                 // Adding record to list
+
+                if (record.getDeviceID().equals(record.getDeviceID()) && actualiseOwnDevice)
+                    record.setHighest_attack_id(currentDevice().getHighest_attack_id());
+
                 if (oldDeviceMap.containsKey(record.getDeviceID())){
                     Long oldSyncId = oldDeviceMap.get(record.getDeviceID());
                     if (oldSyncId < record.getHighest_attack_id()){
@@ -1918,6 +1928,7 @@ public class HostageDBOpenHelper extends SQLiteOpenHelper {
                     if (includeMissing)
                         recordList.add(record);
                 }
+
             } while (cursor.moveToNext());
         }
         cursor.close();