Clean up any previously scheduled background poll jobs.

This commit is contained in:
Anton Chekulaev 2020-10-28 17:29:23 +11:00
parent 4fe6c8acfd
commit d178eefd98

View File

@ -93,8 +93,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV14_BACKUP_FILES = 35; private static final int lokiV14_BACKUP_FILES = 35;
private static final int lokiV15 = 36; private static final int lokiV15 = 36;
private static final int lokiV16 = 37; 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 static final String DATABASE_NAME = "signal.db";
private final Context context; private final Context context;
@ -638,6 +639,12 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
db.execSQL(LokiAPIDatabase.getCreateOpenGroupProfilePictureTableCommand()); 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(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();