mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Update backoff logic of ClearFallbackKbsEnclaveJob.
This commit is contained in:
@@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.pin.KbsEnclaves;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -80,12 +81,30 @@ public class ClearFallbackKbsEnclaveJob extends BaseJob {
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(@NonNull Exception e) {
|
||||
if (e instanceof NonSuccessfulResponseCodeException) {
|
||||
switch (((NonSuccessfulResponseCodeException) e).getCode()) {
|
||||
case 404:
|
||||
return getRunAttempt() < 3;
|
||||
case 508:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextRunAttemptBackoff(int pastAttemptCount, @NonNull Exception e) {
|
||||
if (e instanceof NonSuccessfulResponseCodeException && ((NonSuccessfulResponseCodeException) e).getCode() == 404) {
|
||||
return TimeUnit.DAYS.toMillis(1);
|
||||
} else {
|
||||
return super.getNextRunAttemptBackoff(pastAttemptCount, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
throw new AssertionError("This job should never fail. " + getClass().getSimpleName());
|
||||
Log.w(TAG, "Job failed! It is likely that the old enclave is offline.");
|
||||
}
|
||||
|
||||
public static class Factory implements Job.Factory<ClearFallbackKbsEnclaveJob> {
|
||||
|
||||
Reference in New Issue
Block a user