mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Add internal setting to run KT.
This commit is contained in:
@@ -262,7 +262,7 @@ public class ApplicationContext extends Application implements AppForegroundObse
|
|||||||
checkFreeDiskSpace();
|
checkFreeDiskSpace();
|
||||||
MemoryTracker.start();
|
MemoryTracker.start();
|
||||||
BackupSubscriptionCheckJob.enqueueIfAble();
|
BackupSubscriptionCheckJob.enqueueIfAble();
|
||||||
CheckKeyTransparencyJob.enqueueIfNecessary();
|
CheckKeyTransparencyJob.enqueueIfNecessary(true);
|
||||||
AppDependencies.getAuthWebSocket().registerKeepAliveToken(SignalWebSocket.FOREGROUND_KEEPALIVE);
|
AppDependencies.getAuthWebSocket().registerKeepAliveToken(SignalWebSocket.FOREGROUND_KEEPALIVE);
|
||||||
AppDependencies.getUnauthWebSocket().registerKeepAliveToken(SignalWebSocket.FOREGROUND_KEEPALIVE);
|
AppDependencies.getUnauthWebSocket().registerKeepAliveToken(SignalWebSocket.FOREGROUND_KEEPALIVE);
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import org.thoughtcrime.securesms.database.model.InAppPaymentSubscriberRecord
|
|||||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||||
import org.thoughtcrime.securesms.jobmanager.JobTracker
|
import org.thoughtcrime.securesms.jobmanager.JobTracker
|
||||||
|
import org.thoughtcrime.securesms.jobs.CheckKeyTransparencyJob
|
||||||
import org.thoughtcrime.securesms.jobs.DownloadLatestEmojiDataJob
|
import org.thoughtcrime.securesms.jobs.DownloadLatestEmojiDataJob
|
||||||
import org.thoughtcrime.securesms.jobs.EmojiSearchIndexDownloadJob
|
import org.thoughtcrime.securesms.jobs.EmojiSearchIndexDownloadJob
|
||||||
import org.thoughtcrime.securesms.jobs.InAppPaymentKeepAliveJob
|
import org.thoughtcrime.securesms.jobs.InAppPaymentKeepAliveJob
|
||||||
@@ -307,6 +308,15 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
clickPref(
|
||||||
|
title = DSLSettingsText.from("Run self-check key transparency"),
|
||||||
|
summary = DSLSettingsText.from("Automatically enqueues a job to run KT against yourself without waiting for the elapsed time."),
|
||||||
|
onClick = {
|
||||||
|
SignalStore.misc.lastKeyTransparencyTime = 0
|
||||||
|
CheckKeyTransparencyJob.enqueueIfNecessary(addDelay = false)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
dividerPref()
|
dividerPref()
|
||||||
|
|
||||||
sectionHeaderPref(DSLSettingsText.from("Logging"))
|
sectionHeaderPref(DSLSettingsText.from("Logging"))
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.signal.libsignal.keytrans.KeyTransparencyException
|
|||||||
import org.signal.libsignal.keytrans.VerificationFailedException
|
import org.signal.libsignal.keytrans.VerificationFailedException
|
||||||
import org.signal.libsignal.net.AppExpiredException
|
import org.signal.libsignal.net.AppExpiredException
|
||||||
import org.signal.libsignal.net.BadRequestError
|
import org.signal.libsignal.net.BadRequestError
|
||||||
|
import org.signal.libsignal.net.ChatServiceException
|
||||||
import org.signal.libsignal.net.KeyTransparency
|
import org.signal.libsignal.net.KeyTransparency
|
||||||
import org.signal.libsignal.net.NetworkException
|
import org.signal.libsignal.net.NetworkException
|
||||||
import org.signal.libsignal.net.NetworkProtocolException
|
import org.signal.libsignal.net.NetworkProtocolException
|
||||||
@@ -33,8 +34,13 @@ class KeyTransparencyApi(private val unauthWebSocket: SignalWebSocket.Unauthenti
|
|||||||
onSuccess = { RequestResult.Success(Unit) },
|
onSuccess = { RequestResult.Success(Unit) },
|
||||||
onError = { throwable ->
|
onError = { throwable ->
|
||||||
when (throwable) {
|
when (throwable) {
|
||||||
is TimeoutException,
|
is VerificationFailedException,
|
||||||
is ServerSideErrorException,
|
is KeyTransparencyException,
|
||||||
|
is AppExpiredException,
|
||||||
|
is IllegalArgumentException -> {
|
||||||
|
RequestResult.NonSuccess(KeyTransparencyError(throwable))
|
||||||
|
}
|
||||||
|
is ChatServiceException,
|
||||||
is NetworkException,
|
is NetworkException,
|
||||||
is NetworkProtocolException -> {
|
is NetworkProtocolException -> {
|
||||||
RequestResult.RetryableNetworkError(throwable, null)
|
RequestResult.RetryableNetworkError(throwable, null)
|
||||||
@@ -42,12 +48,6 @@ class KeyTransparencyApi(private val unauthWebSocket: SignalWebSocket.Unauthenti
|
|||||||
is RetryLaterException -> {
|
is RetryLaterException -> {
|
||||||
RequestResult.RetryableNetworkError(throwable, throwable.duration)
|
RequestResult.RetryableNetworkError(throwable, throwable.duration)
|
||||||
}
|
}
|
||||||
is VerificationFailedException,
|
|
||||||
is KeyTransparencyException,
|
|
||||||
is AppExpiredException,
|
|
||||||
is IllegalArgumentException -> {
|
|
||||||
RequestResult.NonSuccess(KeyTransparencyError(throwable))
|
|
||||||
}
|
|
||||||
else -> {
|
else -> {
|
||||||
RequestResult.ApplicationError(throwable)
|
RequestResult.ApplicationError(throwable)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class CheckKeyTransparencyJob private constructor(
|
|||||||
private val TIME_BETWEEN_CHECK = 7.days
|
private val TIME_BETWEEN_CHECK = 7.days
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun enqueueIfNecessary() {
|
fun enqueueIfNecessary(addDelay: Boolean) {
|
||||||
if (!canRunJob()) {
|
if (!canRunJob()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ class CheckKeyTransparencyJob private constructor(
|
|||||||
showFailure = false,
|
showFailure = false,
|
||||||
parameters = Parameters.Builder()
|
parameters = Parameters.Builder()
|
||||||
.addConstraint(NetworkConstraint.KEY)
|
.addConstraint(NetworkConstraint.KEY)
|
||||||
.setInitialDelay(5.minutes.inWholeMilliseconds)
|
.setInitialDelay(if (addDelay) 5.minutes.inWholeMilliseconds else 0.minutes.inWholeMilliseconds)
|
||||||
.setGlobalPriority(Parameters.PRIORITY_LOWER)
|
.setGlobalPriority(Parameters.PRIORITY_LOWER)
|
||||||
.setMaxInstancesForFactory(2)
|
.setMaxInstancesForFactory(2)
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ object RegistrationRepository {
|
|||||||
PreKeysSyncJob.enqueue()
|
PreKeysSyncJob.enqueue()
|
||||||
|
|
||||||
recipientTable.clearSelfKeyTransparencyData()
|
recipientTable.clearSelfKeyTransparencyData()
|
||||||
CheckKeyTransparencyJob.enqueueIfNecessary()
|
CheckKeyTransparencyJob.enqueueIfNecessary(addDelay = true)
|
||||||
|
|
||||||
val jobManager = AppDependencies.jobManager
|
val jobManager = AppDependencies.jobManager
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user