mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Add cleanup job for group ringing.
This commit is contained in:
@@ -57,6 +57,7 @@ import org.thoughtcrime.securesms.jobs.EmojiSearchIndexDownloadJob;
|
|||||||
import org.thoughtcrime.securesms.jobs.ExternalLaunchDonationJob;
|
import org.thoughtcrime.securesms.jobs.ExternalLaunchDonationJob;
|
||||||
import org.thoughtcrime.securesms.jobs.FcmRefreshJob;
|
import org.thoughtcrime.securesms.jobs.FcmRefreshJob;
|
||||||
import org.thoughtcrime.securesms.jobs.FontDownloaderJob;
|
import org.thoughtcrime.securesms.jobs.FontDownloaderJob;
|
||||||
|
import org.thoughtcrime.securesms.jobs.GroupRingCleanupJob;
|
||||||
import org.thoughtcrime.securesms.jobs.GroupV2UpdateSelfProfileKeyJob;
|
import org.thoughtcrime.securesms.jobs.GroupV2UpdateSelfProfileKeyJob;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
||||||
import org.thoughtcrime.securesms.jobs.PnpInitializeDevicesJob;
|
import org.thoughtcrime.securesms.jobs.PnpInitializeDevicesJob;
|
||||||
@@ -214,6 +215,7 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr
|
|||||||
.addPostRender(() -> ApplicationDependencies.getExoPlayerPool().getPoolStats().getMaxUnreserved())
|
.addPostRender(() -> ApplicationDependencies.getExoPlayerPool().getPoolStats().getMaxUnreserved())
|
||||||
.addPostRender(() -> ApplicationDependencies.getRecipientCache().warmUp())
|
.addPostRender(() -> ApplicationDependencies.getRecipientCache().warmUp())
|
||||||
.addPostRender(AccountConsistencyWorkerJob::enqueueIfNecessary)
|
.addPostRender(AccountConsistencyWorkerJob::enqueueIfNecessary)
|
||||||
|
.addPostRender(GroupRingCleanupJob::enqueue)
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
Log.d(TAG, "onCreate() took " + (System.currentTimeMillis() - startTime) + " ms");
|
Log.d(TAG, "onCreate() took " + (System.currentTimeMillis() - startTime) + " ms");
|
||||||
|
|||||||
@@ -1172,6 +1172,25 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLatestRingingCalls(): List<Call> {
|
||||||
|
return readableDatabase.select()
|
||||||
|
.from(TABLE_NAME)
|
||||||
|
.where("$EVENT = ?", Event.serialize(Event.RINGING))
|
||||||
|
.limit(10)
|
||||||
|
.orderBy(TIMESTAMP)
|
||||||
|
.run()
|
||||||
|
.readToList {
|
||||||
|
Call.deserialize(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun markRingingCallsAsMissed() {
|
||||||
|
writableDatabase.update(TABLE_NAME)
|
||||||
|
.values(EVENT to Event.serialize(Event.MISSED))
|
||||||
|
.where("$EVENT = ?", Event.serialize(Event.RINGING))
|
||||||
|
.run()
|
||||||
|
}
|
||||||
|
|
||||||
fun getCallsCount(searchTerm: String?, filter: CallLogFilter): Int {
|
fun getCallsCount(searchTerm: String?, filter: CallLogFilter): Int {
|
||||||
return getCallsCursor(true, 0, 0, searchTerm, filter).use {
|
return getCallsCursor(true, 0, 0, searchTerm, filter).use {
|
||||||
it.moveToFirst()
|
it.moveToFirst()
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Signal Messenger, LLC
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.thoughtcrime.securesms.jobs
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||||
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||||
|
import org.thoughtcrime.securesms.jobmanager.Job
|
||||||
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleans database of stale group rings which can occur if the device or application
|
||||||
|
* crashes while an incoming ring is happening.
|
||||||
|
*/
|
||||||
|
class GroupRingCleanupJob private constructor(parameters: Parameters) : BaseJob(parameters) {
|
||||||
|
companion object {
|
||||||
|
const val KEY = "GroupRingCleanupJob"
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun enqueue() {
|
||||||
|
ApplicationDependencies.getJobManager().add(
|
||||||
|
GroupRingCleanupJob(
|
||||||
|
Parameters.Builder()
|
||||||
|
.addConstraint(NetworkConstraint.KEY)
|
||||||
|
.setLifespan(TimeUnit.HOURS.toMillis(1))
|
||||||
|
.setMaxInstancesForFactory(1)
|
||||||
|
.setQueue(KEY)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(): ByteArray? = null
|
||||||
|
|
||||||
|
override fun getFactoryKey(): String = KEY
|
||||||
|
|
||||||
|
override fun onFailure() = Unit
|
||||||
|
|
||||||
|
override fun onRun() {
|
||||||
|
SignalDatabase.calls.getLatestRingingCalls().forEach {
|
||||||
|
ApplicationDependencies.getSignalCallManager().peekGroupCall(it.peer)
|
||||||
|
}
|
||||||
|
|
||||||
|
SignalDatabase.calls.markRingingCallsAsMissed()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onShouldRetry(e: Exception): Boolean = false
|
||||||
|
|
||||||
|
class Factory : Job.Factory<GroupRingCleanupJob> {
|
||||||
|
override fun create(parameters: Parameters, serializedData: ByteArray?): GroupRingCleanupJob {
|
||||||
|
return GroupRingCleanupJob(parameters)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,6 +129,7 @@ public final class JobManagerFactories {
|
|||||||
put(GroupCallUpdateSendJob.KEY, new GroupCallUpdateSendJob.Factory());
|
put(GroupCallUpdateSendJob.KEY, new GroupCallUpdateSendJob.Factory());
|
||||||
put(GroupCallPeekJob.KEY, new GroupCallPeekJob.Factory());
|
put(GroupCallPeekJob.KEY, new GroupCallPeekJob.Factory());
|
||||||
put(GroupCallPeekWorkerJob.KEY, new GroupCallPeekWorkerJob.Factory());
|
put(GroupCallPeekWorkerJob.KEY, new GroupCallPeekWorkerJob.Factory());
|
||||||
|
put(GroupRingCleanupJob.KEY, new GroupRingCleanupJob.Factory());
|
||||||
put(GroupV2UpdateSelfProfileKeyJob.KEY, new GroupV2UpdateSelfProfileKeyJob.Factory());
|
put(GroupV2UpdateSelfProfileKeyJob.KEY, new GroupV2UpdateSelfProfileKeyJob.Factory());
|
||||||
put(IndividualSendJob.KEY, new IndividualSendJob.Factory());
|
put(IndividualSendJob.KEY, new IndividualSendJob.Factory());
|
||||||
put(LeaveGroupV2Job.KEY, new LeaveGroupV2Job.Factory());
|
put(LeaveGroupV2Job.KEY, new LeaveGroupV2Job.Factory());
|
||||||
|
|||||||
Reference in New Issue
Block a user