mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Include additional settings in backup.
This commit is contained in:
committed by
Greyson Parrelli
parent
1f9afb6c6e
commit
faa19acf81
@@ -54,6 +54,7 @@ public final class AppInitialization {
|
|||||||
ApplicationDependencies.getMegaphoneRepository().onFirstEverAppLaunch();
|
ApplicationDependencies.getMegaphoneRepository().onFirstEverAppLaunch();
|
||||||
SignalStore.onFirstEverAppLaunch();
|
SignalStore.onFirstEverAppLaunch();
|
||||||
SignalStore.onboarding().clearAll();
|
SignalStore.onboarding().clearAll();
|
||||||
|
TextSecurePreferences.onPostBackupRestore(context);
|
||||||
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.ZOZO.getPackId(), BlessedPacks.ZOZO.getPackKey(), false));
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.ZOZO.getPackId(), BlessedPacks.ZOZO.getPackKey(), false));
|
||||||
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.BANDIT.getPackId(), BlessedPacks.BANDIT.getPackKey(), false));
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.BANDIT.getPackId(), BlessedPacks.BANDIT.getPackKey(), false));
|
||||||
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.DAY_BY_DAY.getPackId(), BlessedPacks.DAY_BY_DAY.getPackKey(), false));
|
ApplicationDependencies.getJobManager().add(StickerPackDownloadJob.forInstall(BlessedPacks.DAY_BY_DAY.getPackId(), BlessedPacks.DAY_BY_DAY.getPackKey(), false));
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
|||||||
import org.thoughtcrime.securesms.crypto.ModernDecryptingPartInputStream;
|
import org.thoughtcrime.securesms.crypto.ModernDecryptingPartInputStream;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
import org.thoughtcrime.securesms.database.GroupReceiptDatabase;
|
import org.thoughtcrime.securesms.database.GroupReceiptDatabase;
|
||||||
|
import org.thoughtcrime.securesms.database.KeyValueDatabase;
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.MmsSmsColumns;
|
import org.thoughtcrime.securesms.database.MmsSmsColumns;
|
||||||
import org.thoughtcrime.securesms.database.OneTimePreKeyDatabase;
|
import org.thoughtcrime.securesms.database.OneTimePreKeyDatabase;
|
||||||
@@ -33,6 +34,9 @@ import org.thoughtcrime.securesms.database.SessionDatabase;
|
|||||||
import org.thoughtcrime.securesms.database.SignedPreKeyDatabase;
|
import org.thoughtcrime.securesms.database.SignedPreKeyDatabase;
|
||||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||||
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
|
import org.thoughtcrime.securesms.keyvalue.KeyValueDataSet;
|
||||||
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||||
import org.thoughtcrime.securesms.util.SetUtil;
|
import org.thoughtcrime.securesms.util.SetUtil;
|
||||||
import org.thoughtcrime.securesms.util.Stopwatch;
|
import org.thoughtcrime.securesms.util.Stopwatch;
|
||||||
@@ -64,7 +68,6 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
|
|
||||||
public class FullBackupExporter extends FullBackupBase {
|
public class FullBackupExporter extends FullBackupBase {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static final String TAG = FullBackupExporter.class.getSimpleName();
|
private static final String TAG = FullBackupExporter.class.getSimpleName();
|
||||||
|
|
||||||
private static final Set<String> BLACKLISTED_TABLES = SetUtil.newHashSet(
|
private static final Set<String> BLACKLISTED_TABLES = SetUtil.newHashSet(
|
||||||
@@ -165,6 +168,10 @@ public class FullBackupExporter extends FullBackupBase {
|
|||||||
|
|
||||||
stopwatch.split("prefs");
|
stopwatch.split("prefs");
|
||||||
|
|
||||||
|
count = exportKeyValues(outputStream, SignalStore.getKeysToIncludeInBackup(), count, cancellationSignal);
|
||||||
|
|
||||||
|
stopwatch.split("key_values");
|
||||||
|
|
||||||
for (AvatarHelper.Avatar avatar : AvatarHelper.getAvatars(context)) {
|
for (AvatarHelper.Avatar avatar : AvatarHelper.getAvatars(context)) {
|
||||||
throwIfCanceled(cancellationSignal);
|
throwIfCanceled(cancellationSignal);
|
||||||
if (avatar != null) {
|
if (avatar != null) {
|
||||||
@@ -351,6 +358,46 @@ public class FullBackupExporter extends FullBackupBase {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int exportKeyValues(@NonNull BackupFrameOutputStream outputStream,
|
||||||
|
@NonNull List<String> keysToIncludeInBackup,
|
||||||
|
int count,
|
||||||
|
BackupCancellationSignal cancellationSignal) throws IOException
|
||||||
|
{
|
||||||
|
KeyValueDataSet dataSet = KeyValueDatabase.getInstance(ApplicationDependencies.getApplication())
|
||||||
|
.getDataSet();
|
||||||
|
|
||||||
|
for (String key : keysToIncludeInBackup) {
|
||||||
|
throwIfCanceled(cancellationSignal);
|
||||||
|
if (!dataSet.containsKey(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BackupProtos.KeyValue.Builder builder = BackupProtos.KeyValue.newBuilder()
|
||||||
|
.setKey(key);
|
||||||
|
|
||||||
|
Class<?> type = dataSet.getType(key);
|
||||||
|
if (type == byte[].class) {
|
||||||
|
builder.setBlobValue(ByteString.copyFrom(dataSet.getBlob(key, null)));
|
||||||
|
} else if (type == Boolean.class) {
|
||||||
|
builder.setBooleanValue(dataSet.getBoolean(key, false));
|
||||||
|
} else if (type == Float.class) {
|
||||||
|
builder.setFloatValue(dataSet.getFloat(key, 0));
|
||||||
|
} else if (type == Integer.class) {
|
||||||
|
builder.setIntegerValue(dataSet.getInteger(key, 0));
|
||||||
|
} else if (type == Long.class) {
|
||||||
|
builder.setLongValue(dataSet.getLong(key, 0));
|
||||||
|
} else if (type == String.class) {
|
||||||
|
builder.setStringValue(dataSet.getString(key, null));
|
||||||
|
} else {
|
||||||
|
throw new AssertionError("Unknown type: " + type);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventBus.getDefault().post(new BackupEvent(BackupEvent.Type.PROGRESS, ++count));
|
||||||
|
outputStream.write(builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isNonExpiringMmsMessage(@NonNull Cursor cursor) {
|
private static boolean isNonExpiringMmsMessage(@NonNull Cursor cursor) {
|
||||||
return cursor.getInt(cursor.getColumnIndexOrThrow(MmsSmsColumns.EXPIRES_IN)) <= 0 &&
|
return cursor.getInt(cursor.getColumnIndexOrThrow(MmsSmsColumns.EXPIRES_IN)) <= 0 &&
|
||||||
cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.VIEW_ONCE)) <= 0;
|
cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.VIEW_ONCE)) <= 0;
|
||||||
@@ -422,6 +469,10 @@ public class FullBackupExporter extends FullBackupBase {
|
|||||||
write(outputStream, BackupProtos.BackupFrame.newBuilder().setPreference(preference).build());
|
write(outputStream, BackupProtos.BackupFrame.newBuilder().setPreference(preference).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void write(BackupProtos.KeyValue keyValue) throws IOException {
|
||||||
|
write(outputStream, BackupProtos.BackupFrame.newBuilder().setKeyValue(keyValue).build());
|
||||||
|
}
|
||||||
|
|
||||||
public void write(BackupProtos.SqlStatement statement) throws IOException {
|
public void write(BackupProtos.SqlStatement statement) throws IOException {
|
||||||
write(outputStream, BackupProtos.BackupFrame.newBuilder().setStatement(statement).build());
|
write(outputStream, BackupProtos.BackupFrame.newBuilder().setStatement(statement).build());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ import org.thoughtcrime.securesms.backup.BackupProtos.Sticker;
|
|||||||
import org.thoughtcrime.securesms.crypto.AttachmentSecret;
|
import org.thoughtcrime.securesms.crypto.AttachmentSecret;
|
||||||
import org.thoughtcrime.securesms.crypto.ModernEncryptingPartOutputStream;
|
import org.thoughtcrime.securesms.crypto.ModernEncryptingPartOutputStream;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
|
import org.thoughtcrime.securesms.database.KeyValueDatabase;
|
||||||
import org.thoughtcrime.securesms.database.SearchDatabase;
|
import org.thoughtcrime.securesms.database.SearchDatabase;
|
||||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||||
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
|
import org.thoughtcrime.securesms.keyvalue.KeyValueDataSet;
|
||||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
import org.thoughtcrime.securesms.util.BackupUtil;
|
import org.thoughtcrime.securesms.util.BackupUtil;
|
||||||
@@ -45,6 +48,7 @@ import java.security.InvalidAlgorithmParameterException;
|
|||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -78,10 +82,12 @@ public class FullBackupImporter extends FullBackupBase {
|
|||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
SQLiteDatabase keyValueDatabase = KeyValueDatabase.getInstance(ApplicationDependencies.getApplication()).getSqlCipherDatabase();
|
||||||
try {
|
try {
|
||||||
BackupRecordInputStream inputStream = new BackupRecordInputStream(is, passphrase);
|
BackupRecordInputStream inputStream = new BackupRecordInputStream(is, passphrase);
|
||||||
|
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
|
keyValueDatabase.beginTransaction();
|
||||||
|
|
||||||
dropAllTables(db);
|
dropAllTables(db);
|
||||||
|
|
||||||
@@ -97,12 +103,15 @@ public class FullBackupImporter extends FullBackupBase {
|
|||||||
else if (frame.hasAttachment()) processAttachment(context, attachmentSecret, db, frame.getAttachment(), inputStream);
|
else if (frame.hasAttachment()) processAttachment(context, attachmentSecret, db, frame.getAttachment(), inputStream);
|
||||||
else if (frame.hasSticker()) processSticker(context, attachmentSecret, db, frame.getSticker(), inputStream);
|
else if (frame.hasSticker()) processSticker(context, attachmentSecret, db, frame.getSticker(), inputStream);
|
||||||
else if (frame.hasAvatar()) processAvatar(context, db, frame.getAvatar(), inputStream);
|
else if (frame.hasAvatar()) processAvatar(context, db, frame.getAvatar(), inputStream);
|
||||||
|
else if (frame.hasKeyValue()) processKeyValue(frame.getKeyValue());
|
||||||
else count--;
|
else count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
|
keyValueDatabase.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
|
keyValueDatabase.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventBus.getDefault().post(new BackupEvent(BackupEvent.Type.FINISHED, count));
|
EventBus.getDefault().post(new BackupEvent(BackupEvent.Type.FINISHED, count));
|
||||||
@@ -213,6 +222,29 @@ public class FullBackupImporter extends FullBackupBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void processKeyValue(BackupProtos.KeyValue keyValue) {
|
||||||
|
KeyValueDataSet dataSet = new KeyValueDataSet();
|
||||||
|
|
||||||
|
if (keyValue.hasBlobValue()) {
|
||||||
|
dataSet.putBlob(keyValue.getKey(), keyValue.getBlobValue().toByteArray());
|
||||||
|
} else if (keyValue.hasBooleanValue()) {
|
||||||
|
dataSet.putBoolean(keyValue.getKey(), keyValue.getBooleanValue());
|
||||||
|
} else if (keyValue.hasFloatValue()) {
|
||||||
|
dataSet.putFloat(keyValue.getKey(), keyValue.getFloatValue());
|
||||||
|
} else if (keyValue.hasIntegerValue()) {
|
||||||
|
dataSet.putInteger(keyValue.getKey(), keyValue.getIntegerValue());
|
||||||
|
} else if (keyValue.hasLongValue()) {
|
||||||
|
dataSet.putLong(keyValue.getKey(), keyValue.getLongValue());
|
||||||
|
} else if (keyValue.hasStringValue()) {
|
||||||
|
dataSet.putString(keyValue.getKey(), keyValue.getStringValue());
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "Unknown KeyValue backup value, skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyValueDatabase.getInstance(ApplicationDependencies.getApplication()).writeDataSet(dataSet, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("ApplySharedPref")
|
@SuppressLint("ApplySharedPref")
|
||||||
private static void processPreference(@NonNull Context context, SharedPreference preference) {
|
private static void processPreference(@NonNull Context context, SharedPreference preference) {
|
||||||
SharedPreferences preferences = context.getSharedPreferences(preference.getFile(), 0);
|
SharedPreferences preferences = context.getSharedPreferences(preference.getFile(), 0);
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class CertificateValues extends SignalStoreValues {
|
public final class CertificateValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String UD_CERTIFICATE_UUID_AND_E164 = "certificate.uuidAndE164";
|
private static final String UD_CERTIFICATE_UUID_AND_E164 = "certificate.uuidAndE164";
|
||||||
@@ -17,6 +20,11 @@ public final class CertificateValues extends SignalStoreValues {
|
|||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
public void setUnidentifiedAccessCertificate(@NonNull CertificateType certificateType,
|
public void setUnidentifiedAccessCertificate(@NonNull CertificateType certificateType,
|
||||||
@Nullable byte[] certificate)
|
@Nullable byte[] certificate)
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiUtil;
|
import org.thoughtcrime.securesms.components.emoji.EmojiUtil;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class EmojiValues extends SignalStoreValues {
|
public class EmojiValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String PREFIX = "emojiPref__";
|
private static final String PREFIX = "emojiPref__";
|
||||||
@@ -17,6 +20,11 @@ public class EmojiValues extends SignalStoreValues {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public void setPreferredVariation(@NonNull String emoji) {
|
public void setPreferredVariation(@NonNull String emoji) {
|
||||||
String canonical = EmojiUtil.getCanonicalRepresentation(emoji);
|
String canonical = EmojiUtil.getCanonicalRepresentation(emoji);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package org.thoughtcrime.securesms.keyvalue;
|
package org.thoughtcrime.securesms.keyvalue;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class InternalValues extends SignalStoreValues {
|
public final class InternalValues extends SignalStoreValues {
|
||||||
|
|
||||||
public static final String GV2_DO_NOT_CREATE_GV2 = "internal.gv2.do_not_create_gv2";
|
public static final String GV2_DO_NOT_CREATE_GV2 = "internal.gv2.do_not_create_gv2";
|
||||||
@@ -21,6 +26,11 @@ public final class InternalValues extends SignalStoreValues {
|
|||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not attempt to create GV2 groups, i.e. will force creation of GV1 or MMS groups.
|
* Do not attempt to create GV2 groups, i.e. will force creation of GV1 or MMS groups.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class KbsValues extends SignalStoreValues {
|
public final class KbsValues extends SignalStoreValues {
|
||||||
|
|
||||||
@@ -30,6 +32,11 @@ public final class KbsValues extends SignalStoreValues {
|
|||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deliberately does not clear the {@link #MASTER_KEY}.
|
* Deliberately does not clear the {@link #MASTER_KEY}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ public class KeyValueDataSet implements KeyValueReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean containsKey(@NonNull String key) {
|
@Override
|
||||||
|
public boolean containsKey(@NonNull String key) {
|
||||||
return values.containsKey(key);
|
return values.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ interface KeyValueReader {
|
|||||||
int getInteger(@NonNull String key, int defaultValue);
|
int getInteger(@NonNull String key, int defaultValue);
|
||||||
long getLong(@NonNull String key, long defaultValue);
|
long getLong(@NonNull String key, long defaultValue);
|
||||||
String getString(@NonNull String key, String defaultValue);
|
String getString(@NonNull String key, String defaultValue);
|
||||||
|
boolean containsKey(@NonNull String key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,13 @@ public final class KeyValueStore implements KeyValueReader {
|
|||||||
return dataSet.getString(key, defaultValue);
|
return dataSet.getString(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AnyThread
|
||||||
|
@Override
|
||||||
|
public synchronized boolean containsKey(@NonNull String key) {
|
||||||
|
initializeIfNecessary();
|
||||||
|
return dataSet.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A writer that allows writing and removing multiple entries in a single atomic
|
* @return A writer that allows writing and removing multiple entries in a single atomic
|
||||||
* transaction.
|
* transaction.
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package org.thoughtcrime.securesms.keyvalue;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class MiscellaneousValues extends SignalStoreValues {
|
public final class MiscellaneousValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String LAST_PREKEY_REFRESH_TIME = "last_prekey_refresh_time";
|
private static final String LAST_PREKEY_REFRESH_TIME = "last_prekey_refresh_time";
|
||||||
@@ -21,6 +24,11 @@ public final class MiscellaneousValues extends SignalStoreValues {
|
|||||||
putLong(MESSAGE_REQUEST_ENABLE_TIME, 0);
|
putLong(MESSAGE_REQUEST_ENABLE_TIME, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public long getLastPrekeyRefreshTime() {
|
public long getLastPrekeyRefreshTime() {
|
||||||
return getLong(LAST_PREKEY_REFRESH_TIME, 0);
|
return getLong(LAST_PREKEY_REFRESH_TIME, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import androidx.annotation.NonNull;
|
|||||||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
|
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class OnboardingValues extends SignalStoreValues {
|
public final class OnboardingValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String SHOW_NEW_GROUP = "onboarding.new_group";
|
private static final String SHOW_NEW_GROUP = "onboarding.new_group";
|
||||||
@@ -24,6 +27,11 @@ public final class OnboardingValues extends SignalStoreValues {
|
|||||||
putBoolean(SHOW_SMS, true);
|
putBoolean(SHOW_SMS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public void clearAll() {
|
public void clearAll() {
|
||||||
setShowNewGroup(false);
|
setShowNewGroup(false);
|
||||||
setShowInviteFriends(false);
|
setShowInviteFriends(false);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.thoughtcrime.securesms.util.FeatureFlags;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class PhoneNumberPrivacyValues extends SignalStoreValues {
|
public final class PhoneNumberPrivacyValues extends SignalStoreValues {
|
||||||
|
|
||||||
@@ -29,6 +30,11 @@ public final class PhoneNumberPrivacyValues extends SignalStoreValues {
|
|||||||
// .apply();
|
// .apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Arrays.asList(SHARING_MODE, LISTING_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
public @NonNull PhoneNumberSharingMode getPhoneNumberSharingMode() {
|
public @NonNull PhoneNumberSharingMode getPhoneNumberSharingMode() {
|
||||||
if (!FeatureFlags.phoneNumberPrivacy()) return PhoneNumberSharingMode.EVERYONE;
|
if (!FeatureFlags.phoneNumberPrivacy()) return PhoneNumberSharingMode.EVERYONE;
|
||||||
return PhoneNumberSharingMode.values()[getInteger(SHARING_MODE, PhoneNumberSharingMode.EVERYONE.ordinal())];
|
return PhoneNumberSharingMode.values()[getInteger(SHARING_MODE, PhoneNumberSharingMode.EVERYONE.ordinal())];
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import org.thoughtcrime.securesms.lock.SignalPinReminders;
|
|||||||
import org.thoughtcrime.securesms.lock.v2.PinKeyboardType;
|
import org.thoughtcrime.securesms.lock.v2.PinKeyboardType;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifically handles just the UI/UX state around PINs. For actual keys, see {@link KbsValues}.
|
* Specifically handles just the UI/UX state around PINs. For actual keys, see {@link KbsValues}.
|
||||||
*/
|
*/
|
||||||
@@ -30,6 +33,11 @@ public final class PinValues extends SignalStoreValues {
|
|||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public void onEntrySuccess(@NonNull String pin) {
|
public void onEntrySuccess(@NonNull String pin) {
|
||||||
long nextInterval = SignalPinReminders.getNextInterval(getCurrentInterval());
|
long nextInterval = SignalPinReminders.getNextInterval(getCurrentInterval());
|
||||||
Log.i(TAG, "onEntrySuccess() nextInterval: " + nextInterval);
|
Log.i(TAG, "onEntrySuccess() nextInterval: " + nextInterval);
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import androidx.annotation.Nullable;
|
|||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.signalservice.internal.configuration.SignalProxy;
|
import org.whispersystems.signalservice.internal.configuration.SignalProxy;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class ProxyValues extends SignalStoreValues {
|
public final class ProxyValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String KEY_PROXY_ENABLED = "proxy.enabled";
|
private static final String KEY_PROXY_ENABLED = "proxy.enabled";
|
||||||
@@ -20,6 +23,11 @@ public final class ProxyValues extends SignalStoreValues {
|
|||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Arrays.asList(KEY_PROXY_ENABLED, KEY_HOST, KEY_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
public void enableProxy(@NonNull SignalProxy proxy) {
|
public void enableProxy(@NonNull SignalProxy proxy) {
|
||||||
if (Util.isEmpty(proxy.getHost())) {
|
if (Util.isEmpty(proxy.getHost())) {
|
||||||
throw new IllegalArgumentException("Empty host!");
|
throw new IllegalArgumentException("Empty host!");
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package org.thoughtcrime.securesms.keyvalue;
|
|||||||
import androidx.annotation.CheckResult;
|
import androidx.annotation.CheckResult;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class RegistrationValues extends SignalStoreValues {
|
public final class RegistrationValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String REGISTRATION_COMPLETE = "registration.complete";
|
private static final String REGISTRATION_COMPLETE = "registration.complete";
|
||||||
@@ -19,6 +22,11 @@ public final class RegistrationValues extends SignalStoreValues {
|
|||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void clearRegistrationComplete() {
|
public synchronized void clearRegistrationComplete() {
|
||||||
onFirstEverAppLaunch();
|
onFirstEverAppLaunch();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import org.signal.core.util.logging.Log;
|
import org.signal.core.util.logging.Log;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class RemoteConfigValues extends SignalStoreValues {
|
public final class RemoteConfigValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String TAG = Log.tag(RemoteConfigValues.class);
|
private static final String TAG = Log.tag(RemoteConfigValues.class);
|
||||||
@@ -20,6 +23,11 @@ public final class RemoteConfigValues extends SignalStoreValues {
|
|||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public String getCurrentConfig() {
|
public String getCurrentConfig() {
|
||||||
return getString(CURRENT_CONFIG, null);
|
return getString(CURRENT_CONFIG, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import androidx.annotation.Nullable;
|
|||||||
|
|
||||||
import org.thoughtcrime.securesms.webrtc.CallBandwidthMode;
|
import org.thoughtcrime.securesms.webrtc.CallBandwidthMode;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class SettingsValues extends SignalStoreValues {
|
public final class SettingsValues extends SignalStoreValues {
|
||||||
|
|
||||||
public static final String LINK_PREVIEWS = "settings.link_previews";
|
public static final String LINK_PREVIEWS = "settings.link_previews";
|
||||||
@@ -29,9 +32,21 @@ public final class SettingsValues extends SignalStoreValues {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
getStore().beginWrite()
|
if (!getStore().containsKey(LINK_PREVIEWS)) {
|
||||||
.putBoolean(LINK_PREVIEWS, true)
|
getStore().beginWrite()
|
||||||
.apply();
|
.putBoolean(LINK_PREVIEWS, true)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Arrays.asList(LINK_PREVIEWS,
|
||||||
|
KEEP_MESSAGES_DURATION,
|
||||||
|
PREFER_SYSTEM_CONTACT_PHOTOS,
|
||||||
|
CALL_BANDWIDTH_MODE,
|
||||||
|
THREAD_TRIM_LENGTH,
|
||||||
|
THREAD_TRIM_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLinkPreviewsEnabled() {
|
public boolean isLinkPreviewsEnabled() {
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import androidx.preference.PreferenceDataStore;
|
|||||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||||
import org.thoughtcrime.securesms.util.SignalUncaughtExceptionHandler;
|
import org.thoughtcrime.securesms.util.SignalUncaughtExceptionHandler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple, encrypted key-value store.
|
* Simple, encrypted key-value store.
|
||||||
*/
|
*/
|
||||||
@@ -62,6 +65,7 @@ public final class SignalStore {
|
|||||||
tooltips().onFirstEverAppLaunch();
|
tooltips().onFirstEverAppLaunch();
|
||||||
misc().onFirstEverAppLaunch();
|
misc().onFirstEverAppLaunch();
|
||||||
internalValues().onFirstEverAppLaunch();
|
internalValues().onFirstEverAppLaunch();
|
||||||
|
emojiValues().onFirstEverAppLaunch();
|
||||||
settings().onFirstEverAppLaunch();
|
settings().onFirstEverAppLaunch();
|
||||||
certificateValues().onFirstEverAppLaunch();
|
certificateValues().onFirstEverAppLaunch();
|
||||||
phoneNumberPrivacy().onFirstEverAppLaunch();
|
phoneNumberPrivacy().onFirstEverAppLaunch();
|
||||||
@@ -70,6 +74,27 @@ public final class SignalStore {
|
|||||||
proxy().onFirstEverAppLaunch();
|
proxy().onFirstEverAppLaunch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> getKeysToIncludeInBackup() {
|
||||||
|
List<String> keys = new ArrayList<>();
|
||||||
|
keys.addAll(kbsValues().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(registrationValues().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(pinValues().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(remoteConfigValues().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(storageServiceValues().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(uiHints().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(tooltips().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(misc().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(internalValues().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(emojiValues().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(settings().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(certificateValues().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(phoneNumberPrivacy().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(onboarding().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(wallpaper().getKeysToIncludeInBackup());
|
||||||
|
keys.addAll(proxy().getKeysToIncludeInBackup());
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forces the store to re-fetch all of it's data from the database.
|
* Forces the store to re-fetch all of it's data from the database.
|
||||||
* Should only be used for testing!
|
* Should only be used for testing!
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package org.thoughtcrime.securesms.keyvalue;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
abstract class SignalStoreValues {
|
abstract class SignalStoreValues {
|
||||||
|
|
||||||
private final KeyValueStore store;
|
private final KeyValueStore store;
|
||||||
@@ -16,6 +18,8 @@ abstract class SignalStoreValues {
|
|||||||
|
|
||||||
abstract void onFirstEverAppLaunch();
|
abstract void onFirstEverAppLaunch();
|
||||||
|
|
||||||
|
abstract @NonNull List<String> getKeysToIncludeInBackup();
|
||||||
|
|
||||||
String getString(String key, String defaultValue) {
|
String getString(String key, String defaultValue) {
|
||||||
return store.getString(key, defaultValue);
|
return store.getString(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import org.whispersystems.signalservice.api.storage.StorageKey;
|
import org.whispersystems.signalservice.api.storage.StorageKey;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class StorageServiceValues extends SignalStoreValues {
|
public class StorageServiceValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String LAST_SYNC_TIME = "storage.last_sync_time";
|
private static final String LAST_SYNC_TIME = "storage.last_sync_time";
|
||||||
@@ -17,6 +20,11 @@ public class StorageServiceValues extends SignalStoreValues {
|
|||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized StorageKey getOrCreateStorageKey() {
|
public synchronized StorageKey getOrCreateStorageKey() {
|
||||||
return SignalStore.kbsValues().getOrCreateMasterKey().deriveStorageServiceKey();
|
return SignalStore.kbsValues().getOrCreateMasterKey().deriveStorageServiceKey();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package org.thoughtcrime.securesms.keyvalue;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TooltipValues extends SignalStoreValues {
|
public class TooltipValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final int GROUP_CALLING_MAX_TOOLTIP_DISPLAY_COUNT = 3;
|
private static final int GROUP_CALLING_MAX_TOOLTIP_DISPLAY_COUNT = 3;
|
||||||
@@ -19,6 +22,11 @@ public class TooltipValues extends SignalStoreValues {
|
|||||||
public void onFirstEverAppLaunch() {
|
public void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasSeenBlurHudIconTooltip() {
|
public boolean hasSeenBlurHudIconTooltip() {
|
||||||
return getBoolean(BLUR_HUD_ICON, false);
|
return getBoolean(BLUR_HUD_ICON, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package org.thoughtcrime.securesms.keyvalue;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class UiHints extends SignalStoreValues {
|
public class UiHints extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String HAS_SEEN_GROUP_SETTINGS_MENU_TOAST = "uihints.has_seen_group_settings_menu_toast";
|
private static final String HAS_SEEN_GROUP_SETTINGS_MENU_TOAST = "uihints.has_seen_group_settings_menu_toast";
|
||||||
@@ -16,6 +19,11 @@ public class UiHints extends SignalStoreValues {
|
|||||||
markHasSeenGroupSettingsMenuToast();
|
markHasSeenGroupSettingsMenuToast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public void markHasSeenGroupSettingsMenuToast() {
|
public void markHasSeenGroupSettingsMenuToast() {
|
||||||
putBoolean(HAS_SEEN_GROUP_SETTINGS_MENU_TOAST, true);
|
putBoolean(HAS_SEEN_GROUP_SETTINGS_MENU_TOAST, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import org.thoughtcrime.securesms.wallpaper.ChatWallpaper;
|
|||||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaperFactory;
|
import org.thoughtcrime.securesms.wallpaper.ChatWallpaperFactory;
|
||||||
import org.thoughtcrime.securesms.wallpaper.WallpaperStorage;
|
import org.thoughtcrime.securesms.wallpaper.WallpaperStorage;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class WallpaperValues extends SignalStoreValues {
|
public final class WallpaperValues extends SignalStoreValues {
|
||||||
|
|
||||||
private static final String TAG = Log.tag(WallpaperValues.class);
|
private static final String TAG = Log.tag(WallpaperValues.class);
|
||||||
@@ -29,6 +32,11 @@ public final class WallpaperValues extends SignalStoreValues {
|
|||||||
void onFirstEverAppLaunch() {
|
void onFirstEverAppLaunch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonNull List<String> getKeysToIncludeInBackup() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
public void setWallpaper(@NonNull Context context, @Nullable ChatWallpaper wallpaper) {
|
public void setWallpaper(@NonNull Context context, @Nullable ChatWallpaper wallpaper) {
|
||||||
Wallpaper currentWallpaper = getCurrentWallpaper();
|
Wallpaper currentWallpaper = getCurrentWallpaper();
|
||||||
Uri currentUri = null;
|
Uri currentUri = null;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.backup.BackupProtos;
|
|||||||
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
||||||
import org.thoughtcrime.securesms.keyvalue.SettingsValues;
|
import org.thoughtcrime.securesms.keyvalue.SettingsValues;
|
||||||
import org.thoughtcrime.securesms.lock.RegistrationLockReminders;
|
import org.thoughtcrime.securesms.lock.RegistrationLockReminders;
|
||||||
|
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||||
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference;
|
||||||
import org.whispersystems.libsignal.util.Medium;
|
import org.whispersystems.libsignal.util.Medium;
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
@@ -280,6 +281,12 @@ public class TextSecurePreferences {
|
|||||||
return backupProtos;
|
return backupProtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onPostBackupRestore(@NonNull Context context) {
|
||||||
|
if (NotificationChannels.supported() && PreferenceManager.getDefaultSharedPreferences(context).contains(VIBRATE_PREF)) {
|
||||||
|
NotificationChannels.updateMessageVibrate(context, isNotificationVibrateEnabled(context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isScreenLockEnabled(@NonNull Context context) {
|
public static boolean isScreenLockEnabled(@NonNull Context context) {
|
||||||
return getBooleanPreference(context, SCREEN_LOCK, false);
|
return getBooleanPreference(context, SCREEN_LOCK, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,16 @@ message Header {
|
|||||||
optional bytes salt = 2;
|
optional bytes salt = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message KeyValue {
|
||||||
|
optional string key = 1;
|
||||||
|
optional bytes blobValue = 2;
|
||||||
|
optional bool booleanValue = 3;
|
||||||
|
optional float floatValue = 4;
|
||||||
|
optional int32 integerValue = 5;
|
||||||
|
optional int64 longValue = 6;
|
||||||
|
optional string stringValue = 7;
|
||||||
|
}
|
||||||
|
|
||||||
message BackupFrame {
|
message BackupFrame {
|
||||||
optional Header header = 1;
|
optional Header header = 1;
|
||||||
optional SqlStatement statement = 2;
|
optional SqlStatement statement = 2;
|
||||||
@@ -68,4 +78,5 @@ message BackupFrame {
|
|||||||
optional bool end = 6;
|
optional bool end = 6;
|
||||||
optional Avatar avatar = 7;
|
optional Avatar avatar = 7;
|
||||||
optional Sticker sticker = 8;
|
optional Sticker sticker = 8;
|
||||||
|
optional KeyValue keyValue = 9;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user