Further simplify storage service syncing.

This commit is contained in:
Greyson Parrelli
2021-04-28 10:57:25 -04:00
committed by Alex Hart
parent 1493581a4d
commit cdc7f1565e
18 changed files with 261 additions and 507 deletions

View File

@@ -62,7 +62,7 @@ public final class SignalStore {
registrationValues().onFirstEverAppLaunch();
pinValues().onFirstEverAppLaunch();
remoteConfigValues().onFirstEverAppLaunch();
storageServiceValues().onFirstEverAppLaunch();
storageService().onFirstEverAppLaunch();
uiHints().onFirstEverAppLaunch();
tooltips().onFirstEverAppLaunch();
misc().onFirstEverAppLaunch();
@@ -83,7 +83,7 @@ public final class SignalStore {
keys.addAll(registrationValues().getKeysToIncludeInBackup());
keys.addAll(pinValues().getKeysToIncludeInBackup());
keys.addAll(remoteConfigValues().getKeysToIncludeInBackup());
keys.addAll(storageServiceValues().getKeysToIncludeInBackup());
keys.addAll(storageService().getKeysToIncludeInBackup());
keys.addAll(uiHints().getKeysToIncludeInBackup());
keys.addAll(tooltips().getKeysToIncludeInBackup());
keys.addAll(misc().getKeysToIncludeInBackup());
@@ -124,7 +124,7 @@ public final class SignalStore {
return INSTANCE.remoteConfigValues;
}
public static @NonNull StorageServiceValues storageServiceValues() {
public static @NonNull StorageServiceValues storageService() {
return INSTANCE.storageServiceValues;
}

View File

@@ -1,7 +1,9 @@
package org.thoughtcrime.securesms.keyvalue;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.whispersystems.signalservice.api.storage.SignalStorageManifest;
import org.whispersystems.signalservice.api.storage.StorageKey;
import java.util.Collections;
@@ -11,6 +13,7 @@ public class StorageServiceValues extends SignalStoreValues {
private static final String LAST_SYNC_TIME = "storage.last_sync_time";
private static final String NEEDS_ACCOUNT_RESTORE = "storage.needs_account_restore";
private static final String MANIFEST = "storage.manifest";
StorageServiceValues(@NonNull KeyValueStore store) {
super(store);
@@ -44,4 +47,18 @@ public class StorageServiceValues extends SignalStoreValues {
public void setNeedsAccountRestore(boolean value) {
putBoolean(NEEDS_ACCOUNT_RESTORE, value);
}
public void setManifest(@NonNull SignalStorageManifest manifest) {
putBlob(MANIFEST, manifest.serialize());
}
public @NonNull SignalStorageManifest getManifest() {
byte[] data = getBlob(MANIFEST, null);
if (data != null) {
return SignalStorageManifest.deserialize(data);
} else {
return SignalStorageManifest.EMPTY;
}
}
}