That fuck shit the fascists are using
1package org.tm.archive.migrations;
2
3import androidx.annotation.NonNull;
4import androidx.annotation.Nullable;
5
6import org.tm.archive.contacts.sync.ContactDiscovery;
7import org.tm.archive.jobmanager.Job;
8import org.tm.archive.jobmanager.impl.NetworkConstraint;
9
10import java.io.IOException;
11
12/**
13 * We added a column for keeping track of the phone number type ("mobile", "home", etc) to the
14 * recipient database, and therefore we need to do a directory sync to fill in that column.
15 */
16public class RecipientSearchMigrationJob extends MigrationJob {
17
18 public static final String KEY = "RecipientSearchMigrationJob";
19
20 RecipientSearchMigrationJob() {
21 this(new Job.Parameters.Builder().addConstraint(NetworkConstraint.KEY).build());
22 }
23
24 private RecipientSearchMigrationJob(@NonNull Job.Parameters parameters) {
25 super(parameters);
26 }
27
28 @Override
29 public @NonNull String getFactoryKey() {
30 return KEY;
31 }
32
33 @Override
34 boolean isUiBlocking() {
35 return false;
36 }
37
38 @Override
39 void performMigration() throws Exception {
40 ContactDiscovery.refreshAll(context, false);
41 }
42
43 @Override
44 boolean shouldRetry(@NonNull Exception e) {
45 return e instanceof IOException;
46 }
47
48 public static class Factory implements Job.Factory<RecipientSearchMigrationJob> {
49 @Override
50 public @NonNull RecipientSearchMigrationJob create(@NonNull Parameters parameters, @Nullable byte[] serializedData) {
51 return new RecipientSearchMigrationJob(parameters);
52 }
53 }
54}