kopia lustrzana https://github.com/ryukoposting/Signal-Android
Update backoff logic of ClearFallbackKbsEnclaveJob.
rodzic
c0735c8119
commit
290fbbb9ee
|
@ -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> {
|
||||
|
|
Ładowanie…
Reference in New Issue