mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Check for restorable previously optimized media and restore if necessary.
This commit is contained in:
committed by
Greyson Parrelli
parent
d81182633d
commit
5552455c2e
@@ -69,6 +69,7 @@ import org.thoughtcrime.securesms.jobs.PnpInitializeDevicesJob;
|
||||
import org.thoughtcrime.securesms.jobs.PreKeysSyncJob;
|
||||
import org.thoughtcrime.securesms.jobs.ProfileUploadJob;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshSvrCredentialsJob;
|
||||
import org.thoughtcrime.securesms.jobs.RestoreOptimizedMediaJob;
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob;
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveRemoteAnnouncementsJob;
|
||||
import org.thoughtcrime.securesms.jobs.StoryOnboardingDownloadJob;
|
||||
@@ -223,6 +224,7 @@ public class ApplicationContext extends Application implements AppForegroundObse
|
||||
.addPostRender(LinkedDeviceInactiveCheckJob::enqueueIfNecessary)
|
||||
.addPostRender(() -> ActiveCallManager.clearNotifications(this))
|
||||
.addPostRender(() -> GroupSendEndorsementInternalNotifier.init())
|
||||
.addPostRender(RestoreOptimizedMediaJob::enqueueIfNecessary)
|
||||
.execute();
|
||||
|
||||
Log.d(TAG, "onCreate() took " + (System.currentTimeMillis() - startTime) + " ms");
|
||||
|
||||
@@ -23,6 +23,13 @@ class RestoreOptimizedMediaJob private constructor(parameters: Parameters) : Job
|
||||
val job = RestoreOptimizedMediaJob()
|
||||
AppDependencies.jobManager.add(job)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun enqueueIfNecessary() {
|
||||
if (SignalStore.backup.backsUpMedia && !SignalStore.backup.optimizeStorage) {
|
||||
AppDependencies.jobManager.add(RestoreOptimizedMediaJob())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private constructor() : this(
|
||||
@@ -34,11 +41,19 @@ class RestoreOptimizedMediaJob private constructor(parameters: Parameters) : Job
|
||||
)
|
||||
|
||||
override fun run(): Result {
|
||||
if (SignalStore.backup.optimizeStorage) {
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
val restorableAttachments = SignalDatabase.attachments.getRestorableOptimizedAttachments()
|
||||
|
||||
if (restorableAttachments.isEmpty()) {
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
val jobManager = AppDependencies.jobManager
|
||||
|
||||
SignalDatabase
|
||||
.attachments
|
||||
.getRestorableOptimizedAttachments()
|
||||
restorableAttachments
|
||||
.forEach {
|
||||
val job = RestoreAttachmentJob.forOffloadedRestore(
|
||||
messageId = it.mmsId,
|
||||
|
||||
Reference in New Issue
Block a user