mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Stagger app wake ups due to analyze database alarm.
This commit is contained in:
@@ -5,6 +5,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobs.AnalyzeDatabaseJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.toMillis
|
||||
import java.security.SecureRandom
|
||||
import java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
@@ -43,12 +44,13 @@ class AnalyzeDatabaseAlarmListener : PersistentAlarmManagerListener() {
|
||||
}
|
||||
|
||||
private fun getNextTime(): Long {
|
||||
val random = SecureRandom()
|
||||
return LocalDateTime
|
||||
.now()
|
||||
.plusDays(1)
|
||||
.withHour(3)
|
||||
.withMinute(0)
|
||||
.withSecond(0)
|
||||
.withHour(2 + random.nextInt(3))
|
||||
.withMinute(random.nextInt(60))
|
||||
.withSecond(random.nextInt(60))
|
||||
.toMillis()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user