mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Migrate queued jobs during SMS migration.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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}.
|
||||
|
||||
Reference in New Issue
Block a user