Search in sources :

Example 6 with SignalAccountRecord

use of org.whispersystems.signalservice.api.storage.SignalAccountRecord in project Signal-Android by WhisperSystems.

the class ApplyUnknownFieldsToSelfMigrationJob method performMigration.

@Override
public void performMigration() {
    if (!SignalStore.account().isRegistered() || SignalStore.account().getAci() == null) {
        Log.w(TAG, "Not registered!");
        return;
    }
    Recipient self;
    RecipientRecord settings;
    try {
        self = Recipient.self();
        settings = SignalDatabase.recipients().getRecordForSync(self.getId());
    } catch (RecipientDatabase.MissingRecipientException e) {
        Log.w(TAG, "Unable to find self");
        return;
    }
    if (settings == null || settings.getSyncExtras().getStorageProto() == null) {
        Log.d(TAG, "No unknowns to apply");
        return;
    }
    try {
        StorageId storageId = StorageId.forAccount(self.getStorageServiceId());
        AccountRecord accountRecord = AccountRecord.parseFrom(settings.getSyncExtras().getStorageProto());
        SignalAccountRecord signalAccountRecord = new SignalAccountRecord(storageId, accountRecord);
        Log.d(TAG, "Applying potentially now known unknowns");
        StorageSyncHelper.applyAccountStorageSyncUpdates(context, self, signalAccountRecord, false);
    } catch (InvalidProtocolBufferException e) {
        Log.w(TAG, e);
    }
}
Also used : RecipientDatabase(org.thoughtcrime.securesms.database.RecipientDatabase) SignalAccountRecord(org.whispersystems.signalservice.api.storage.SignalAccountRecord) RecipientRecord(org.thoughtcrime.securesms.database.model.RecipientRecord) SignalAccountRecord(org.whispersystems.signalservice.api.storage.SignalAccountRecord) AccountRecord(org.whispersystems.signalservice.internal.storage.protos.AccountRecord) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Recipient(org.thoughtcrime.securesms.recipients.Recipient) StorageId(org.whispersystems.signalservice.api.storage.StorageId)

Aggregations

SignalAccountRecord (org.whispersystems.signalservice.api.storage.SignalAccountRecord)6 Recipient (org.thoughtcrime.securesms.recipients.Recipient)3 StorageId (org.whispersystems.signalservice.api.storage.StorageId)3 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)2 RecipientRecord (org.thoughtcrime.securesms.database.model.RecipientRecord)2 SignalServiceAccountManager (org.whispersystems.signalservice.api.SignalServiceAccountManager)2 SignalStorageManifest (org.whispersystems.signalservice.api.storage.SignalStorageManifest)2 SignalStorageRecord (org.whispersystems.signalservice.api.storage.SignalStorageRecord)2 StorageKey (org.whispersystems.signalservice.api.storage.StorageKey)2 ContentValues (android.content.ContentValues)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 LinkedList (java.util.LinkedList)1 SQLiteDatabase (net.zetetic.database.sqlcipher.SQLiteDatabase)1 InvalidInputException (org.signal.zkgroup.InvalidInputException)1 GroupMasterKey (org.signal.zkgroup.groups.GroupMasterKey)1 UnknownStorageIdDatabase (org.thoughtcrime.securesms.database.UnknownStorageIdDatabase)1 BadGroupIdException (org.thoughtcrime.securesms.groups.BadGroupIdException)1 JobManager (org.thoughtcrime.securesms.jobmanager.JobManager)1 Entropy (org.thoughtcrime.securesms.payments.Entropy)1 AccountRecordProcessor (org.thoughtcrime.securesms.storage.AccountRecordProcessor)1