Search in sources :

Example 11 with StorageSyncJob

use of org.thoughtcrime.securesms.jobs.StorageSyncJob in project Signal-Android by signalapp.

the class PinRestoreRepository method submitPin.

void submitPin(@NonNull String pin, @NonNull TokenData tokenData, @NonNull Callback<PinResultData> callback) {
    executor.execute(() -> {
        try {
            Stopwatch stopwatch = new Stopwatch("PinSubmission");
            KbsPinData kbsData = KbsRepository.restoreMasterKey(pin, tokenData.getEnclave(), tokenData.getBasicAuth(), tokenData.getTokenResponse());
            PinState.onSignalPinRestore(ApplicationDependencies.getApplication(), Objects.requireNonNull(kbsData), pin);
            stopwatch.split("MasterKey");
            ApplicationDependencies.getJobManager().runSynchronously(new StorageAccountRestoreJob(), StorageAccountRestoreJob.LIFESPAN);
            stopwatch.split("AccountRestore");
            ApplicationDependencies.getJobManager().runSynchronously(new StorageSyncJob(), TimeUnit.SECONDS.toMillis(10));
            stopwatch.split("ContactRestore");
            stopwatch.stop(TAG);
            callback.onComplete(new PinResultData(PinResult.SUCCESS, tokenData));
        } catch (IOException e) {
            callback.onComplete(new PinResultData(PinResult.NETWORK_ERROR, tokenData));
        } catch (KeyBackupSystemNoDataException e) {
            callback.onComplete(new PinResultData(PinResult.LOCKED, tokenData));
        } catch (KeyBackupSystemWrongPinException e) {
            callback.onComplete(new PinResultData(PinResult.INCORRECT, TokenData.withResponse(tokenData, e.getTokenResponse())));
        }
    });
}
Also used : StorageSyncJob(org.thoughtcrime.securesms.jobs.StorageSyncJob) StorageAccountRestoreJob(org.thoughtcrime.securesms.jobs.StorageAccountRestoreJob) Stopwatch(org.thoughtcrime.securesms.util.Stopwatch) KbsPinData(org.whispersystems.signalservice.api.KbsPinData) IOException(java.io.IOException) KeyBackupSystemNoDataException(org.whispersystems.signalservice.api.KeyBackupSystemNoDataException)

Example 12 with StorageSyncJob

use of org.thoughtcrime.securesms.jobs.StorageSyncJob in project Signal-Android by signalapp.

the class StorageServiceMigrationJob method performMigration.

@Override
public void performMigration() {
    if (SignalStore.account().getAci() == null) {
        Log.w(TAG, "Self not yet available.");
        return;
    }
    SignalDatabase.recipients().markNeedsSync(Recipient.self().getId());
    JobManager jobManager = ApplicationDependencies.getJobManager();
    if (TextSecurePreferences.isMultiDevice(context)) {
        Log.i(TAG, "Multi-device.");
        jobManager.startChain(new StorageSyncJob()).then(new MultiDeviceKeysUpdateJob()).enqueue();
    } else {
        Log.i(TAG, "Single-device.");
        jobManager.add(new StorageSyncJob());
    }
}
Also used : StorageSyncJob(org.thoughtcrime.securesms.jobs.StorageSyncJob) MultiDeviceKeysUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceKeysUpdateJob) JobManager(org.thoughtcrime.securesms.jobmanager.JobManager)

Aggregations

StorageSyncJob (org.thoughtcrime.securesms.jobs.StorageSyncJob)12 Stopwatch (org.thoughtcrime.securesms.util.Stopwatch)6 IOException (java.io.IOException)4 StorageAccountRestoreJob (org.thoughtcrime.securesms.jobs.StorageAccountRestoreJob)4 WorkerThread (androidx.annotation.WorkerThread)2 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)2 RegisteredState (org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState)2 JobManager (org.thoughtcrime.securesms.jobmanager.JobManager)2 DirectoryRefreshJob (org.thoughtcrime.securesms.jobs.DirectoryRefreshJob)2 MultiDeviceContactUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob)2 MultiDeviceKeysUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceKeysUpdateJob)2 KbsPinData (org.whispersystems.signalservice.api.KbsPinData)2 KeyBackupSystemNoDataException (org.whispersystems.signalservice.api.KeyBackupSystemNoDataException)2 ACI (org.whispersystems.signalservice.api.push.ACI)2