use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class StickerManagementRepository method installStickerPack.
void installStickerPack(@NonNull String packId, @NonNull String packKey, boolean notify) {
SignalExecutors.SERIAL.execute(() -> {
JobManager jobManager = ApplicationDependencies.getJobManager();
if (stickerDatabase.isPackAvailableAsReference(packId)) {
stickerDatabase.markPackAsInstalled(packId, notify);
}
jobManager.add(StickerPackDownloadJob.forInstall(packId, packKey, notify));
if (TextSecurePreferences.isMultiDevice(context)) {
jobManager.add(new MultiDeviceStickerPackOperationJob(packId, packKey, MultiDeviceStickerPackOperationJob.Type.INSTALL));
}
});
}
use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class MmsSendJob method enqueue.
/**
* Enqueues compression jobs for attachments and finally the MMS send job.
*/
@WorkerThread
public static void enqueue(@NonNull Context context, @NonNull JobManager jobManager, long messageId) {
MessageDatabase database = SignalDatabase.mms();
OutgoingMediaMessage message;
try {
message = database.getOutgoingMessage(messageId);
} catch (MmsException | NoSuchMessageException e) {
throw new AssertionError(e);
}
List<Job> compressionJobs = Stream.of(message.getAttachments()).map(a -> (Job) AttachmentCompressionJob.fromAttachment((DatabaseAttachment) a, true, message.getSubscriptionId())).toList();
MmsSendJob sendJob = new MmsSendJob(messageId);
jobManager.startChain(compressionJobs).then(sendJob).enqueue();
}
use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class MultiDeviceReadUpdateJob 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 MultiDeviceReadUpdateJob(chunk));
}
}
use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class MessageContentProcessor method handleSynchronizeStickerPackOperation.
private void handleSynchronizeStickerPackOperation(@NonNull List<StickerPackOperationMessage> stickerPackOperations, long envelopeTimestamp) {
log(envelopeTimestamp, "Synchronize sticker pack operation.");
JobManager jobManager = ApplicationDependencies.getJobManager();
for (StickerPackOperationMessage operation : stickerPackOperations) {
if (operation.getPackId().isPresent() && operation.getPackKey().isPresent() && operation.getType().isPresent()) {
String packId = Hex.toStringCondensed(operation.getPackId().get());
String packKey = Hex.toStringCondensed(operation.getPackKey().get());
switch(operation.getType().get()) {
case INSTALL:
jobManager.add(StickerPackDownloadJob.forInstall(packId, packKey, false));
break;
case REMOVE:
SignalDatabase.stickers().uninstallPack(packId);
break;
}
} else {
warn("Received incomplete sticker pack operation sync.");
}
}
}
use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by WhisperSystems.
the class GroupsV2CapabilityChecker method refreshCapabilitiesIfNecessary.
/**
* @param resolved A collection of resolved recipients.
* @return True if a recipient needed to be refreshed, otherwise false.
*/
@WorkerThread
public static boolean refreshCapabilitiesIfNecessary(@NonNull Collection<Recipient> resolved) throws IOException {
Set<RecipientId> needsRefresh = Stream.of(resolved).filter(r -> r.getGroupsV2Capability() != Recipient.Capability.SUPPORTED).map(Recipient::getId).collect(Collectors.toSet());
if (needsRefresh.size() > 0) {
Log.d(TAG, "[refreshCapabilitiesIfNecessary] Need to refresh " + needsRefresh.size() + " recipients.");
List<Job> jobs = RetrieveProfileJob.forRecipients(needsRefresh);
JobManager jobManager = ApplicationDependencies.getJobManager();
for (Job job : jobs) {
if (!jobManager.runSynchronously(job, TimeUnit.SECONDS.toMillis(10)).isPresent()) {
throw new IOException("Recipient capability was not retrieved in time");
}
}
return true;
} else {
return false;
}
}
Aggregations