Migrate queued jobs during SMS migration.

This commit is contained in:
Greyson Parrelli
2022-12-16 23:29:07 -05:00
parent 4d9dc42868
commit c6f29fc950
14 changed files with 144 additions and 33 deletions

View File

@@ -0,0 +1,32 @@
package org.thoughtcrime.securesms.keyvalue
import android.annotation.SuppressLint
import android.content.Context
import androidx.preference.PreferenceManager
/**
* There are some values that you can't, for whatever reason, store in the normal encrypted [KeyValueStore].
* Usually, it's because the value your storing is _related to_ the database. Regardless, this is just a normal
* shared-prefs-backed class. Do not put anything in here that you wouldn't be comfortable storing in plain text.
*
* A good rule of thumb might be: if you're not comforable logging it, then you shouldn't be comfortable putting
* it in here.
*/
class PlainTextSharedPrefsDataStore(private val context: Context) {
companion object {
const val SMS_MIGRATION_ID_OFFSET = "sms_migration_id_offset"
}
private val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context)
/**
* Stores the ID offset that was determined during the big migration that moved all SMS messages into the MMS table.
*/
var smsMigrationIdOffset: Long
get() = sharedPrefs.getLong(SMS_MIGRATION_ID_OFFSET, -1)
@SuppressLint("ApplySharedPref")
set(value) {
sharedPrefs.edit().putLong(SMS_MIGRATION_ID_OFFSET, value).commit()
}
}

View File

@@ -44,6 +44,8 @@ public final class SignalStore {
private final ReleaseChannelValues releaseChannelValues;
private final StoryValues storyValues;
private final PlainTextSharedPrefsDataStore plainTextValues;
private static volatile SignalStore instance;
private static @NonNull SignalStore getInstance() {
@@ -85,6 +87,7 @@ public final class SignalStore {
this.notificationProfileValues = new NotificationProfileValues(store);
this.releaseChannelValues = new ReleaseChannelValues(store);
this.storyValues = new StoryValues(store);
this.plainTextValues = new PlainTextSharedPrefsDataStore(ApplicationDependencies.getApplication());
}
public static void onFirstEverAppLaunch() {
@@ -269,6 +272,10 @@ public final class SignalStore {
return new SignalPreferenceDataStore(getStore());
}
public static @NonNull PlainTextSharedPrefsDataStore plaintext() {
return getInstance().plainTextValues;
}
/**
* Ensures any pending writes are finished. Only intended to be called by
* {@link SignalUncaughtExceptionHandler}.