mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 14:18:26 +00:00
Remove MasterSecret job.
It's no longer necessary.
This commit is contained in:
parent
776b0e23ae
commit
a3411072ba
@ -30,12 +30,11 @@ public abstract class Job extends Worker implements Serializable {
|
||||
|
||||
private static final WorkLockManager WORK_LOCK_MANAGER = new WorkLockManager();
|
||||
|
||||
static final String KEY_RETRY_COUNT = "Job_retry_count";
|
||||
static final String KEY_RETRY_UNTIL = "Job_retry_until";
|
||||
static final String KEY_SUBMIT_TIME = "Job_submit_time";
|
||||
static final String KEY_REQUIRES_NETWORK = "Job_requires_network";
|
||||
static final String KEY_REQUIRES_MASTER_SECRET = "Job_requires_master_secret";
|
||||
static final String KEY_REQUIRES_SQLCIPHER = "Job_requires_sqlcipher";
|
||||
static final String KEY_RETRY_COUNT = "Job_retry_count";
|
||||
static final String KEY_RETRY_UNTIL = "Job_retry_until";
|
||||
static final String KEY_SUBMIT_TIME = "Job_submit_time";
|
||||
static final String KEY_REQUIRES_NETWORK = "Job_requires_network";
|
||||
static final String KEY_REQUIRES_SQLCIPHER = "Job_requires_sqlcipher";
|
||||
|
||||
private JobParameters parameters;
|
||||
|
||||
@ -213,10 +212,6 @@ public abstract class Job extends Worker implements Serializable {
|
||||
private boolean requirementsMet(@NonNull Data data) {
|
||||
boolean met = true;
|
||||
|
||||
if (data.getBoolean(KEY_REQUIRES_MASTER_SECRET, false)) {
|
||||
met &= new MasterSecretRequirement(getApplicationContext()).isPresent();
|
||||
}
|
||||
|
||||
if (data.getBoolean(KEY_REQUIRES_SQLCIPHER, false)) {
|
||||
met &= new SqlCipherMigrationRequirement(getApplicationContext()).isPresent();
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ public class JobManager {
|
||||
.putLong(Job.KEY_RETRY_UNTIL, jobParameters.getRetryUntil())
|
||||
.putLong(Job.KEY_SUBMIT_TIME, System.currentTimeMillis())
|
||||
.putBoolean(Job.KEY_REQUIRES_NETWORK, jobParameters.requiresNetwork())
|
||||
.putBoolean(Job.KEY_REQUIRES_MASTER_SECRET, jobParameters.requiresMasterSecret())
|
||||
.putBoolean(Job.KEY_REQUIRES_SQLCIPHER, jobParameters.requiresSqlCipher());
|
||||
Data data = job.serialize(dataBuilder);
|
||||
|
||||
|
@ -19,7 +19,6 @@ package org.thoughtcrime.securesms.jobmanager;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkBackoffRequirement;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkRequirement;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.Requirement;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.NetworkOrServiceRequirement;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.SqlCipherMigrationRequirement;
|
||||
|
||||
@ -36,7 +35,6 @@ public class JobParameters implements Serializable {
|
||||
|
||||
private final List<Requirement> requirements;
|
||||
private final boolean requiresNetwork;
|
||||
private final boolean requiresMasterSecret;
|
||||
private final boolean requiresSqlCipher;
|
||||
private final int retryCount;
|
||||
private final long retryUntil;
|
||||
@ -46,19 +44,17 @@ public class JobParameters implements Serializable {
|
||||
private JobParameters(String groupId,
|
||||
boolean ignoreDuplicates,
|
||||
boolean requiresNetwork,
|
||||
boolean requiresMasterSecret,
|
||||
boolean requiresSqlCipher,
|
||||
int retryCount,
|
||||
long retryUntil)
|
||||
{
|
||||
this.groupId = groupId;
|
||||
this.ignoreDuplicates = ignoreDuplicates;
|
||||
this.requirements = Collections.emptyList();
|
||||
this.requiresNetwork = requiresNetwork;
|
||||
this.requiresMasterSecret = requiresMasterSecret;
|
||||
this.requiresSqlCipher = requiresSqlCipher;
|
||||
this.retryCount = retryCount;
|
||||
this.retryUntil = retryUntil;
|
||||
this.groupId = groupId;
|
||||
this.ignoreDuplicates = ignoreDuplicates;
|
||||
this.requirements = Collections.emptyList();
|
||||
this.requiresNetwork = requiresNetwork;
|
||||
this.requiresSqlCipher = requiresSqlCipher;
|
||||
this.retryCount = retryCount;
|
||||
this.retryUntil = retryUntil;
|
||||
}
|
||||
|
||||
public boolean shouldIgnoreDuplicates() {
|
||||
@ -69,10 +65,6 @@ public class JobParameters implements Serializable {
|
||||
return requiresNetwork || hasNetworkRequirement(requirements);
|
||||
}
|
||||
|
||||
public boolean requiresMasterSecret() {
|
||||
return requiresMasterSecret || hasMasterSecretRequirement(requirements);
|
||||
}
|
||||
|
||||
public boolean requiresSqlCipher() {
|
||||
return requiresSqlCipher || hasSqlCipherRequirement(requirements);
|
||||
}
|
||||
@ -92,18 +84,6 @@ public class JobParameters implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasMasterSecretRequirement(List<Requirement> requirements) {
|
||||
if (requirements == null || requirements.size() == 0) return false;
|
||||
|
||||
for (Requirement requirement : requirements) {
|
||||
if (requirement instanceof MasterSecretRequirement) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasSqlCipherRequirement(List<Requirement> requirements) {
|
||||
if (requirements == null || requirements.size() == 0) return false;
|
||||
|
||||
@ -142,19 +122,12 @@ public class JobParameters implements Serializable {
|
||||
private boolean ignoreDuplicates = false;
|
||||
private boolean requiresNetwork = false;
|
||||
private boolean requiresSqlCipher = false;
|
||||
private boolean requiresMasterSecret = false;
|
||||
|
||||
public Builder withNetworkRequirement() {
|
||||
requiresNetwork = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Builder withMasterSecretRequirement() {
|
||||
requiresMasterSecret = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Builder withSqlCipherRequirement() {
|
||||
requiresSqlCipher = true;
|
||||
@ -216,7 +189,7 @@ public class JobParameters implements Serializable {
|
||||
* @return the JobParameters instance that describes a Job.
|
||||
*/
|
||||
public JobParameters create() {
|
||||
return new JobParameters(groupId, ignoreDuplicates, requiresNetwork, requiresMasterSecret, requiresSqlCipher, retryCount, System.currentTimeMillis() + retryDuration);
|
||||
return new JobParameters(groupId, ignoreDuplicates, requiresNetwork, requiresSqlCipher, retryCount, System.currentTimeMillis() + retryDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class AttachmentDownloadJob extends MasterSecretJob implements InjectableType {
|
||||
public class AttachmentDownloadJob extends ContextJob implements InjectableType {
|
||||
private static final long serialVersionUID = 2L;
|
||||
private static final int MAX_ATTACHMENT_SIZE = 150 * 1024 * 1024;
|
||||
private static final String TAG = AttachmentDownloadJob.class.getSimpleName();
|
||||
@ -63,7 +63,6 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
|
||||
public AttachmentDownloadJob(Context context, long messageId, AttachmentId attachmentId, boolean manual) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withGroupId(AttachmentDownloadJob.class.getCanonicalName())
|
||||
.withMasterSecretRequirement()
|
||||
.withNetworkRequirement()
|
||||
.create());
|
||||
|
||||
@ -96,7 +95,7 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws IOException {
|
||||
public void onRun() throws IOException {
|
||||
Log.i(TAG, "onRun() messageId: " + messageId + " partRowId: " + partRowId + " partUniqueId: " + partUniqueId + " manual: " + manual);
|
||||
|
||||
final AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context);
|
||||
@ -135,7 +134,7 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
protected boolean onShouldRetry(Exception exception) {
|
||||
return (exception instanceof PushNetworkException);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class AvatarDownloadJob extends MasterSecretJob implements InjectableType {
|
||||
public class AvatarDownloadJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final int MAX_AVATAR_SIZE = 20 * 1024 * 1024;
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -50,7 +50,6 @@ public class AvatarDownloadJob extends MasterSecretJob implements InjectableType
|
||||
|
||||
public AvatarDownloadJob(Context context, @NonNull byte[] groupId) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withMasterSecretRequirement()
|
||||
.withNetworkRequirement()
|
||||
.create());
|
||||
|
||||
@ -72,7 +71,7 @@ public class AvatarDownloadJob extends MasterSecretJob implements InjectableType
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws IOException {
|
||||
public void onRun() throws IOException {
|
||||
String encodeId = GroupUtil.getEncodedId(groupId, false);
|
||||
GroupDatabase database = DatabaseFactory.getGroupDatabase(context);
|
||||
Optional<GroupRecord> record = database.getGroup(encodeId);
|
||||
@ -117,7 +116,7 @@ public class AvatarDownloadJob extends MasterSecretJob implements InjectableType
|
||||
public void onCanceled() {}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof IOException) return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import androidx.work.Data;
|
||||
|
||||
import static org.thoughtcrime.securesms.dependencies.AxolotlStorageModule.SignedPreKeyStoreFactory;
|
||||
|
||||
public class CleanPreKeysJob extends MasterSecretJob implements InjectableType {
|
||||
public class CleanPreKeysJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final String TAG = CleanPreKeysJob.class.getSimpleName();
|
||||
|
||||
@ -46,7 +46,6 @@ public class CleanPreKeysJob extends MasterSecretJob implements InjectableType {
|
||||
public CleanPreKeysJob(Context context) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withGroupId(CleanPreKeysJob.class.getSimpleName())
|
||||
.withMasterSecretRequirement()
|
||||
.withRetryCount(5)
|
||||
.create());
|
||||
}
|
||||
@ -61,7 +60,7 @@ public class CleanPreKeysJob extends MasterSecretJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws IOException {
|
||||
public void onRun() throws IOException {
|
||||
try {
|
||||
Log.i(TAG, "Cleaning prekeys...");
|
||||
|
||||
@ -99,7 +98,7 @@ public class CleanPreKeysJob extends MasterSecretJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception throwable) {
|
||||
public boolean onShouldRetry(Exception throwable) {
|
||||
if (throwable instanceof NonSuccessfulResponseCodeException) return false;
|
||||
if (throwable instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
|
@ -22,7 +22,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class CreateSignedPreKeyJob extends MasterSecretJob implements InjectableType {
|
||||
public class CreateSignedPreKeyJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -37,7 +37,6 @@ public class CreateSignedPreKeyJob extends MasterSecretJob implements Injectable
|
||||
public CreateSignedPreKeyJob(Context context) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withNetworkRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.withGroupId(CreateSignedPreKeyJob.class.getSimpleName())
|
||||
.create());
|
||||
}
|
||||
@ -52,7 +51,7 @@ public class CreateSignedPreKeyJob extends MasterSecretJob implements Injectable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws IOException {
|
||||
public void onRun() throws IOException {
|
||||
if (TextSecurePreferences.isSignedPreKeyRegistered(context)) {
|
||||
Log.w(TAG, "Signed prekey already registered...");
|
||||
return;
|
||||
@ -74,7 +73,7 @@ public class CreateSignedPreKeyJob extends MasterSecretJob implements Injectable
|
||||
public void onCanceled() {}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobParameters;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
|
||||
public abstract class MasterSecretJob extends ContextJob {
|
||||
|
||||
public MasterSecretJob(Context context, JobParameters parameters) {
|
||||
super(context, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun() throws Exception {
|
||||
MasterSecret masterSecret = getMasterSecret();
|
||||
onRun(masterSecret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof RequirementNotMetException) return true;
|
||||
return onShouldRetryThrowable(exception);
|
||||
}
|
||||
|
||||
public abstract void onRun(MasterSecret masterSecret) throws Exception;
|
||||
public abstract boolean onShouldRetryThrowable(Exception exception);
|
||||
|
||||
private MasterSecret getMasterSecret() throws RequirementNotMetException {
|
||||
MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
|
||||
|
||||
if (masterSecret == null) throw new RequirementNotMetException();
|
||||
else return masterSecret;
|
||||
}
|
||||
|
||||
protected static class RequirementNotMetException extends Exception {}
|
||||
|
||||
}
|
@ -49,7 +49,7 @@ import java.util.Set;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class MmsDownloadJob extends MasterSecretJob {
|
||||
public class MmsDownloadJob extends ContextJob {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -69,8 +69,6 @@ public class MmsDownloadJob extends MasterSecretJob {
|
||||
|
||||
public MmsDownloadJob(Context context, long messageId, long threadId, boolean automatic) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withMasterSecretRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.withGroupId("mms-operation")
|
||||
.create());
|
||||
|
||||
@ -103,7 +101,7 @@ public class MmsDownloadJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) {
|
||||
public void onRun() {
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
Optional<MmsDatabase.MmsNotificationInfo> notification = database.getNotification(messageId);
|
||||
|
||||
@ -186,7 +184,7 @@ public class MmsDownloadJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import com.google.android.mms.smil.SmilHelper;
|
||||
import com.klinker.android.send_message.Utils;
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||
@ -70,7 +69,6 @@ public class MmsSendJob extends SendJob {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withGroupId("mms-operation")
|
||||
.withNetworkRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.withRetryCount(15)
|
||||
.create());
|
||||
|
||||
@ -88,7 +86,7 @@ public class MmsSendJob extends SendJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend(MasterSecret masterSecret) throws MmsException, NoSuchMessageException, IOException {
|
||||
public void onSend() throws MmsException, NoSuchMessageException, IOException {
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
|
||||
@ -124,7 +122,7 @@ public class MmsSendJob extends SendJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class MultiDeviceBlockedUpdateJob extends MasterSecretJob implements InjectableType {
|
||||
public class MultiDeviceBlockedUpdateJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -45,7 +45,6 @@ public class MultiDeviceBlockedUpdateJob extends MasterSecretJob implements Inje
|
||||
public MultiDeviceBlockedUpdateJob(Context context) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withNetworkRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.withGroupId(MultiDeviceBlockedUpdateJob.class.getSimpleName())
|
||||
.create());
|
||||
}
|
||||
@ -60,7 +59,7 @@ public class MultiDeviceBlockedUpdateJob extends MasterSecretJob implements Inje
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret)
|
||||
public void onRun()
|
||||
throws IOException, UntrustedIdentityException
|
||||
{
|
||||
if (!TextSecurePreferences.isMultiDevice(context)) {
|
||||
@ -90,7 +89,7 @@ public class MultiDeviceBlockedUpdateJob extends MasterSecretJob implements Inje
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import android.support.annotation.Nullable;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
||||
import org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
@ -52,7 +51,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class MultiDeviceContactUpdateJob extends MasterSecretJob implements InjectableType {
|
||||
public class MultiDeviceContactUpdateJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
@ -88,7 +87,6 @@ public class MultiDeviceContactUpdateJob extends MasterSecretJob implements Inje
|
||||
public MultiDeviceContactUpdateJob(@NonNull Context context, @Nullable Address address, boolean forceSync) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withNetworkRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.withGroupId(MultiDeviceContactUpdateJob.class.getSimpleName())
|
||||
.create());
|
||||
|
||||
@ -112,7 +110,7 @@ public class MultiDeviceContactUpdateJob extends MasterSecretJob implements Inje
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret)
|
||||
public void onRun()
|
||||
throws IOException, UntrustedIdentityException, NetworkException
|
||||
{
|
||||
if (!TextSecurePreferences.isMultiDevice(context)) {
|
||||
@ -217,7 +215,7 @@ public class MultiDeviceContactUpdateJob extends MasterSecretJob implements Inje
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class MultiDeviceGroupUpdateJob extends MasterSecretJob implements InjectableType {
|
||||
public class MultiDeviceGroupUpdateJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String TAG = MultiDeviceGroupUpdateJob.class.getSimpleName();
|
||||
@ -52,7 +52,6 @@ public class MultiDeviceGroupUpdateJob extends MasterSecretJob implements Inject
|
||||
public MultiDeviceGroupUpdateJob(Context context) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withNetworkRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.withGroupId(MultiDeviceGroupUpdateJob.class.getSimpleName())
|
||||
.create());
|
||||
}
|
||||
@ -67,7 +66,7 @@ public class MultiDeviceGroupUpdateJob extends MasterSecretJob implements Inject
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws Exception {
|
||||
public void onRun() throws Exception {
|
||||
if (!TextSecurePreferences.isMultiDevice(context)) {
|
||||
Log.i(TAG, "Not multi device, aborting...");
|
||||
return;
|
||||
@ -118,7 +117,7 @@ public class MultiDeviceGroupUpdateJob extends MasterSecretJob implements Inject
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class MultiDeviceProfileKeyUpdateJob extends MasterSecretJob implements InjectableType {
|
||||
public class MultiDeviceProfileKeyUpdateJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String TAG = MultiDeviceProfileKeyUpdateJob.class.getSimpleName();
|
||||
@ -60,7 +60,7 @@ public class MultiDeviceProfileKeyUpdateJob extends MasterSecretJob implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
|
||||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
if (!TextSecurePreferences.isMultiDevice(getContext())) {
|
||||
Log.i(TAG, "Not multi device...");
|
||||
return;
|
||||
@ -91,7 +91,7 @@ public class MultiDeviceProfileKeyUpdateJob extends MasterSecretJob implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class MultiDeviceReadUpdateJob extends MasterSecretJob implements InjectableType {
|
||||
public class MultiDeviceReadUpdateJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String TAG = MultiDeviceReadUpdateJob.class.getSimpleName();
|
||||
@ -50,7 +50,6 @@ public class MultiDeviceReadUpdateJob extends MasterSecretJob implements Injecta
|
||||
public MultiDeviceReadUpdateJob(Context context, List<SyncMessageId> messageIds) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withNetworkRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.create());
|
||||
|
||||
this.messageIds = new LinkedList<>();
|
||||
@ -90,7 +89,7 @@ public class MultiDeviceReadUpdateJob extends MasterSecretJob implements Injecta
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws IOException, UntrustedIdentityException {
|
||||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
if (!TextSecurePreferences.isMultiDevice(context)) {
|
||||
Log.i(TAG, "Not multi device...");
|
||||
return;
|
||||
@ -106,7 +105,7 @@ public class MultiDeviceReadUpdateJob extends MasterSecretJob implements Injecta
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
return exception instanceof PushNetworkException;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,6 @@ import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -77,7 +76,6 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
public PushGroupSendJob(Context context, long messageId, @NonNull Address destination, @Nullable Address filterAddress) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withGroupId(destination.toGroupString())
|
||||
.withMasterSecretRequirement()
|
||||
.withNetworkRequirement()
|
||||
.withRetryDuration(TimeUnit.DAYS.toMillis(1))
|
||||
.create());
|
||||
@ -190,7 +188,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof IOException) return true;
|
||||
if (exception instanceof RetryLaterException) return true;
|
||||
return false;
|
||||
|
@ -136,10 +136,8 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof RequirementNotMetException) return true;
|
||||
if (exception instanceof RetryLaterException) return true;
|
||||
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof RetryLaterException) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,6 @@ public abstract class PushSendJob extends SendJob {
|
||||
protected static JobParameters constructParameters(Address destination) {
|
||||
JobParameters.Builder builder = JobParameters.newBuilder();
|
||||
builder.withGroupId(destination.serialize());
|
||||
builder.withMasterSecretRequirement();
|
||||
builder.withNetworkRequirement();
|
||||
builder.withRetryDuration(TimeUnit.DAYS.toMillis(1));
|
||||
|
||||
@ -58,7 +57,7 @@ public abstract class PushSendJob extends SendJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onSend(MasterSecret masterSecret) throws Exception {
|
||||
protected final void onSend() throws Exception {
|
||||
if (TextSecurePreferences.getSignedPreKeyFailureCount(context) > 5) {
|
||||
ApplicationContext.getInstance(context)
|
||||
.getJobManager()
|
||||
|
@ -129,7 +129,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof RetryLaterException) return true;
|
||||
|
||||
return false;
|
||||
|
@ -26,7 +26,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class RefreshPreKeysJob extends MasterSecretJob implements InjectableType {
|
||||
public class RefreshPreKeysJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final String TAG = RefreshPreKeysJob.class.getSimpleName();
|
||||
|
||||
@ -42,7 +42,6 @@ public class RefreshPreKeysJob extends MasterSecretJob implements InjectableType
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withGroupId(RefreshPreKeysJob.class.getSimpleName())
|
||||
.withNetworkRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.withRetryCount(5)
|
||||
.create());
|
||||
}
|
||||
@ -57,7 +56,7 @@ public class RefreshPreKeysJob extends MasterSecretJob implements InjectableType
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws IOException {
|
||||
public void onRun() throws IOException {
|
||||
if (!TextSecurePreferences.isPushRegistered(context)) return;
|
||||
|
||||
int availableKeys = accountManager.getPreKeysCount();
|
||||
@ -84,7 +83,7 @@ public class RefreshPreKeysJob extends MasterSecretJob implements InjectableType
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof NonSuccessfulResponseCodeException) return false;
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import javax.inject.Inject;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class RotateSignedPreKeyJob extends MasterSecretJob implements InjectableType {
|
||||
public class RotateSignedPreKeyJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final String TAG = RotateSignedPreKeyJob.class.getName();
|
||||
|
||||
@ -35,7 +35,6 @@ public class RotateSignedPreKeyJob extends MasterSecretJob implements Injectable
|
||||
public RotateSignedPreKeyJob(Context context) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withNetworkRequirement()
|
||||
.withMasterSecretRequirement()
|
||||
.withRetryCount(5)
|
||||
.create());
|
||||
}
|
||||
@ -50,7 +49,7 @@ public class RotateSignedPreKeyJob extends MasterSecretJob implements Injectable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) throws Exception {
|
||||
public void onRun() throws Exception {
|
||||
Log.i(TAG, "Rotating signed prekey...");
|
||||
|
||||
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context);
|
||||
@ -68,7 +67,7 @@ public class RotateSignedPreKeyJob extends MasterSecretJob implements Injectable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
return exception instanceof PushNetworkException;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class SendJob extends MasterSecretJob {
|
||||
public abstract class SendJob extends ContextJob {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final static String TAG = SendJob.class.getSimpleName();
|
||||
@ -38,7 +38,7 @@ public abstract class SendJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onRun(MasterSecret masterSecret) throws Exception {
|
||||
public final void onRun() throws Exception {
|
||||
if (Util.getDaysTillBuildExpiry() <= 0) {
|
||||
throw new TextSecureExpiredException(String.format("TextSecure expired (build %d, now %d)",
|
||||
BuildConfig.BUILD_TIMESTAMP,
|
||||
@ -46,11 +46,11 @@ public abstract class SendJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
Log.i(TAG, "Starting message send attempt");
|
||||
onSend(masterSecret);
|
||||
onSend();
|
||||
Log.i(TAG, "Message send completed");
|
||||
}
|
||||
|
||||
protected abstract void onSend(MasterSecret masterSecret) throws Exception;
|
||||
protected abstract void onSend() throws Exception;
|
||||
|
||||
protected void markAttachmentsUploaded(long messageId, @NonNull List<Attachment> attachments) {
|
||||
AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context);
|
||||
|
@ -76,7 +76,7 @@ public class SmsSendJob extends SendJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend(MasterSecret masterSecret) throws NoSuchMessageException, RequirementNotMetException, TooManyRetriesException {
|
||||
public void onSend() throws NoSuchMessageException, RequirementNotMetException, TooManyRetriesException {
|
||||
if (!requirementsMet()) {
|
||||
Log.w(TAG, "No service. Retrying.");
|
||||
throw new RequirementNotMetException();
|
||||
@ -107,7 +107,7 @@ public class SmsSendJob extends SendJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception throwable) {
|
||||
public boolean onShouldRetry(Exception throwable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -250,7 +250,6 @@ public class SmsSendJob extends SendJob {
|
||||
|
||||
private static JobParameters constructParameters(String name) {
|
||||
JobParameters.Builder builder = JobParameters.newBuilder()
|
||||
.withMasterSecretRequirement()
|
||||
.withRetryCount(MAX_ATTEMPTS)
|
||||
.withGroupId(name);
|
||||
return builder.create();
|
||||
@ -258,4 +257,6 @@ public class SmsSendJob extends SendJob {
|
||||
|
||||
private static class TooManyRetriesException extends Exception { }
|
||||
|
||||
private static class RequirementNotMetException extends Exception { }
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.service.SmsDeliveryListener;
|
||||
|
||||
import androidx.work.Data;
|
||||
|
||||
public class SmsSentJob extends MasterSecretJob {
|
||||
public class SmsSentJob extends ContextJob {
|
||||
|
||||
private static final long serialVersionUID = -2624694558755317560L;
|
||||
private static final String TAG = SmsSentJob.class.getSimpleName();
|
||||
@ -41,7 +41,6 @@ public class SmsSentJob extends MasterSecretJob {
|
||||
|
||||
public SmsSentJob(Context context, long messageId, String action, int result, int runAttempt) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withMasterSecretRequirement()
|
||||
.create());
|
||||
|
||||
this.messageId = messageId;
|
||||
@ -68,7 +67,7 @@ public class SmsSentJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(MasterSecret masterSecret) {
|
||||
public void onRun() {
|
||||
Log.i(TAG, "Got SMS callback: " + action + " , " + result);
|
||||
|
||||
switch (action) {
|
||||
@ -82,7 +81,7 @@ public class SmsSentJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception throwable) {
|
||||
public boolean onShouldRetry(Exception throwable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user