mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-05 04:45:14 +01:00
Build eager prefetch sessions under the SignalSessionLock.
This commit is contained in:
+1
@@ -209,6 +209,7 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
|
||||
protocolStore.aci(),
|
||||
new SignalProtocolAddress(pushServiceSocket.getCredentialsProvider().getAci().getLibSignalServiceId(),
|
||||
pushServiceSocket.getCredentialsProvider().getDeviceId()),
|
||||
ReentrantSessionLock.INSTANCE,
|
||||
PreKeyBatcher.INSTANCE
|
||||
)
|
||||
);
|
||||
|
||||
+15
-12
@@ -32,6 +32,7 @@ class PreKeyRepository(
|
||||
private val keysApi: KeysApi,
|
||||
private val aciStore: SignalServiceAccountDataStore,
|
||||
private val localProtocolAddress: SignalProtocolAddress,
|
||||
private val sessionLock: SignalSessionLock,
|
||||
private val batchHelper: BatchHelper
|
||||
) {
|
||||
|
||||
@@ -134,18 +135,20 @@ class PreKeyRepository(
|
||||
val recipient = result.recipient
|
||||
var aborted = false
|
||||
|
||||
for (preKey in result.bundles) {
|
||||
val preKeyAddress = SignalProtocolAddress(recipient.identifier, preKey.deviceId)
|
||||
try {
|
||||
SessionBuilder(aciStore, preKeyAddress, localProtocolAddress).process(preKey)
|
||||
} catch (_: UntrustedIdentityException) {
|
||||
Log.i(TAG, "[eagerPrefetch] Untrusted identity for recipient")
|
||||
aborted = true
|
||||
break
|
||||
} catch (_: InvalidKeyException) {
|
||||
Log.i(TAG, "[eagerPrefetch] Invalid pre-key")
|
||||
aborted = true
|
||||
break
|
||||
sessionLock.acquire().use {
|
||||
for (preKey in result.bundles) {
|
||||
val preKeyAddress = SignalProtocolAddress(recipient.identifier, preKey.deviceId)
|
||||
try {
|
||||
SessionBuilder(aciStore, preKeyAddress, localProtocolAddress).process(preKey)
|
||||
} catch (_: UntrustedIdentityException) {
|
||||
Log.i(TAG, "[eagerPrefetch] Untrusted identity for recipient")
|
||||
aborted = true
|
||||
break
|
||||
} catch (_: InvalidKeyException) {
|
||||
Log.i(TAG, "[eagerPrefetch] Invalid pre-key")
|
||||
aborted = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user