Search in sources :

Example 6 with StorageSyncJob

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

the class AccountRecordMigrationJob method performMigration.

@Override
public void performMigration() {
    if (!SignalStore.account().isRegistered() || SignalStore.account().getAci() == null) {
        Log.w(TAG, "Not registered!");
        return;
    }
    SignalDatabase.recipients().markNeedsSync(Recipient.self().getId());
    ApplicationDependencies.getJobManager().add(new StorageSyncJob());
}
Also used : StorageSyncJob(org.thoughtcrime.securesms.jobs.StorageSyncJob)

Example 7 with StorageSyncJob

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

the class RegistrationLockFragment method handleSuccessfulPinEntry.

@Override
protected void handleSuccessfulPinEntry(@NonNull String pin) {
    SignalStore.pinValues().setKeyboardType(getPinEntryKeyboardType());
    SimpleTask.run(() -> {
        SignalStore.onboarding().clearAll();
        Stopwatch stopwatch = new Stopwatch("RegistrationLockRestore");
        ApplicationDependencies.getJobManager().runSynchronously(new StorageAccountRestoreJob(), StorageAccountRestoreJob.LIFESPAN);
        stopwatch.split("AccountRestore");
        ApplicationDependencies.getJobManager().runSynchronously(new StorageSyncJob(), TimeUnit.SECONDS.toMillis(10));
        stopwatch.split("ContactRestore");
        try {
            FeatureFlags.refreshSync();
        } catch (IOException e) {
            Log.w(TAG, "Failed to refresh flags.", e);
        }
        stopwatch.split("FeatureFlags");
        stopwatch.stop(TAG);
        return null;
    }, none -> {
        cancelSpinning(pinButton);
        SafeNavigation.safeNavigate(Navigation.findNavController(requireView()), RegistrationLockFragmentDirections.actionSuccessfulRegistration());
    });
}
Also used : StorageSyncJob(org.thoughtcrime.securesms.jobs.StorageSyncJob) StorageAccountRestoreJob(org.thoughtcrime.securesms.jobs.StorageAccountRestoreJob) Stopwatch(org.thoughtcrime.securesms.util.Stopwatch) IOException(java.io.IOException)

Example 8 with StorageSyncJob

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

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 9 with StorageSyncJob

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

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)

Example 10 with StorageSyncJob

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

the class RegistrationUtil method maybeMarkRegistrationComplete.

/**
 * There's several events where a registration may or may not be considered complete based on what
 * path a user has taken. This will only truly mark registration as complete if all of the
 * requirements are met.
 */
public static void maybeMarkRegistrationComplete(@NonNull Context context) {
    if (!SignalStore.registrationValues().isRegistrationComplete() && SignalStore.account().isRegistered() && !Recipient.self().getProfileName().isEmpty() && (SignalStore.kbsValues().hasPin() || SignalStore.kbsValues().hasOptedOut())) {
        Log.i(TAG, "Marking registration completed.", new Throwable());
        SignalStore.registrationValues().setRegistrationComplete();
        ApplicationDependencies.getJobManager().startChain(new StorageSyncJob()).then(new DirectoryRefreshJob(false)).enqueue();
    } else if (!SignalStore.registrationValues().isRegistrationComplete()) {
        Log.i(TAG, "Registration is not yet complete.", new Throwable());
    }
}
Also used : StorageSyncJob(org.thoughtcrime.securesms.jobs.StorageSyncJob) DirectoryRefreshJob(org.thoughtcrime.securesms.jobs.DirectoryRefreshJob)

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