From 0dbe96d723e7b60def82b5d0f7e1b07631a788f5 Mon Sep 17 00:00:00 2001 From: Harris Date: Wed, 25 May 2022 10:43:26 +1000 Subject: [PATCH] build: update build numbers (#895) fix: migration issues in 1.13.0 --- app/build.gradle | 4 ++-- .../securesms/database/LokiAPIDatabase.kt | 5 +++++ .../database/helpers/SQLCipherOpenHelper.java | 14 +++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0459c7f7b12..47db31d2d46 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -158,8 +158,8 @@ dependencies { testImplementation 'org.robolectric:shadows-multidex:4.4' } -def canonicalVersionCode = 278 -def canonicalVersionName = "1.13.0" +def canonicalVersionCode = 279 +def canonicalVersionName = "1.13.1" def postFixSize = 10 def abiPostFix = ['armeabi-v7a' : 1, diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/LokiAPIDatabase.kt b/app/src/main/java/org/thoughtcrime/securesms/database/LokiAPIDatabase.kt index 826c39ae8a1..0f97a0e6142 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/LokiAPIDatabase.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/LokiAPIDatabase.kt @@ -113,6 +113,9 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database( INSERT INTO $lastMessageHashValueTable2($snode, $publicKey, $lastMessageHashValue) SELECT $snode, $publicKey, $lastMessageHashValue FROM $legacyLastMessageHashValueTable2); DROP TABLE $legacyLastMessageHashValueTable2; """ + const val INSERT_LAST_HASH_DATA = "INSERT OR IGNORE INTO $lastMessageHashValueTable2($snode, $publicKey, $lastMessageHashValue) SELECT $snode, $publicKey, $lastMessageHashValue FROM $legacyLastMessageHashValueTable2;" + const val DROP_LEGACY_LAST_HASH = "DROP TABLE $legacyLastMessageHashValueTable2;" + const val UPDATE_RECEIVED_INCLUDE_NAMESPACE_COMMAND = """ CREATE TABLE IF NOT EXISTS $receivedMessageHashValuesTable( $publicKey STRING, $receivedMessageHashValues TEXT, $receivedMessageHashNamespace INTEGER DEFAULT 0, PRIMARY KEY ($publicKey, $receivedMessageHashNamespace) @@ -122,6 +125,8 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database( DROP TABLE $legacyReceivedMessageHashValuesTable3; """ + const val INSERT_RECEIVED_HASHES_DATA = "INSERT OR IGNORE INTO $receivedMessageHashValuesTable($publicKey, $receivedMessageHashValues) SELECT $publicKey, $receivedMessageHashValues FROM $legacyReceivedMessageHashValuesTable3;" + const val DROP_LEGACY_RECEIVED_HASHES = "DROP TABLE $legacyReceivedMessageHashValuesTable3;" // region Deprecated private val deviceLinkCache = "loki_pairing_authorisation_cache" diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index 8d3fcb472ab..94b9cf15987 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -65,9 +65,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { private static final int lokiV31 = 52; private static final int lokiV32 = 53; private static final int lokiV33 = 54; + private static final int lokiV34 = 55; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes - private static final int DATABASE_VERSION = lokiV33; + private static final int DATABASE_VERSION = lokiV34; private static final String DATABASE_NAME = "signal.db"; private final Context context; @@ -148,6 +149,10 @@ public void onCreate(SQLiteDatabase db) { db.execSQL(LokiAPIDatabase.CREATE_DEFAULT_FORK_INFO_COMMAND); db.execSQL(LokiAPIDatabase.UPDATE_HASHES_INCLUDE_NAMESPACE_COMMAND); db.execSQL(LokiAPIDatabase.UPDATE_RECEIVED_INCLUDE_NAMESPACE_COMMAND); + db.execSQL(LokiAPIDatabase.INSERT_LAST_HASH_DATA); + db.execSQL(LokiAPIDatabase.DROP_LEGACY_LAST_HASH); + db.execSQL(LokiAPIDatabase.INSERT_RECEIVED_HASHES_DATA); + db.execSQL(LokiAPIDatabase.DROP_LEGACY_RECEIVED_HASHES); executeStatements(db, SmsDatabase.CREATE_INDEXS); executeStatements(db, MmsDatabase.CREATE_INDEXS); @@ -349,6 +354,13 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(LokiAPIDatabase.UPDATE_RECEIVED_INCLUDE_NAMESPACE_COMMAND); } + if (oldVersion < lokiV34) { + db.execSQL(LokiAPIDatabase.INSERT_LAST_HASH_DATA); + db.execSQL(LokiAPIDatabase.DROP_LEGACY_LAST_HASH); + db.execSQL(LokiAPIDatabase.INSERT_RECEIVED_HASHES_DATA); + db.execSQL(LokiAPIDatabase.DROP_LEGACY_RECEIVED_HASHES); + } + db.setTransactionSuccessful(); } finally { db.endTransaction();