Search in sources :

Example 1 with AccountRecord

use of org.whispersystems.signalservice.internal.storage.protos.AccountRecord 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

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)1 RecipientRecord (org.thoughtcrime.securesms.database.model.RecipientRecord)1 Recipient (org.thoughtcrime.securesms.recipients.Recipient)1 SignalAccountRecord (org.whispersystems.signalservice.api.storage.SignalAccountRecord)1 StorageId (org.whispersystems.signalservice.api.storage.StorageId)1 AccountRecord (org.whispersystems.signalservice.internal.storage.protos.AccountRecord)1