mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 11:19:19 +00:00
Let's have JobManager only deal with checked exceptions.
Also, switch to Builder for JobManager construction.
This commit is contained in:
@@ -77,8 +77,8 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
if (throwable instanceof PushNetworkException) return true;
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ public class AvatarDownloadJob extends MasterSecretJob {
|
||||
public void onCanceled() {}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
if (throwable instanceof IOException) return true;
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof IOException) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CleanPreKeysJob extends MasterSecretJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
public boolean onShouldRetryThrowable(Exception throwable) {
|
||||
if (throwable instanceof NonSuccessfulResponseCodeException) return false;
|
||||
if (throwable instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.push.TextSecureCommunicationFactory;
|
||||
import org.thoughtcrime.securesms.util.ParcelUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.jobqueue.EncryptionKeys;
|
||||
@@ -60,8 +59,8 @@ public class CreateSignedPreKeyJob extends ContextJob implements InjectableType
|
||||
public void onCanceled() {}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Throwable throwable) {
|
||||
if (throwable instanceof PushNetworkException) return true;
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,10 +62,10 @@ public class DeliveryReceiptJob extends ContextJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Throwable throwable) {
|
||||
Log.w(TAG, throwable);
|
||||
if (throwable instanceof NonSuccessfulResponseCodeException) return false;
|
||||
if (throwable instanceof PushNetworkException) return true;
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
Log.w(TAG, exception);
|
||||
if (exception instanceof NonSuccessfulResponseCodeException) return false;
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GcmRefreshJob extends ContextJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Throwable throwable) {
|
||||
public boolean onShouldRetry(Exception throwable) {
|
||||
if (throwable instanceof NonSuccessfulResponseCodeException) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,19 +13,19 @@ public abstract class MasterSecretJob extends ContextJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun() throws Throwable {
|
||||
public void onRun() throws Exception {
|
||||
MasterSecret masterSecret = getMasterSecret();
|
||||
onRun(masterSecret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Throwable throwable) {
|
||||
if (throwable instanceof RequirementNotMetException) return true;
|
||||
return onShouldRetryThrowable(throwable);
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
if (exception instanceof RequirementNotMetException) return true;
|
||||
return onShouldRetryThrowable(exception);
|
||||
}
|
||||
|
||||
public abstract void onRun(MasterSecret masterSecret) throws Throwable;
|
||||
public abstract boolean onShouldRetryThrowable(Throwable throwable);
|
||||
public abstract void onRun(MasterSecret masterSecret) throws Exception;
|
||||
public abstract boolean onShouldRetryThrowable(Exception exception);
|
||||
|
||||
private MasterSecret getMasterSecret() throws RequirementNotMetException {
|
||||
MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
|
||||
|
||||
@@ -179,7 +179,7 @@ public class MmsDownloadJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class MmsReceiveJob extends ContextJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Throwable throwable) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class MmsSendJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class PushDecryptJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
if (throwable instanceof IOException) return true;
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof IOException) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
if (throwable instanceof RequirementNotMetException) return true;
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof RequirementNotMetException) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PushReceiveJob extends ContextJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Throwable throwable) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,8 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
if (throwable instanceof RetryLaterException) return true;
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof RetryLaterException) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
||||
import org.thoughtcrime.securesms.push.TextSecureCommunicationFactory;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.jobqueue.JobParameters;
|
||||
import org.whispersystems.jobqueue.requirements.NetworkRequirement;
|
||||
@@ -17,7 +16,6 @@ import org.whispersystems.libaxolotl.IdentityKeyPair;
|
||||
import org.whispersystems.libaxolotl.state.PreKeyRecord;
|
||||
import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
|
||||
import org.whispersystems.textsecure.api.TextSecureAccountManager;
|
||||
import org.whispersystems.textsecure.push.PushServiceSocket;
|
||||
import org.whispersystems.textsecure.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
import org.whispersystems.textsecure.push.exceptions.PushNetworkException;
|
||||
|
||||
@@ -76,9 +74,9 @@ public class RefreshPreKeysJob extends MasterSecretJob implements InjectableType
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
if (throwable instanceof NonSuccessfulResponseCodeException) return false;
|
||||
if (throwable instanceof PushNetworkException) return true;
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof NonSuccessfulResponseCodeException) return false;
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,15 +5,14 @@ import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.AsymmetricMasterCipher;
|
||||
import org.thoughtcrime.securesms.crypto.AsymmetricMasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.SecurityEvent;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.crypto.SecurityEvent;
|
||||
import org.thoughtcrime.securesms.crypto.SmsCipher;
|
||||
import org.thoughtcrime.securesms.crypto.storage.TextSecureAxolotlStore;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.EncryptingSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
@@ -94,7 +93,7 @@ public class SmsDecryptJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class SmsReceiveJob extends ContextJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Throwable throwable) {
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class SmsSendJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
public boolean onShouldRetryThrowable(Exception throwable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SmsSentJob extends MasterSecretJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Throwable throwable) {
|
||||
public boolean onShouldRetryThrowable(Exception throwable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user