mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Add sticker specific restore flow and fix archive related sticker bugs.
This commit is contained in:
committed by
Michelle Tang
parent
9903a664d4
commit
21363f085e
@@ -469,6 +469,10 @@ class JobController {
|
||||
return jobStorage.areQueuesEmpty(queueKeys);
|
||||
}
|
||||
|
||||
synchronized boolean areFactoriesEmpty(@NonNull Set<String> factoryKeys) {
|
||||
return jobStorage.areFactoriesEmpty(factoryKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the dynamic JobRunner system with minimum threads.
|
||||
*/
|
||||
|
||||
@@ -436,6 +436,19 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
return jobController.areQueuesEmpty(queueKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can tell you if there are no jobs for the given factories at the time of invocation. It is worth noting
|
||||
* that the state could change immediately after this method returns due to a call on some
|
||||
* other thread, and you should take that into consideration when using the result.
|
||||
*
|
||||
* @return True if there are no jobs for the given factories at the time of invocation, otherwise false.
|
||||
*/
|
||||
@WorkerThread
|
||||
public boolean areFactoriesEmpty(@NonNull Set<String> factoryKeys) {
|
||||
waitUntilInitialized();
|
||||
return jobController.areFactoriesEmpty(factoryKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pokes the system to take another pass at the job queue.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2025 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.jobmanager.impl
|
||||
|
||||
import android.app.job.JobInfo
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Constraint
|
||||
import org.thoughtcrime.securesms.jobmanager.ConstraintObserver
|
||||
import org.thoughtcrime.securesms.jobs.StickerDownloadJob
|
||||
import org.thoughtcrime.securesms.jobs.StickerPackDownloadJob
|
||||
|
||||
/**
|
||||
* When met, no sticker download jobs should be in the job queue/running.
|
||||
*/
|
||||
object StickersNotDownloadingConstraint : Constraint {
|
||||
|
||||
const val KEY = "StickersNotDownloadingConstraint"
|
||||
|
||||
private val factoryKeys = setOf(StickerPackDownloadJob.KEY, StickerDownloadJob.KEY)
|
||||
|
||||
override fun isMet(): Boolean {
|
||||
return AppDependencies.jobManager.areFactoriesEmpty(factoryKeys)
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun applyToJobInfo(jobInfoBuilder: JobInfo.Builder) = Unit
|
||||
|
||||
object Observer : ConstraintObserver {
|
||||
override fun register(notifier: ConstraintObserver.Notifier) {
|
||||
AppDependencies.jobManager.addListener({ job -> factoryKeys.contains(job.factoryKey) }) { job, jobState ->
|
||||
if (jobState.isComplete) {
|
||||
if (isMet) {
|
||||
notifier.onConstraintMet(KEY)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Factory : Constraint.Factory<StickersNotDownloadingConstraint> {
|
||||
override fun create(): StickersNotDownloadingConstraint {
|
||||
return StickersNotDownloadingConstraint
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,9 @@ interface JobStorage {
|
||||
@WorkerThread
|
||||
fun areQueuesEmpty(queueKeys: Set<String>): Boolean
|
||||
|
||||
@WorkerThread
|
||||
fun areFactoriesEmpty(factoryKeys: Set<String>): Boolean
|
||||
|
||||
@WorkerThread
|
||||
fun markJobAsRunning(id: String, currentTime: Long)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user