use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class MultiDeviceViewedUpdateJob method enqueue.
/**
* Enqueues all the necessary jobs for read receipts, ensuring that they're all within the
* maximum size.
*/
public static void enqueue(@NonNull List<SyncMessageId> messageIds) {
JobManager jobManager = ApplicationDependencies.getJobManager();
List<List<SyncMessageId>> messageIdChunks = Util.chunk(messageIds, SendReadReceiptJob.MAX_TIMESTAMPS);
if (messageIdChunks.size() > 1) {
Log.w(TAG, "Large receipt count! Had to break into multiple chunks. Total count: " + messageIds.size());
}
for (List<SyncMessageId> chunk : messageIdChunks) {
jobManager.add(new MultiDeviceViewedUpdateJob(chunk));
}
}
use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class GroupV1MigrationJob method enqueueRoutineMigrationsIfNecessary.
public static void enqueueRoutineMigrationsIfNecessary(@NonNull Application application) {
if (!SignalStore.registrationValues().isRegistrationComplete() || !SignalStore.account().isRegistered() || SignalStore.account().getAci() == null) {
Log.i(TAG, "Registration not complete. Skipping.");
return;
}
long timeSinceRefresh = System.currentTimeMillis() - SignalStore.misc().getLastGv1RoutineMigrationTime();
if (timeSinceRefresh < REFRESH_INTERVAL) {
Log.i(TAG, "Too soon to refresh. Did the last refresh " + timeSinceRefresh + " ms ago.");
return;
}
SignalStore.misc().setLastGv1RoutineMigrationTime(System.currentTimeMillis());
SignalExecutors.BOUNDED.execute(() -> {
JobManager jobManager = ApplicationDependencies.getJobManager();
List<ThreadRecord> threads = SignalDatabase.threads().getRecentV1Groups(ROUTINE_LIMIT);
Set<RecipientId> needsRefresh = new HashSet<>();
if (threads.size() > 0) {
Log.d(TAG, "About to enqueue refreshes for " + threads.size() + " groups.");
}
for (ThreadRecord thread : threads) {
jobManager.add(new GroupV1MigrationJob(thread.getRecipient().getId()));
needsRefresh.addAll(Stream.of(thread.getRecipient().getParticipants()).filter(r -> r.getGroupsV2Capability() != Recipient.Capability.SUPPORTED || r.getGroupsV1MigrationCapability() != Recipient.Capability.SUPPORTED).map(Recipient::getId).toList());
}
if (needsRefresh.size() > 0) {
Log.w(TAG, "Enqueuing profile refreshes for " + needsRefresh.size() + " GV1 participants.");
RetrieveProfileJob.enqueue(needsRefresh);
}
});
}
use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class LocalBackupJob method enqueue.
public static void enqueue(boolean force) {
JobManager jobManager = ApplicationDependencies.getJobManager();
Parameters.Builder parameters = new Parameters.Builder().setQueue(QUEUE).setMaxInstancesForFactory(1).setMaxAttempts(3);
if (force) {
jobManager.cancelAllInQueue(QUEUE);
} else {
parameters.addConstraint(ChargingConstraint.KEY);
}
if (BackupUtil.isUserSelectionRequired(ApplicationDependencies.getApplication())) {
jobManager.add(new LocalBackupJobApi29(parameters.build()));
} else {
jobManager.add(new LocalBackupJob(parameters.build()));
}
}
use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class MessageSender method sendMms.
private static void sendMms(Context context, long messageId) {
JobManager jobManager = ApplicationDependencies.getJobManager();
MmsSendJob.enqueue(context, jobManager, messageId);
}
use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class GroupCallPeekJob method enqueue.
public static void enqueue(@NonNull RecipientId groupRecipientId) {
JobManager jobManager = ApplicationDependencies.getJobManager();
String queue = QUEUE + groupRecipientId.serialize();
Parameters.Builder parameters = new Parameters.Builder().setQueue(queue).addConstraint(DecryptionsDrainedConstraint.KEY);
jobManager.cancelAllInQueue(queue);
jobManager.add(new GroupCallPeekJob(parameters.build(), groupRecipientId));
}
Aggregations