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());
}
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());
});
}
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())));
}
});
}
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());
}
}
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());
}
}
Aggregations