mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Rewrite the AppDependencies system.
This commit is contained in:
committed by
Cody Henthorne
parent
a0131bf39b
commit
b6a4e1f145
@@ -2,7 +2,7 @@ package org.thoughtcrime.securesms.messages
|
||||
|
||||
import org.signal.ringrtc.CallId
|
||||
import org.thoughtcrime.securesms.database.model.IdentityRecord
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.messages.MessageContentProcessor.Companion.log
|
||||
import org.thoughtcrime.securesms.messages.MessageContentProcessor.Companion.warn
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
@@ -57,9 +57,9 @@ object CallMessageProcessor {
|
||||
}
|
||||
|
||||
val remotePeer = RemotePeer(senderRecipientId, CallId(offerId))
|
||||
val remoteIdentityKey = ApplicationDependencies.getProtocolStore().aci().identities().getIdentityRecord(senderRecipientId).map { (_, identityKey): IdentityRecord -> identityKey.serialize() }.get()
|
||||
val remoteIdentityKey = AppDependencies.protocolStore.aci().identities().getIdentityRecord(senderRecipientId).map { (_, identityKey): IdentityRecord -> identityKey.serialize() }.get()
|
||||
|
||||
ApplicationDependencies.getSignalCallManager()
|
||||
AppDependencies.signalCallManager
|
||||
.receivedOffer(
|
||||
CallMetadata(remotePeer, metadata.sourceDeviceId),
|
||||
OfferMetadata(offer.opaque?.toByteArray(), OfferMessage.Type.fromProto(offer.type!!)),
|
||||
@@ -87,9 +87,9 @@ object CallMessageProcessor {
|
||||
}
|
||||
|
||||
val remotePeer = RemotePeer(senderRecipientId, CallId(answerId))
|
||||
val remoteIdentityKey = ApplicationDependencies.getProtocolStore().aci().identities().getIdentityRecord(senderRecipientId).map { (_, identityKey): IdentityRecord -> identityKey.serialize() }.get()
|
||||
val remoteIdentityKey = AppDependencies.protocolStore.aci().identities().getIdentityRecord(senderRecipientId).map { (_, identityKey): IdentityRecord -> identityKey.serialize() }.get()
|
||||
|
||||
ApplicationDependencies.getSignalCallManager()
|
||||
AppDependencies.signalCallManager
|
||||
.receivedAnswer(
|
||||
CallMetadata(remotePeer, metadata.sourceDeviceId),
|
||||
AnswerMetadata(answer.opaque?.toByteArray()),
|
||||
@@ -117,7 +117,7 @@ object CallMessageProcessor {
|
||||
|
||||
if (iceCandidates.isNotEmpty()) {
|
||||
val remotePeer = RemotePeer(senderRecipientId, CallId(callId))
|
||||
ApplicationDependencies.getSignalCallManager()
|
||||
AppDependencies.signalCallManager
|
||||
.receivedIceCandidates(
|
||||
CallMetadata(remotePeer, metadata.sourceDeviceId),
|
||||
iceCandidates
|
||||
@@ -143,7 +143,7 @@ object CallMessageProcessor {
|
||||
}
|
||||
|
||||
val remotePeer = RemotePeer(senderRecipientId, CallId(hangupId))
|
||||
ApplicationDependencies.getSignalCallManager()
|
||||
AppDependencies.signalCallManager
|
||||
.receivedCallHangup(
|
||||
CallMetadata(remotePeer, metadata.sourceDeviceId),
|
||||
HangupMetadata(HangupMessage.Type.fromProto(hangup.type), hangupDeviceId ?: 0)
|
||||
@@ -161,7 +161,7 @@ object CallMessageProcessor {
|
||||
}
|
||||
|
||||
val remotePeer = RemotePeer(senderRecipientId, CallId(busyId))
|
||||
ApplicationDependencies.getSignalCallManager().receivedCallBusy(CallMetadata(remotePeer, metadata.sourceDeviceId))
|
||||
AppDependencies.signalCallManager.receivedCallBusy(CallMetadata(remotePeer, metadata.sourceDeviceId))
|
||||
}
|
||||
|
||||
private fun handleCallOpaqueMessage(envelope: Envelope, metadata: EnvelopeMetadata, opaque: Opaque, senderServiceId: ServiceId, serverDeliveredTimestamp: Long) {
|
||||
@@ -179,7 +179,7 @@ object CallMessageProcessor {
|
||||
messageAgeSeconds = (serverDeliveredTimestamp - envelope.serverTimestamp!!).milliseconds.inWholeSeconds
|
||||
}
|
||||
|
||||
ApplicationDependencies.getSignalCallManager()
|
||||
AppDependencies.signalCallManager
|
||||
.receivedOpaqueMessage(
|
||||
OpaqueMessageMetadata(
|
||||
senderServiceId.rawUuid,
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.thoughtcrime.securesms.database.model.StickerRecord
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.GiftBadge
|
||||
import org.thoughtcrime.securesms.database.model.toBodyRangeList
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.BadGroupIdException
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob
|
||||
@@ -192,15 +192,15 @@ object DataMessageProcessor {
|
||||
}
|
||||
|
||||
if (metadata.sealedSender && messageId != null) {
|
||||
SignalExecutors.BOUNDED.execute { ApplicationDependencies.getJobManager().add(SendDeliveryReceiptJob(senderRecipient.id, message.timestamp!!, messageId)) }
|
||||
SignalExecutors.BOUNDED.execute { AppDependencies.jobManager.add(SendDeliveryReceiptJob(senderRecipient.id, message.timestamp!!, messageId)) }
|
||||
} else if (!metadata.sealedSender) {
|
||||
if (RecipientUtil.shouldHaveProfileKey(threadRecipient)) {
|
||||
Log.w(MessageContentProcessor.TAG, "Received an unsealed sender message from " + senderRecipient.id + ", but they should already have our profile key. Correcting.")
|
||||
|
||||
if (groupId != null) {
|
||||
Log.i(MessageContentProcessor.TAG, "Message was to a GV2 group. Ensuring our group profile keys are up to date.")
|
||||
ApplicationDependencies
|
||||
.getJobManager()
|
||||
AppDependencies
|
||||
.jobManager
|
||||
.startChain(RefreshAttributesJob(false))
|
||||
.then(GroupV2UpdateSelfProfileKeyJob.withQueueLimits(groupId))
|
||||
.enqueue()
|
||||
@@ -208,8 +208,8 @@ object DataMessageProcessor {
|
||||
Log.i(MessageContentProcessor.TAG, "Message was to a 1:1. Ensuring this user has our profile key.")
|
||||
val profileSendJob = ProfileKeySendJob.create(SignalDatabase.threads.getOrCreateThreadIdFor(threadRecipient), true)
|
||||
if (profileSendJob != null) {
|
||||
ApplicationDependencies
|
||||
.getJobManager()
|
||||
AppDependencies
|
||||
.jobManager
|
||||
.startChain(RefreshAttributesJob(false))
|
||||
.then(profileSendJob)
|
||||
.enqueue()
|
||||
@@ -222,7 +222,7 @@ object DataMessageProcessor {
|
||||
val timeSinceLastSync = System.currentTimeMillis() - SignalStore.misc().lastCdsForegroundSyncTime
|
||||
if (timeSinceLastSync > FeatureFlags.cdsForegroundSyncInterval() || timeSinceLastSync < 0) {
|
||||
log(envelope.timestamp!!, "New 1:1 chat. Scheduling a CDS sync to see if they match someone in our contacts.")
|
||||
ApplicationDependencies.getJobManager().add(DirectoryRefreshJob(false))
|
||||
AppDependencies.jobManager.add(DirectoryRefreshJob(false))
|
||||
SignalStore.misc().lastCdsForegroundSyncTime = System.currentTimeMillis()
|
||||
} else {
|
||||
warn(envelope.timestamp!!, "New 1:1 chat, but performed a CDS sync $timeSinceLastSync ms ago, which is less than our threshold. Skipping CDS sync.")
|
||||
@@ -278,7 +278,7 @@ object DataMessageProcessor {
|
||||
val insertResult: InsertResult? = insertPlaceholder(sender, timestamp, groupId)
|
||||
if (insertResult != null) {
|
||||
SignalDatabase.messages.markAsInvalidMessage(insertResult.messageId)
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,9 +303,9 @@ object DataMessageProcessor {
|
||||
val insertResult: InsertResult? = SignalDatabase.messages.insertMessageInbox(incomingMessage).orNull()
|
||||
|
||||
return if (insertResult != null) {
|
||||
ApplicationDependencies.getProtocolStore().aci().deleteAllSessions(metadata.sourceServiceId.toString())
|
||||
AppDependencies.protocolStore.aci().deleteAllSessions(metadata.sourceServiceId.toString())
|
||||
SecurityEvent.broadcastSecurityUpdateEvent(context)
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
insertResult
|
||||
} else {
|
||||
null
|
||||
@@ -460,9 +460,9 @@ object DataMessageProcessor {
|
||||
SignalDatabase.messages.setTransactionSuccessful()
|
||||
|
||||
if (parentStoryId.isGroupReply()) {
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.fromThreadAndReply(insertResult.threadId, parentStoryId as GroupReply))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.fromThreadAndReply(insertResult.threadId, parentStoryId as GroupReply))
|
||||
} else {
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
TrimThreadJob.enqueueAsync(insertResult.threadId)
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ object DataMessageProcessor {
|
||||
if (targetMessage == null) {
|
||||
warn(envelope.timestamp!!, "[handleReaction] Could not find matching message! Putting it in the early message cache. timestamp: " + targetSentTimestamp + " author: " + targetAuthor.id)
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(targetAuthor.id, targetSentTimestamp, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(targetAuthor.id, targetSentTimestamp, earlyMessageCacheEntry)
|
||||
PushProcessEarlyMessagesJob.enqueue()
|
||||
}
|
||||
return null
|
||||
@@ -547,11 +547,11 @@ object DataMessageProcessor {
|
||||
|
||||
if (isRemove) {
|
||||
SignalDatabase.reactions.deleteReaction(targetMessageId, senderRecipientId)
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context)
|
||||
AppDependencies.messageNotifier.updateNotification(context)
|
||||
} else {
|
||||
val reactionRecord = ReactionRecord(emoji!!, senderRecipientId, message.timestamp!!, System.currentTimeMillis())
|
||||
SignalDatabase.reactions.addReaction(targetMessageId, reactionRecord)
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.fromMessageRecord(targetMessage))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.fromMessageRecord(targetMessage))
|
||||
}
|
||||
|
||||
return targetMessageId
|
||||
@@ -571,13 +571,13 @@ object DataMessageProcessor {
|
||||
SignalDatabase.messages.deleteRemotelyDeletedStory(targetMessage.id)
|
||||
}
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.fromMessageRecord(targetMessage))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.fromMessageRecord(targetMessage))
|
||||
|
||||
MessageId(targetMessage.id)
|
||||
} else if (targetMessage == null) {
|
||||
warn(envelope.timestamp!!, "[handleRemoteDelete] Could not find matching message! timestamp: $targetSentTimestamp author: $senderRecipientId")
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(senderRecipientId, targetSentTimestamp, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(senderRecipientId, targetSentTimestamp, earlyMessageCacheEntry)
|
||||
PushProcessEarlyMessagesJob.enqueue()
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ object DataMessageProcessor {
|
||||
|
||||
val insertResult: InsertResult? = SignalDatabase.messages.insertMessageInbox(mediaMessage, -1).orNull()
|
||||
if (insertResult != null) {
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
return insertResult
|
||||
}
|
||||
} catch (e: PublicKeyConflictException) {
|
||||
@@ -682,7 +682,7 @@ object DataMessageProcessor {
|
||||
throw StorageFailedException(e, metadata.sourceServiceId.toString(), metadata.sourceDeviceId)
|
||||
} finally {
|
||||
SignalDatabase.runPostSuccessfulTransaction {
|
||||
ApplicationDependencies.getJobManager()
|
||||
AppDependencies.jobManager
|
||||
.startChain(PaymentTransactionCheckJob(uuid, queue))
|
||||
.then(PaymentLedgerUpdateJob.updateLedger())
|
||||
.enqueue()
|
||||
@@ -790,9 +790,9 @@ object DataMessageProcessor {
|
||||
SignalDatabase.messages.setTransactionSuccessful()
|
||||
|
||||
if (parentStoryId.isGroupReply()) {
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.fromThreadAndReply(insertResult.threadId, parentStoryId as GroupReply))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.fromThreadAndReply(insertResult.threadId, parentStoryId as GroupReply))
|
||||
} else {
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
TrimThreadJob.enqueueAsync(insertResult.threadId)
|
||||
}
|
||||
|
||||
@@ -855,7 +855,7 @@ object DataMessageProcessor {
|
||||
}
|
||||
|
||||
return if (insertResult != null) {
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
TrimThreadJob.enqueueAsync(insertResult.threadId)
|
||||
insertResult
|
||||
} else {
|
||||
@@ -938,14 +938,14 @@ object DataMessageProcessor {
|
||||
AttachmentDownloadJob(insertResult.messageId, attachmentId, false)
|
||||
}
|
||||
}
|
||||
ApplicationDependencies.getJobManager().addAll(downloadJobs)
|
||||
AppDependencies.jobManager.addAll(downloadJobs)
|
||||
}
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
TrimThreadJob.enqueueAsync(insertResult.threadId)
|
||||
|
||||
if (message.isViewOnce == true) {
|
||||
ApplicationDependencies.getViewOnceMessageManager().scheduleIfNecessary()
|
||||
AppDependencies.viewOnceMessageManager.scheduleIfNecessary()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -992,7 +992,7 @@ object DataMessageProcessor {
|
||||
localMetrics?.onInsertedTextMessage()
|
||||
|
||||
return if (insertResult != null) {
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
insertResult
|
||||
} else {
|
||||
null
|
||||
@@ -1031,7 +1031,7 @@ object DataMessageProcessor {
|
||||
|
||||
if (threadId > 0 && TextSecurePreferences.isTypingIndicatorsEnabled(context)) {
|
||||
debug("Typing stopped on thread $threadId due to an incoming message.")
|
||||
ApplicationDependencies.getTypingStatusRepository().onTypingStopped(threadId, senderRecipient, device, true)
|
||||
AppDependencies.typingStatusRepository.onTypingStopped(threadId, senderRecipient, device, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.database.model.MessageId
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
|
||||
import org.thoughtcrime.securesms.database.model.toBodyRangeList
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob
|
||||
import org.thoughtcrime.securesms.jobs.PushProcessEarlyMessagesJob
|
||||
@@ -56,7 +56,7 @@ object EditMessageProcessor {
|
||||
warn(envelope.timestamp!!, "[handleEditMessage] Could not find matching message! timestamp: ${editMessage.targetSentTimestamp} author: ${senderRecipient.id}")
|
||||
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(senderRecipient.id, editMessage.targetSentTimestamp!!, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(senderRecipient.id, editMessage.targetSentTimestamp!!, earlyMessageCacheEntry)
|
||||
PushProcessEarlyMessagesJob.enqueue()
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ object EditMessageProcessor {
|
||||
|
||||
if (insertResult != null) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
ApplicationDependencies.getJobManager().add(SendDeliveryReceiptJob(senderRecipient.id, message.timestamp!!, MessageId(insertResult.messageId)))
|
||||
AppDependencies.jobManager.add(SendDeliveryReceiptJob(senderRecipient.id, message.timestamp!!, MessageId(insertResult.messageId)))
|
||||
}
|
||||
|
||||
if (targetMessage.expireStarted > 0) {
|
||||
ApplicationDependencies.getExpiringMessageManager()
|
||||
AppDependencies.expiringMessageManager
|
||||
.scheduleDeletion(
|
||||
insertResult.messageId,
|
||||
true,
|
||||
@@ -108,7 +108,7 @@ object EditMessageProcessor {
|
||||
)
|
||||
}
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, forConversation(insertResult.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, forConversation(insertResult.threadId))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ object EditMessageProcessor {
|
||||
val downloadJobs: List<AttachmentDownloadJob> = insertResult.insertedAttachments.mapNotNull { (_, attachmentId) ->
|
||||
AttachmentDownloadJob(insertResult.messageId, attachmentId, false)
|
||||
}
|
||||
ApplicationDependencies.getJobManager().addAll(downloadJobs)
|
||||
AppDependencies.jobManager.addAll(downloadJobs)
|
||||
}
|
||||
}
|
||||
return insertResult
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.database.MessageSendLogTables;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.DistributionListId;
|
||||
import org.thoughtcrime.securesms.database.model.MessageId;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@@ -65,7 +65,6 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class GroupSendUtil {
|
||||
|
||||
@@ -298,7 +297,7 @@ public final class GroupSendUtil {
|
||||
}
|
||||
|
||||
List<SendMessageResult> allResults = new ArrayList<>(allTargets.size());
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
SignalServiceMessageSender messageSender = AppDependencies.getSignalServiceMessageSender();
|
||||
|
||||
if (senderKeyTargets.size() > 0 && distributionId != null) {
|
||||
long keyCreateTime = SenderKeyUtil.getCreateTimeForOurKey(distributionId);
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.crypto.ReentrantSessionLock
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.GroupsV2ProcessingLock
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.BackoffUtil
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
@@ -74,7 +74,7 @@ class IncomingMessageObserver(private val context: Application) {
|
||||
const val FOREGROUND_ID = 313399
|
||||
|
||||
private val censored: Boolean
|
||||
get() = ApplicationDependencies.getSignalServiceNetworkAccess().isCensored()
|
||||
get() = AppDependencies.signalServiceNetworkAccess.isCensored()
|
||||
}
|
||||
|
||||
private val decryptionDrainedListeners: MutableList<Runnable> = CopyOnWriteArrayList()
|
||||
@@ -128,7 +128,7 @@ class IncomingMessageObserver(private val context: Application) {
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationDependencies.getAppForegroundObserver().addListener(object : AppForegroundObserver.Listener {
|
||||
AppDependencies.appForegroundObserver.addListener(object : AppForegroundObserver.Listener {
|
||||
override fun onForeground() {
|
||||
onAppForegrounded()
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class IncomingMessageObserver(private val context: Application) {
|
||||
}
|
||||
|
||||
private fun disconnect() {
|
||||
ApplicationDependencies.getSignalWebSocket().disconnect()
|
||||
AppDependencies.signalWebSocket.disconnect()
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@@ -372,8 +372,8 @@ class IncomingMessageObserver(private val context: Application) {
|
||||
waitForConnectionNecessary()
|
||||
Log.i(TAG, "Making websocket connection....")
|
||||
|
||||
val signalWebSocket = ApplicationDependencies.getSignalWebSocket()
|
||||
val webSocketDisposable = signalWebSocket.webSocketState.subscribe { state: WebSocketConnectionState ->
|
||||
val signalWebSocket = AppDependencies.signalWebSocket
|
||||
val webSocketDisposable = AppDependencies.webSocketObserver.subscribe { state: WebSocketConnectionState ->
|
||||
Log.d(TAG, "WebSocket State: $state")
|
||||
|
||||
// Any state change at all means that we are not drained
|
||||
@@ -405,7 +405,7 @@ class IncomingMessageObserver(private val context: Application) {
|
||||
if (followUpOperations != null) {
|
||||
Log.d(TAG, "Running ${followUpOperations.size} follow-up operations...")
|
||||
val jobs = followUpOperations.mapNotNull { it.run() }
|
||||
ApplicationDependencies.getJobManager().addAllChains(jobs)
|
||||
AppDependencies.jobManager.addAllChains(jobs)
|
||||
}
|
||||
|
||||
signalWebSocket.sendAck(response)
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.database.model.GroupRecord
|
||||
import org.thoughtcrime.securesms.database.model.MessageLogEntry
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.PendingRetryReceiptModel
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.BadGroupIdException
|
||||
import org.thoughtcrime.securesms.groups.GroupChangeBusyException
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
@@ -71,7 +71,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun create(context: Context = ApplicationDependencies.getApplication()): MessageContentProcessor {
|
||||
fun create(context: Context = AppDependencies.application): MessageContentProcessor {
|
||||
return MessageContentProcessor(context)
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
val threadId = SignalDatabase.threads.getThreadIdFor(destination.id)
|
||||
if (threadId != null) {
|
||||
val lastSeen = SignalDatabase.threads.getConversationMetadata(threadId).lastSeen
|
||||
val visibleThread = ApplicationDependencies.getMessageNotifier().visibleThread.map(ConversationId::threadId).orElse(-1L)
|
||||
val visibleThread = AppDependencies.messageNotifier.visibleThread.map(ConversationId::threadId).orElse(-1L)
|
||||
|
||||
if (threadId != visibleThread && lastSeen > 0 && lastSeen < pending.receivedTimestamp) {
|
||||
receivedTime = pending.receivedTimestamp
|
||||
@@ -307,7 +307,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
.insertMessageInbox(textMessage)
|
||||
.ifPresent {
|
||||
marker(it.messageId)
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(it.threadId))
|
||||
AppDependencies.messageNotifier.updateNotification(context, ConversationId.forConversation(it.threadId))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,8 +328,8 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
|
||||
handleMessage(senderRecipient, envelope, content, metadata, serverDeliveredTimestamp, processingEarlyContent, localMetric)
|
||||
|
||||
val earlyCacheEntries: List<EarlyMessageCacheEntry>? = ApplicationDependencies
|
||||
.getEarlyMessageCache()
|
||||
val earlyCacheEntries: List<EarlyMessageCacheEntry>? = AppDependencies
|
||||
.earlyMessageCache
|
||||
.retrieve(senderRecipient.id, envelope.timestamp!!)
|
||||
.orNull()
|
||||
|
||||
@@ -395,7 +395,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
MessageState.CORRUPT_MESSAGE,
|
||||
MessageState.NO_SESSION -> {
|
||||
warn(timestamp, "Discovered old enqueued bad encrypted message. Scheduling reset.")
|
||||
ApplicationDependencies.getJobManager().add(AutomaticSessionResetJob(sender.id, exceptionMetadata.senderDevice, timestamp))
|
||||
AppDependencies.jobManager.add(AutomaticSessionResetJob(sender.id, exceptionMetadata.senderDevice, timestamp))
|
||||
}
|
||||
|
||||
MessageState.DUPLICATE_MESSAGE -> warn(timestamp, "Duplicate message. Dropping.")
|
||||
@@ -420,7 +420,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
return
|
||||
}
|
||||
|
||||
val pending: PendingRetryReceiptModel? = ApplicationDependencies.getPendingRetryReceiptCache().get(senderRecipient.id, envelope.timestamp!!)
|
||||
val pending: PendingRetryReceiptModel? = AppDependencies.pendingRetryReceiptCache.get(senderRecipient.id, envelope.timestamp!!)
|
||||
val receivedTime: Long = handlePendingRetry(pending, envelope.timestamp!!, threadRecipient)
|
||||
|
||||
log(envelope.timestamp!!, "Beginning message processing. Sender: " + formatSender(senderRecipient.id, metadata.sourceServiceId, metadata.sourceDeviceId))
|
||||
@@ -518,7 +518,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
|
||||
if (pending != null) {
|
||||
warn(envelope.timestamp!!, "Pending retry was processed. Deleting.")
|
||||
ApplicationDependencies.getPendingRetryReceiptCache().delete(pending)
|
||||
AppDependencies.pendingRetryReceiptCache.delete(pending)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,10 +553,10 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
|
||||
if (typingMessage.hasStarted) {
|
||||
Log.d(TAG, "Typing started on thread $threadId")
|
||||
ApplicationDependencies.getTypingStatusRepository().onTypingStarted(context, threadId, senderRecipient, metadata.sourceDeviceId)
|
||||
AppDependencies.typingStatusRepository.onTypingStarted(context, threadId, senderRecipient, metadata.sourceDeviceId)
|
||||
} else {
|
||||
Log.d(TAG, "Typing stopped on thread $threadId")
|
||||
ApplicationDependencies.getTypingStatusRepository().onTypingStopped(threadId, senderRecipient, metadata.sourceDeviceId, false)
|
||||
AppDependencies.typingStatusRepository.onTypingStopped(threadId, senderRecipient, metadata.sourceDeviceId, false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
|
||||
if (messageLogEntry != null) {
|
||||
warn(envelope.timestamp!!, "[RetryReceipt-SK] Found MSL entry for ${requester.id} ($requesterAddress) with timestamp $sentTimestamp. Scheduling a resend.")
|
||||
ApplicationDependencies.getJobManager().add(
|
||||
AppDependencies.jobManager.add(
|
||||
ResendMessageJob(
|
||||
messageLogEntry.recipientId,
|
||||
messageLogEntry.dateSent,
|
||||
@@ -646,7 +646,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
)
|
||||
} else {
|
||||
warn(envelope.timestamp!!, "[RetryReceipt-SK] Unable to find MSL entry for ${requester.id} ($requesterAddress) with timestamp $sentTimestamp for ${if (groupId != null) "group $groupId" else "distribution list"}. Scheduling a job to send them the SenderKeyDistributionMessage. Membership will be checked there.")
|
||||
ApplicationDependencies.getJobManager().add(SenderKeyDistributionSendJob(requester.id, threadRecipient.id))
|
||||
AppDependencies.jobManager.add(SenderKeyDistributionSendJob(requester.id, threadRecipient.id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,7 +661,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
if (decryptionErrorMessage.ratchetKey.isPresent) {
|
||||
if (ratchetKeyMatches(requester, metadata.sourceDeviceId, decryptionErrorMessage.ratchetKey.get())) {
|
||||
warn(envelope.timestamp!!, "[RetryReceipt-I] Ratchet key matches. Archiving the session.")
|
||||
ApplicationDependencies.getProtocolStore().aci().sessions().archiveSession(requester.requireServiceId(), metadata.sourceDeviceId)
|
||||
AppDependencies.protocolStore.aci().sessions().archiveSession(requester.requireServiceId(), metadata.sourceDeviceId)
|
||||
archivedSession = true
|
||||
} else {
|
||||
log(envelope.timestamp!!, "[RetryReceipt-I] Ratchet key does not match. Leaving the session as-is.")
|
||||
@@ -672,7 +672,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
|
||||
if (messageLogEntry != null) {
|
||||
warn(envelope.timestamp!!, "[RetryReceipt-I] Found an entry in the MSL. Resending.")
|
||||
ApplicationDependencies.getJobManager().add(
|
||||
AppDependencies.jobManager.add(
|
||||
ResendMessageJob(
|
||||
messageLogEntry.recipientId,
|
||||
messageLogEntry.dateSent,
|
||||
@@ -685,7 +685,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
)
|
||||
} else if (archivedSession) {
|
||||
warn(envelope.timestamp!!, "[RetryReceipt-I] Could not find an entry in the MSL, but we archived the session, so we're sending a null message to complete the reset.")
|
||||
ApplicationDependencies.getJobManager().add(NullMessageSendJob(requester.id))
|
||||
AppDependencies.jobManager.add(NullMessageSendJob(requester.id))
|
||||
} else {
|
||||
warn(envelope.timestamp!!, "[RetryReceipt-I] Could not find an entry in the MSL. Skipping.")
|
||||
}
|
||||
@@ -702,7 +702,7 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
|
||||
private fun ratchetKeyMatches(recipient: Recipient, deviceId: Int, ratchetKey: ECPublicKey): Boolean {
|
||||
val address = recipient.resolve().requireAci().toProtocolAddress(deviceId)
|
||||
val session = ApplicationDependencies.getProtocolStore().aci().loadSession(address)
|
||||
val session = AppDependencies.protocolStore.aci().loadSession(address)
|
||||
return session.currentRatchetKeyMatches(ratchetKey)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.crypto.ReentrantSessionLock
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.BadGroupIdException
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager
|
||||
@@ -360,8 +360,8 @@ object MessageDecryptor {
|
||||
return@FollowUpOperation null
|
||||
}
|
||||
|
||||
ApplicationDependencies.getPendingRetryReceiptCache().insert(sender.id, senderDevice, envelope.timestamp!!, receivedTimestamp, threadId)
|
||||
ApplicationDependencies.getPendingRetryReceiptManager().scheduleIfNecessary()
|
||||
AppDependencies.pendingRetryReceiptCache.insert(sender.id, senderDevice, envelope.timestamp!!, receivedTimestamp, threadId)
|
||||
AppDependencies.pendingRetryReceiptManager.scheduleIfNecessary()
|
||||
null
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import org.signal.core.util.Stopwatch
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobs.PushProcessEarlyMessagesJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.messages.MessageContentProcessor.Companion.log
|
||||
@@ -88,7 +88,7 @@ object ReceiptMessageProcessor {
|
||||
for (targetTimestamp in missingTargetTimestamps) {
|
||||
warn(envelope.timestamp!!, "[handleReadReceipt] Could not find matching message! targetTimestamp: $targetTimestamp, receiptAuthor: $senderRecipientId | Receipt, so associating with message from self ($selfId)")
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(selfId, targetTimestamp, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(selfId, targetTimestamp, earlyMessageCacheEntry)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ object ReceiptMessageProcessor {
|
||||
for (targetTimestamp in missingTargetTimestamps) {
|
||||
warn(envelope.timestamp!!, "[handleViewedReceipt] Could not find matching message! targetTimestamp: $targetTimestamp, receiptAuthor: $senderRecipientId | Receipt so associating with message from self ($selfId)")
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(selfId, targetTimestamp, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(selfId, targetTimestamp, earlyMessageCacheEntry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.database.model.StoryType
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.ChatColor
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.StoryTextPost
|
||||
import org.thoughtcrime.securesms.database.model.toBodyRangeList
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.messages.MessageContentProcessor.Companion.log
|
||||
import org.thoughtcrime.securesms.messages.MessageContentProcessor.Companion.warn
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.groupId
|
||||
@@ -91,7 +91,7 @@ object StoryMessageProcessor {
|
||||
|
||||
if (insertResult != null) {
|
||||
Stories.enqueueNextStoriesForDownload(threadRecipient.id, false, FeatureFlags.storiesAutoDownloadMaximum())
|
||||
ApplicationDependencies.getExpireStoriesManager().scheduleIfNecessary()
|
||||
AppDependencies.expireStoriesManager.scheduleIfNecessary()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.thoughtcrime.securesms.database.model.StoryType
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.GiftBadge
|
||||
import org.thoughtcrime.securesms.database.model.toBodyRangeList
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.BadGroupIdException
|
||||
import org.thoughtcrime.securesms.groups.GroupChangeBusyException
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
@@ -241,7 +241,7 @@ object SyncMessageProcessor {
|
||||
|
||||
if (threadId != -1L) {
|
||||
SignalDatabase.threads.setRead(threadId, true)
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context)
|
||||
AppDependencies.messageNotifier.updateNotification(context)
|
||||
}
|
||||
|
||||
if (SignalStore.rateLimit().needsRecaptcha()) {
|
||||
@@ -249,7 +249,7 @@ object SyncMessageProcessor {
|
||||
RateLimitUtil.retryAllRateLimitedMessages(context)
|
||||
}
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().setLastDesktopActivityTimestamp(sent.timestamp!!)
|
||||
AppDependencies.messageNotifier.setLastDesktopActivityTimestamp(sent.timestamp!!)
|
||||
} catch (e: MmsException) {
|
||||
throw StorageFailedException(e, metadata.sourceServiceId.toString(), metadata.sourceDeviceId)
|
||||
}
|
||||
@@ -268,7 +268,7 @@ object SyncMessageProcessor {
|
||||
|
||||
val address = SignalProtocolAddress(pni.toString(), SignalServiceAddress.DEFAULT_DEVICE_ID)
|
||||
|
||||
if (ApplicationDependencies.getProtocolStore().aci().identities().getIdentity(address) != null) {
|
||||
if (AppDependencies.protocolStore.aci().identities().getIdentity(address) != null) {
|
||||
log(envelope.timestamp!!, "Ignoring identity on sent transcript for $pni because we already have one.")
|
||||
continue
|
||||
}
|
||||
@@ -276,7 +276,7 @@ object SyncMessageProcessor {
|
||||
try {
|
||||
log(envelope.timestamp!!, "Saving identity from sent transcript for $pni")
|
||||
val identityKey = IdentityKey(status.destinationIdentityKey!!.toByteArray())
|
||||
ApplicationDependencies.getProtocolStore().aci().identities().saveIdentity(address, identityKey)
|
||||
AppDependencies.protocolStore.aci().identities().saveIdentity(address, identityKey)
|
||||
} catch (e: InvalidKeyException) {
|
||||
warn(envelope.timestamp!!, "Failed to deserialize identity key for $pni")
|
||||
}
|
||||
@@ -307,7 +307,7 @@ object SyncMessageProcessor {
|
||||
if (targetMessage == null) {
|
||||
warn(envelope.timestamp!!, "[handleSynchronizeSentEditMessage] Could not find matching message! targetTimestamp: $targetSentTimestamp author: $senderRecipientId")
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(senderRecipientId, targetSentTimestamp, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(senderRecipientId, targetSentTimestamp, earlyMessageCacheEntry)
|
||||
PushProcessEarlyMessagesJob.enqueue()
|
||||
}
|
||||
} else if (MessageConstraintsUtil.isValidEditMessageReceive(targetMessage, senderRecipient, envelope.serverTimestamp!!)) {
|
||||
@@ -375,7 +375,7 @@ object SyncMessageProcessor {
|
||||
SignalDatabase.messages.markAsSent(messageId, true)
|
||||
if (targetMessage.expireStarted > 0) {
|
||||
SignalDatabase.messages.markExpireStarted(messageId, targetMessage.expireStarted)
|
||||
ApplicationDependencies.getExpiringMessageManager().scheduleDeletion(messageId, true, targetMessage.expireStarted, targetMessage.expireStarted)
|
||||
AppDependencies.expiringMessageManager.scheduleDeletion(messageId, true, targetMessage.expireStarted, targetMessage.expireStarted)
|
||||
}
|
||||
|
||||
if (toRecipient.isSelf) {
|
||||
@@ -436,7 +436,7 @@ object SyncMessageProcessor {
|
||||
|
||||
if (targetMessage.expireStarted > 0) {
|
||||
SignalDatabase.messages.markExpireStarted(messageId, targetMessage.expireStarted)
|
||||
ApplicationDependencies.getExpiringMessageManager().scheduleDeletion(messageId, true, targetMessage.expireStarted, targetMessage.expireStarted)
|
||||
AppDependencies.expiringMessageManager.scheduleDeletion(messageId, true, targetMessage.expireStarted, targetMessage.expireStarted)
|
||||
}
|
||||
|
||||
if (toRecipient.isSelf) {
|
||||
@@ -447,7 +447,7 @@ object SyncMessageProcessor {
|
||||
if (syncAttachments.isNotEmpty()) {
|
||||
SignalDatabase.runPostSuccessfulTransaction {
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
AppDependencies.jobManager.add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -547,7 +547,7 @@ object SyncMessageProcessor {
|
||||
|
||||
SignalDatabase.runPostSuccessfulTransaction {
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
AppDependencies.jobManager.add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -615,7 +615,7 @@ object SyncMessageProcessor {
|
||||
val threadId: Long = SignalDatabase.threads.getOrCreateThreadIdFor(recipient)
|
||||
|
||||
if (!recipient.isGroup) {
|
||||
ApplicationDependencies.getProtocolStore().aci().deleteAllSessions(recipient.requireServiceId().toString())
|
||||
AppDependencies.protocolStore.aci().deleteAllSessions(recipient.requireServiceId().toString())
|
||||
SecurityEvent.broadcastSecurityUpdateEvent(context)
|
||||
val messageId = SignalDatabase.messages.insertMessageOutbox(
|
||||
outgoingEndSessionMessage,
|
||||
@@ -749,8 +749,8 @@ object SyncMessageProcessor {
|
||||
if (dataMessage.expireTimerDuration > Duration.ZERO) {
|
||||
SignalDatabase.messages.markExpireStarted(messageId, sent.expirationStartTimestamp ?: 0)
|
||||
|
||||
ApplicationDependencies
|
||||
.getExpiringMessageManager()
|
||||
AppDependencies
|
||||
.expiringMessageManager
|
||||
.scheduleDeletion(messageId, true, sent.expirationStartTimestamp ?: 0, dataMessage.expireTimerDuration.inWholeMilliseconds)
|
||||
}
|
||||
if (recipient.isSelf) {
|
||||
@@ -817,7 +817,7 @@ object SyncMessageProcessor {
|
||||
if (dataMessage.expireTimerDuration > Duration.ZERO) {
|
||||
SignalDatabase.messages.markExpireStarted(messageId, sent.expirationStartTimestamp ?: 0)
|
||||
|
||||
ApplicationDependencies.getExpiringMessageManager().scheduleDeletion(messageId, true, sent.expirationStartTimestamp ?: 0, dataMessage.expireTimerDuration.inWholeMilliseconds)
|
||||
AppDependencies.expiringMessageManager.scheduleDeletion(messageId, true, sent.expirationStartTimestamp ?: 0, dataMessage.expireTimerDuration.inWholeMilliseconds)
|
||||
}
|
||||
if (recipient.isSelf) {
|
||||
SignalDatabase.messages.incrementDeliveryReceiptCount(sent.timestamp!!, recipient.id, System.currentTimeMillis())
|
||||
@@ -827,7 +827,7 @@ object SyncMessageProcessor {
|
||||
SignalDatabase.runPostSuccessfulTransaction {
|
||||
val downloadJobs: List<AttachmentDownloadJob> = attachments.map { AttachmentDownloadJob(messageId, it.attachmentId, false) }
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().addAll(downloadJobs)
|
||||
AppDependencies.jobManager.addAll(downloadJobs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -872,7 +872,7 @@ object SyncMessageProcessor {
|
||||
SignalDatabase.messages.markAsSent(messageId, true)
|
||||
if (expiresInMillis > 0) {
|
||||
SignalDatabase.messages.markExpireStarted(messageId, sent.expirationStartTimestamp ?: 0)
|
||||
ApplicationDependencies.getExpiringMessageManager().scheduleDeletion(messageId, isGroup, sent.expirationStartTimestamp ?: 0, expiresInMillis)
|
||||
AppDependencies.expiringMessageManager.scheduleDeletion(messageId, isGroup, sent.expirationStartTimestamp ?: 0, expiresInMillis)
|
||||
}
|
||||
|
||||
if (recipient.isSelf) {
|
||||
@@ -892,10 +892,10 @@ object SyncMessageProcessor {
|
||||
}
|
||||
|
||||
when (message.type) {
|
||||
Request.Type.CONTACTS -> ApplicationDependencies.getJobManager().add(MultiDeviceContactUpdateJob(true))
|
||||
Request.Type.BLOCKED -> ApplicationDependencies.getJobManager().add(MultiDeviceBlockedUpdateJob())
|
||||
Request.Type.CONTACTS -> AppDependencies.jobManager.add(MultiDeviceContactUpdateJob(true))
|
||||
Request.Type.BLOCKED -> AppDependencies.jobManager.add(MultiDeviceBlockedUpdateJob())
|
||||
Request.Type.CONFIGURATION -> {
|
||||
ApplicationDependencies.getJobManager().add(
|
||||
AppDependencies.jobManager.add(
|
||||
MultiDeviceConfigurationUpdateJob(
|
||||
TextSecurePreferences.isReadReceiptsEnabled(context),
|
||||
TextSecurePreferences.isTypingIndicatorsEnabled(context),
|
||||
@@ -903,9 +903,9 @@ object SyncMessageProcessor {
|
||||
SignalStore.settings().isLinkPreviewsEnabled
|
||||
)
|
||||
)
|
||||
ApplicationDependencies.getJobManager().add(MultiDeviceStickerPackSyncJob())
|
||||
AppDependencies.jobManager.add(MultiDeviceStickerPackSyncJob())
|
||||
}
|
||||
Request.Type.KEYS -> ApplicationDependencies.getJobManager().add(MultiDeviceKeysUpdateJob())
|
||||
Request.Type.KEYS -> AppDependencies.jobManager.add(MultiDeviceKeysUpdateJob())
|
||||
else -> warn(envelopeTimestamp, "Unknown request type: ${message.type}")
|
||||
}
|
||||
}
|
||||
@@ -930,7 +930,7 @@ object SyncMessageProcessor {
|
||||
for (id in unhandled) {
|
||||
warn(envelopeTimestamp, "[handleSynchronizeReadMessage] Could not find matching message! timestamp: ${id.timetamp} author: ${id.recipientId}")
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(id.recipientId, id.timetamp, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(id.recipientId, id.timetamp, earlyMessageCacheEntry)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -938,8 +938,8 @@ object SyncMessageProcessor {
|
||||
PushProcessEarlyMessagesJob.enqueue()
|
||||
}
|
||||
|
||||
ApplicationDependencies
|
||||
.getMessageNotifier()
|
||||
AppDependencies
|
||||
.messageNotifier
|
||||
.apply {
|
||||
setLastDesktopActivityTimestamp(envelopeTimestamp)
|
||||
cancelDelayedNotifications()
|
||||
@@ -974,7 +974,7 @@ object SyncMessageProcessor {
|
||||
SignalDatabase.messages.setIncomingMessagesViewed(toMarkViewed)
|
||||
SignalDatabase.messages.setOutgoingGiftsRevealed(toMarkViewed)
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().apply {
|
||||
AppDependencies.messageNotifier.apply {
|
||||
setLastDesktopActivityTimestamp(envelopeTimestamp)
|
||||
cancelDelayedNotifications()
|
||||
updateNotification(context)
|
||||
@@ -998,12 +998,12 @@ object SyncMessageProcessor {
|
||||
} else {
|
||||
warn(envelopeTimestamp.toString(), "Got a view-once open message for a message we don't have!")
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(author, timestamp, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(author, timestamp, earlyMessageCacheEntry)
|
||||
PushProcessEarlyMessagesJob.enqueue()
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().apply {
|
||||
AppDependencies.messageNotifier.apply {
|
||||
setLastDesktopActivityTimestamp(envelopeTimestamp)
|
||||
cancelDelayedNotifications()
|
||||
updateNotification(context)
|
||||
@@ -1019,7 +1019,7 @@ object SyncMessageProcessor {
|
||||
private fun handleSynchronizeStickerPackOperation(stickerPackOperations: List<StickerPackOperation>, envelopeTimestamp: Long) {
|
||||
log(envelopeTimestamp, "Synchronize sticker pack operation.")
|
||||
|
||||
val jobManager = ApplicationDependencies.getJobManager()
|
||||
val jobManager = AppDependencies.jobManager
|
||||
|
||||
for (operation in stickerPackOperations) {
|
||||
if (operation.packId != null && operation.packKey != null && operation.type != null) {
|
||||
@@ -1066,7 +1066,7 @@ object SyncMessageProcessor {
|
||||
private fun handleSynchronizeFetchMessage(fetchType: FetchLatest.Type, envelopeTimestamp: Long) {
|
||||
log(envelopeTimestamp, "Received fetch request with type: $fetchType")
|
||||
when (fetchType) {
|
||||
FetchLatest.Type.LOCAL_PROFILE -> ApplicationDependencies.getJobManager().add(RefreshOwnProfileJob())
|
||||
FetchLatest.Type.LOCAL_PROFILE -> AppDependencies.jobManager.add(RefreshOwnProfileJob())
|
||||
FetchLatest.Type.STORAGE_MANIFEST -> StorageSyncHelper.scheduleSyncForDataChange()
|
||||
FetchLatest.Type.SUBSCRIPTION_STATUS -> warn(envelopeTimestamp, "Dropping subscription status fetch message.")
|
||||
else -> warn(envelopeTimestamp, "Received a fetch message for an unknown type.")
|
||||
@@ -1164,7 +1164,7 @@ object SyncMessageProcessor {
|
||||
|
||||
if (address == null && recipientId == null) {
|
||||
log(envelopeTimestamp, "Inserting defrag")
|
||||
address = ApplicationDependencies.getPayments().wallet.mobileCoinPublicAddress
|
||||
address = AppDependencies.payments.wallet.mobileCoinPublicAddress
|
||||
recipientId = Recipient.self().id
|
||||
}
|
||||
|
||||
@@ -1217,7 +1217,7 @@ object SyncMessageProcessor {
|
||||
|
||||
val attachment: SignalServiceAttachmentPointer = contactsMessage.blob!!.toSignalServiceAttachmentPointer()
|
||||
|
||||
ApplicationDependencies.getJobManager().add(MultiDeviceContactSyncJob(attachment))
|
||||
AppDependencies.jobManager.add(MultiDeviceContactSyncJob(attachment))
|
||||
}
|
||||
|
||||
private fun handleSynchronizeCallEvent(callEvent: SyncMessage.CallEvent, envelopeTimestamp: Long) {
|
||||
@@ -1329,7 +1329,7 @@ object SyncMessageProcessor {
|
||||
)
|
||||
}
|
||||
|
||||
ApplicationDependencies.getJobManager().add(RefreshCallLinkDetailsJob(callLinkUpdate))
|
||||
AppDependencies.jobManager.add(RefreshCallLinkDetailsJob(callLinkUpdate))
|
||||
}
|
||||
|
||||
private fun handleSynchronizeOneToOneCallEvent(callEvent: SyncMessage.CallEvent, envelopeTimestamp: Long) {
|
||||
@@ -1473,7 +1473,7 @@ object SyncMessageProcessor {
|
||||
handleSynchronizeLocalOnlyConversationDeletes(deleteForMe.localOnlyConversationDeletes, envelopeTimestamp)
|
||||
}
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context)
|
||||
AppDependencies.messageNotifier.updateNotification(context)
|
||||
}
|
||||
|
||||
private fun handleSynchronizeMessageDeletes(messageDeletes: List<SyncMessage.DeleteForMe.MessageDeletes>, envelopeTimestamp: Long, earlyMessageCacheEntry: EarlyMessageCacheEntry?) {
|
||||
@@ -1489,7 +1489,7 @@ object SyncMessageProcessor {
|
||||
for (syncMessage in unhandled) {
|
||||
warn(envelopeTimestamp, "[handleSynchronizeDeleteForMe] Could not find matching message! timestamp: ${syncMessage.timetamp} author: ${syncMessage.recipientId}")
|
||||
if (earlyMessageCacheEntry != null) {
|
||||
ApplicationDependencies.getEarlyMessageCache().store(syncMessage.recipientId, syncMessage.timetamp, earlyMessageCacheEntry)
|
||||
AppDependencies.earlyMessageCache.store(syncMessage.recipientId, syncMessage.timetamp, earlyMessageCacheEntry)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import androidx.annotation.AnyThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import org.signal.core.util.Stopwatch
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.JobTracker
|
||||
import org.thoughtcrime.securesms.jobmanager.JobTracker.JobListener
|
||||
@@ -50,8 +50,8 @@ object WebSocketDrainer {
|
||||
|
||||
var websocketDrainTimeout = requestedWebsocketDrainTimeoutMs
|
||||
|
||||
val context = ApplicationDependencies.getApplication()
|
||||
val incomingMessageObserver = ApplicationDependencies.getIncomingMessageObserver()
|
||||
val context = AppDependencies.application
|
||||
val incomingMessageObserver = AppDependencies.incomingMessageObserver
|
||||
val powerManager = ServiceUtil.getPowerManager(context)
|
||||
|
||||
val doze = PowerManagerCompat.isDeviceIdleMode(powerManager)
|
||||
@@ -67,7 +67,7 @@ object WebSocketDrainer {
|
||||
}
|
||||
|
||||
val wakeLockTag = WAKELOCK_PREFIX + System.currentTimeMillis()
|
||||
val wakeLock = WakeLockUtil.acquire(ApplicationDependencies.getApplication(), PowerManager.PARTIAL_WAKE_LOCK, websocketDrainTimeout + QUEUE_TIMEOUT, wakeLockTag)
|
||||
val wakeLock = WakeLockUtil.acquire(AppDependencies.application, PowerManager.PARTIAL_WAKE_LOCK, websocketDrainTimeout + QUEUE_TIMEOUT, wakeLockTag)
|
||||
|
||||
return try {
|
||||
drainAndProcess(websocketDrainTimeout, incomingMessageObserver, keepAliveToken)
|
||||
@@ -86,7 +86,7 @@ object WebSocketDrainer {
|
||||
private fun drainAndProcess(timeout: Long, incomingMessageObserver: IncomingMessageObserver, keepAliveToken: String): Boolean {
|
||||
val stopwatch = Stopwatch("websocket-strategy")
|
||||
|
||||
val jobManager = ApplicationDependencies.getJobManager()
|
||||
val jobManager = AppDependencies.jobManager
|
||||
val queueListener = QueueFindingJobListener()
|
||||
|
||||
jobManager.addListener(
|
||||
@@ -148,7 +148,7 @@ object WebSocketDrainer {
|
||||
|
||||
private fun blockUntilJobQueueDrained(queue: String, timeoutMs: Long): Boolean {
|
||||
val startTime = System.currentTimeMillis()
|
||||
val jobManager = ApplicationDependencies.getJobManager()
|
||||
val jobManager = AppDependencies.jobManager
|
||||
val markerJob = MarkerJob(queue)
|
||||
val jobState = jobManager.runSynchronously(markerJob, timeoutMs)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.thoughtcrime.securesms.messages.protocol
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.whispersystems.signalservice.api.push.ServiceId
|
||||
|
||||
@@ -32,8 +32,8 @@ class BufferedProtocolStore private constructor(
|
||||
* Writes any buffered data to disk. You can continue to use the same buffered store afterwards.
|
||||
*/
|
||||
fun flushToDisk() {
|
||||
aciStore.second.flushToDisk(ApplicationDependencies.getProtocolStore().aci())
|
||||
pniStore.second.flushToDisk(ApplicationDependencies.getProtocolStore().pni())
|
||||
aciStore.second.flushToDisk(AppDependencies.protocolStore.aci())
|
||||
pniStore.second.flushToDisk(AppDependencies.protocolStore.pni())
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user