From d178eefd98938fcc994a6ac678a2e8c20b8b3d02 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Wed, 28 Oct 2020 17:29:23 +1100 Subject: [PATCH] Clean up any previously scheduled background poll jobs. --- .../database/helpers/SQLCipherOpenHelper.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index cae4f03c09..d57c258717 100644 --- a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -93,8 +93,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { private static final int lokiV14_BACKUP_FILES = 35; private static final int lokiV15 = 36; private static final int lokiV16 = 37; + private static final int lokiV17_CLEAR_BG_POLL_JOBS = 38; - private static final int DATABASE_VERSION = lokiV16; + private static final int DATABASE_VERSION = lokiV17_CLEAR_BG_POLL_JOBS; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes private static final String DATABASE_NAME = "signal.db"; private final Context context; @@ -633,11 +634,17 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { if (oldVersion < lokiV15) { db.execSQL(SharedSenderKeysDatabase.getCreateOldClosedGroupRatchetTableCommand()); } - + if (oldVersion < lokiV16) { db.execSQL(LokiAPIDatabase.getCreateOpenGroupProfilePictureTableCommand()); } + if (oldVersion < lokiV17_CLEAR_BG_POLL_JOBS) { + // BackgroundPollJob was replaced with BackgroundPollWorker. Clear all the scheduled job records. + db.execSQL("DELETE FROM job_spec WHERE factory_key = 'BackgroundPollJob'"); + db.execSQL("DELETE FROM constraint_spec WHERE factory_key = 'BackgroundPollJob'"); + } + db.setTransactionSuccessful(); } finally { db.endTransaction();