2019-03-28 16:56:35 +01:00
|
|
|
package org.thoughtcrime.securesms.jobs;
|
|
|
|
|
|
|
|
import android.app.Application;
|
2019-12-03 18:31:23 +01:00
|
|
|
|
2019-06-05 21:47:14 +02:00
|
|
|
import androidx.annotation.NonNull;
|
2019-03-28 16:56:35 +01:00
|
|
|
|
2020-02-19 23:08:34 +01:00
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
2019-03-28 16:56:35 +01:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.Constraint;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.ConstraintObserver;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.Job;
|
2019-08-22 04:14:38 +02:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.JobMigration;
|
2019-03-28 16:56:35 +01:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.CellServiceConstraintObserver;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraintObserver;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.NetworkOrCellServiceConstraint;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraint;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
2020-05-27 17:00:04 +02:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.WebsocketDrainedConstraint;
|
|
|
|
import org.thoughtcrime.securesms.jobmanager.impl.WebsocketDrainedConstraintObserver;
|
2020-03-07 00:51:33 +01:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.migrations.PushProcessMessageQueueJobMigration;
|
2019-09-26 16:53:46 +02:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdFollowUpJobMigration;
|
2019-09-27 20:18:15 +02:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdFollowUpJobMigration2;
|
2019-08-07 20:22:51 +02:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration;
|
2020-06-09 01:04:55 +02:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.migrations.RetrieveProfileJobMigration;
|
2020-02-19 23:08:34 +01:00
|
|
|
import org.thoughtcrime.securesms.jobmanager.migrations.SendReadReceiptsJobMigration;
|
2020-03-25 23:43:02 +01:00
|
|
|
import org.thoughtcrime.securesms.migrations.AvatarIdRemovalMigrationJob;
|
2019-09-23 17:37:01 +02:00
|
|
|
import org.thoughtcrime.securesms.migrations.AvatarMigrationJob;
|
2019-11-01 15:03:39 +01:00
|
|
|
import org.thoughtcrime.securesms.migrations.CachedAttachmentsMigrationJob;
|
2019-07-30 01:02:40 +02:00
|
|
|
import org.thoughtcrime.securesms.migrations.DatabaseMigrationJob;
|
|
|
|
import org.thoughtcrime.securesms.migrations.LegacyMigrationJob;
|
|
|
|
import org.thoughtcrime.securesms.migrations.MigrationCompleteJob;
|
2020-05-08 15:46:16 +02:00
|
|
|
import org.thoughtcrime.securesms.migrations.PassingMigrationJob;
|
2020-05-30 00:16:38 +02:00
|
|
|
import org.thoughtcrime.securesms.migrations.PinReminderMigrationJob;
|
2020-07-07 17:00:29 +02:00
|
|
|
import org.thoughtcrime.securesms.migrations.ProfileMigrationJob;
|
2019-08-27 00:09:01 +02:00
|
|
|
import org.thoughtcrime.securesms.migrations.RecipientSearchMigrationJob;
|
2019-12-03 18:31:23 +01:00
|
|
|
import org.thoughtcrime.securesms.migrations.RegistrationPinV2MigrationJob;
|
2020-02-10 21:29:15 +01:00
|
|
|
import org.thoughtcrime.securesms.migrations.StickerAdditionMigrationJob;
|
2020-02-13 19:22:21 +01:00
|
|
|
import org.thoughtcrime.securesms.migrations.StickerLaunchMigrationJob;
|
2020-04-02 23:09:25 +02:00
|
|
|
import org.thoughtcrime.securesms.migrations.StorageCapabilityMigrationJob;
|
2020-02-10 19:42:43 +01:00
|
|
|
import org.thoughtcrime.securesms.migrations.StorageServiceMigrationJob;
|
2019-09-07 05:40:06 +02:00
|
|
|
import org.thoughtcrime.securesms.migrations.UuidMigrationJob;
|
2019-03-28 16:56:35 +01:00
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
public final class JobManagerFactories {
|
|
|
|
|
|
|
|
public static Map<String, Job.Factory> getJobFactories(@NonNull Application application) {
|
|
|
|
return new HashMap<String, Job.Factory>() {{
|
2019-07-03 21:07:00 +02:00
|
|
|
put(AttachmentCopyJob.KEY, new AttachmentCopyJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(AttachmentDownloadJob.KEY, new AttachmentDownloadJob.Factory());
|
|
|
|
put(AttachmentUploadJob.KEY, new AttachmentUploadJob.Factory());
|
2020-02-13 19:22:21 +01:00
|
|
|
put(AttachmentMarkUploadedJob.KEY, new AttachmentMarkUploadedJob.Factory());
|
2019-08-06 22:52:15 +02:00
|
|
|
put(AttachmentCompressionJob.KEY, new AttachmentCompressionJob.Factory());
|
2020-04-07 22:55:33 +02:00
|
|
|
put(AvatarGroupsV1DownloadJob.KEY, new AvatarGroupsV1DownloadJob.Factory());
|
|
|
|
put(AvatarGroupsV2DownloadJob.KEY, new AvatarGroupsV2DownloadJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(CleanPreKeysJob.KEY, new CleanPreKeysJob.Factory());
|
|
|
|
put(CreateSignedPreKeyJob.KEY, new CreateSignedPreKeyJob.Factory());
|
2019-08-07 20:22:51 +02:00
|
|
|
put(DirectoryRefreshJob.KEY, new DirectoryRefreshJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(FcmRefreshJob.KEY, new FcmRefreshJob.Factory());
|
2020-02-21 19:52:27 +01:00
|
|
|
put(LeaveGroupJob.KEY, new LeaveGroupJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(LocalBackupJob.KEY, new LocalBackupJob.Factory());
|
|
|
|
put(MmsDownloadJob.KEY, new MmsDownloadJob.Factory());
|
|
|
|
put(MmsReceiveJob.KEY, new MmsReceiveJob.Factory());
|
|
|
|
put(MmsSendJob.KEY, new MmsSendJob.Factory());
|
|
|
|
put(MultiDeviceBlockedUpdateJob.KEY, new MultiDeviceBlockedUpdateJob.Factory());
|
|
|
|
put(MultiDeviceConfigurationUpdateJob.KEY, new MultiDeviceConfigurationUpdateJob.Factory());
|
|
|
|
put(MultiDeviceContactUpdateJob.KEY, new MultiDeviceContactUpdateJob.Factory());
|
|
|
|
put(MultiDeviceGroupUpdateJob.KEY, new MultiDeviceGroupUpdateJob.Factory());
|
2019-09-26 16:12:51 +02:00
|
|
|
put(MultiDeviceKeysUpdateJob.KEY, new MultiDeviceKeysUpdateJob.Factory());
|
2020-02-21 19:52:27 +01:00
|
|
|
put(MultiDeviceMessageRequestResponseJob.KEY, new MultiDeviceMessageRequestResponseJob.Factory());
|
2019-11-08 21:33:10 +01:00
|
|
|
put(MultiDeviceProfileContentUpdateJob.KEY, new MultiDeviceProfileContentUpdateJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(MultiDeviceProfileKeyUpdateJob.KEY, new MultiDeviceProfileKeyUpdateJob.Factory());
|
|
|
|
put(MultiDeviceReadUpdateJob.KEY, new MultiDeviceReadUpdateJob.Factory());
|
2019-04-17 16:21:30 +02:00
|
|
|
put(MultiDeviceStickerPackOperationJob.KEY, new MultiDeviceStickerPackOperationJob.Factory());
|
|
|
|
put(MultiDeviceStickerPackSyncJob.KEY, new MultiDeviceStickerPackSyncJob.Factory());
|
2019-09-26 16:12:51 +02:00
|
|
|
put(MultiDeviceStorageSyncRequestJob.KEY, new MultiDeviceStorageSyncRequestJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(MultiDeviceVerifiedUpdateJob.KEY, new MultiDeviceVerifiedUpdateJob.Factory());
|
2019-08-01 01:33:56 +02:00
|
|
|
put(MultiDeviceViewOnceOpenJob.KEY, new MultiDeviceViewOnceOpenJob.Factory());
|
2020-04-16 14:30:46 +02:00
|
|
|
put(ProfileKeySendJob.KEY, new ProfileKeySendJob.Factory());
|
2019-12-20 22:50:50 +01:00
|
|
|
put(PushDecryptMessageJob.KEY, new PushDecryptMessageJob.Factory());
|
|
|
|
put(PushProcessMessageJob.KEY, new PushProcessMessageJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(PushGroupSendJob.KEY, new PushGroupSendJob.Factory());
|
2020-07-10 17:32:40 +02:00
|
|
|
put(PushGroupSilentUpdateSendJob.KEY, new PushGroupSilentUpdateSendJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(PushGroupUpdateJob.KEY, new PushGroupUpdateJob.Factory());
|
|
|
|
put(PushMediaSendJob.KEY, new PushMediaSendJob.Factory());
|
|
|
|
put(PushNotificationReceiveJob.KEY, new PushNotificationReceiveJob.Factory());
|
|
|
|
put(PushTextSendJob.KEY, new PushTextSendJob.Factory());
|
2019-12-03 22:57:21 +01:00
|
|
|
put(ReactionSendJob.KEY, new ReactionSendJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(RefreshAttributesJob.KEY, new RefreshAttributesJob.Factory());
|
2019-11-08 21:33:10 +01:00
|
|
|
put(RefreshOwnProfileJob.KEY, new RefreshOwnProfileJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(RefreshPreKeysJob.KEY, new RefreshPreKeysJob.Factory());
|
2019-12-19 23:41:21 +01:00
|
|
|
put(RemoteConfigRefreshJob.KEY, new RemoteConfigRefreshJob.Factory());
|
2020-04-15 20:56:58 +02:00
|
|
|
put(RemoteDeleteSendJob.KEY, new RemoteDeleteSendJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(RequestGroupInfoJob.KEY, new RequestGroupInfoJob.Factory());
|
2020-04-16 22:06:18 +02:00
|
|
|
put(ResumableUploadSpecJob.KEY, new ResumableUploadSpecJob.Factory());
|
2020-03-18 21:31:45 +01:00
|
|
|
put(StorageAccountRestoreJob.KEY, new StorageAccountRestoreJob.Factory());
|
2020-05-02 00:13:23 +02:00
|
|
|
put(RequestGroupV2InfoJob.KEY, new RequestGroupV2InfoJob.Factory());
|
2020-05-26 21:02:34 +02:00
|
|
|
put(WakeGroupV2Job.KEY, new WakeGroupV2Job.Factory());
|
2020-05-08 15:46:16 +02:00
|
|
|
put(GroupV2UpdateSelfProfileKeyJob.KEY, new GroupV2UpdateSelfProfileKeyJob.Factory());
|
2019-08-07 20:22:51 +02:00
|
|
|
put(RetrieveProfileAvatarJob.KEY, new RetrieveProfileAvatarJob.Factory());
|
|
|
|
put(RetrieveProfileJob.KEY, new RetrieveProfileJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(RotateCertificateJob.KEY, new RotateCertificateJob.Factory());
|
|
|
|
put(RotateProfileKeyJob.KEY, new RotateProfileKeyJob.Factory());
|
|
|
|
put(RotateSignedPreKeyJob.KEY, new RotateSignedPreKeyJob.Factory());
|
|
|
|
put(SendDeliveryReceiptJob.KEY, new SendDeliveryReceiptJob.Factory());
|
2019-08-07 20:22:51 +02:00
|
|
|
put(SendReadReceiptJob.KEY, new SendReadReceiptJob.Factory(application));
|
2019-03-28 16:56:35 +01:00
|
|
|
put(ServiceOutageDetectionJob.KEY, new ServiceOutageDetectionJob.Factory());
|
|
|
|
put(SmsReceiveJob.KEY, new SmsReceiveJob.Factory());
|
|
|
|
put(SmsSendJob.KEY, new SmsSendJob.Factory());
|
|
|
|
put(SmsSentJob.KEY, new SmsSentJob.Factory());
|
2019-04-17 16:21:30 +02:00
|
|
|
put(StickerDownloadJob.KEY, new StickerDownloadJob.Factory());
|
|
|
|
put(StickerPackDownloadJob.KEY, new StickerPackDownloadJob.Factory());
|
2019-09-26 16:12:51 +02:00
|
|
|
put(StorageForcePushJob.KEY, new StorageForcePushJob.Factory());
|
|
|
|
put(StorageSyncJob.KEY, new StorageSyncJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
put(TrimThreadJob.KEY, new TrimThreadJob.Factory());
|
|
|
|
put(TypingSendJob.KEY, new TypingSendJob.Factory());
|
|
|
|
put(UpdateApkJob.KEY, new UpdateApkJob.Factory());
|
2019-12-20 22:50:50 +01:00
|
|
|
put(MarkerJob.KEY, new MarkerJob.Factory());
|
2019-12-20 21:12:22 +01:00
|
|
|
put(ProfileUploadJob.KEY, new ProfileUploadJob.Factory());
|
2019-07-31 18:53:19 +02:00
|
|
|
|
2019-07-30 01:02:40 +02:00
|
|
|
// Migrations
|
2020-03-25 23:43:02 +01:00
|
|
|
put(AvatarIdRemovalMigrationJob.KEY, new AvatarIdRemovalMigrationJob.Factory());
|
2019-09-23 17:37:01 +02:00
|
|
|
put(AvatarMigrationJob.KEY, new AvatarMigrationJob.Factory());
|
2019-12-13 07:23:32 +01:00
|
|
|
put(CachedAttachmentsMigrationJob.KEY, new CachedAttachmentsMigrationJob.Factory());
|
2019-07-30 01:02:40 +02:00
|
|
|
put(DatabaseMigrationJob.KEY, new DatabaseMigrationJob.Factory());
|
|
|
|
put(LegacyMigrationJob.KEY, new LegacyMigrationJob.Factory());
|
|
|
|
put(MigrationCompleteJob.KEY, new MigrationCompleteJob.Factory());
|
2020-05-30 00:16:38 +02:00
|
|
|
put(PinReminderMigrationJob.KEY, new PinReminderMigrationJob.Factory());
|
2019-08-27 00:09:01 +02:00
|
|
|
put(RecipientSearchMigrationJob.KEY, new RecipientSearchMigrationJob.Factory());
|
2020-02-10 21:29:15 +01:00
|
|
|
put(RegistrationPinV2MigrationJob.KEY, new RegistrationPinV2MigrationJob.Factory());
|
2019-12-13 07:23:32 +01:00
|
|
|
put(StickerLaunchMigrationJob.KEY, new StickerLaunchMigrationJob.Factory());
|
2020-02-10 21:29:15 +01:00
|
|
|
put(StickerAdditionMigrationJob.KEY, new StickerAdditionMigrationJob.Factory());
|
2020-04-02 23:09:25 +02:00
|
|
|
put(StorageCapabilityMigrationJob.KEY, new StorageCapabilityMigrationJob.Factory());
|
2020-02-10 19:42:43 +01:00
|
|
|
put(StorageServiceMigrationJob.KEY, new StorageServiceMigrationJob.Factory());
|
2019-09-07 05:40:06 +02:00
|
|
|
put(UuidMigrationJob.KEY, new UuidMigrationJob.Factory());
|
2020-07-07 17:00:29 +02:00
|
|
|
put(ProfileMigrationJob.KEY, new ProfileMigrationJob.Factory());
|
2019-07-30 01:02:40 +02:00
|
|
|
|
2019-07-31 18:53:19 +02:00
|
|
|
// Dead jobs
|
2020-03-02 16:22:37 +01:00
|
|
|
put(FailingJob.KEY, new FailingJob.Factory());
|
|
|
|
put(PassingMigrationJob.KEY, new PassingMigrationJob.Factory());
|
2019-07-31 18:53:19 +02:00
|
|
|
put("PushContentReceiveJob", new FailingJob.Factory());
|
2019-08-06 22:52:15 +02:00
|
|
|
put("AttachmentUploadJob", new FailingJob.Factory());
|
|
|
|
put("MmsSendJob", new FailingJob.Factory());
|
2019-11-21 17:10:13 +01:00
|
|
|
put("RefreshUnidentifiedDeliveryAbilityJob", new FailingJob.Factory());
|
2020-03-02 16:22:37 +01:00
|
|
|
put("Argon2TestJob", new FailingJob.Factory());
|
|
|
|
put("Argon2TestMigrationJob", new PassingMigrationJob.Factory());
|
2020-04-02 23:09:25 +02:00
|
|
|
put("StorageKeyRotationMigrationJob", new PassingMigrationJob.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Map<String, Constraint.Factory> getConstraintFactories(@NonNull Application application) {
|
|
|
|
return new HashMap<String, Constraint.Factory>() {{
|
2020-05-01 18:44:53 +02:00
|
|
|
put(NetworkConstraint.KEY, new NetworkConstraint.Factory(application));
|
|
|
|
put(NetworkOrCellServiceConstraint.KEY, new NetworkOrCellServiceConstraint.Factory(application));
|
|
|
|
put(NetworkOrCellServiceConstraint.LEGACY_KEY, new NetworkOrCellServiceConstraint.Factory(application));
|
|
|
|
put(SqlCipherMigrationConstraint.KEY, new SqlCipherMigrationConstraint.Factory(application));
|
2020-05-27 17:00:04 +02:00
|
|
|
put(WebsocketDrainedConstraint.KEY, new WebsocketDrainedConstraint.Factory());
|
2019-03-28 16:56:35 +01:00
|
|
|
}};
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<ConstraintObserver> getConstraintObservers(@NonNull Application application) {
|
2019-07-23 00:06:26 +02:00
|
|
|
return Arrays.asList(CellServiceConstraintObserver.getInstance(application),
|
2019-03-28 16:56:35 +01:00
|
|
|
new NetworkConstraintObserver(application),
|
2020-05-27 17:00:04 +02:00
|
|
|
new SqlCipherMigrationConstraintObserver(),
|
|
|
|
new WebsocketDrainedConstraintObserver());
|
2019-03-28 16:56:35 +01:00
|
|
|
}
|
2019-08-22 04:14:38 +02:00
|
|
|
|
2019-08-07 20:22:51 +02:00
|
|
|
public static List<JobMigration> getJobMigrations(@NonNull Application application) {
|
2019-09-26 16:53:46 +02:00
|
|
|
return Arrays.asList(new RecipientIdJobMigration(application),
|
2019-09-27 20:18:15 +02:00
|
|
|
new RecipientIdFollowUpJobMigration(),
|
2020-02-19 23:08:34 +01:00
|
|
|
new RecipientIdFollowUpJobMigration2(),
|
2020-03-07 00:51:33 +01:00
|
|
|
new SendReadReceiptsJobMigration(DatabaseFactory.getMmsSmsDatabase(application)),
|
2020-06-09 01:04:55 +02:00
|
|
|
new PushProcessMessageQueueJobMigration(application),
|
|
|
|
new RetrieveProfileJobMigration());
|
2019-08-22 04:14:38 +02:00
|
|
|
}
|
2019-03-28 16:56:35 +01:00
|
|
|
}
|