use of org.whispersystems.signalservice.api.push.exceptions.PushNetworkException in project Signal-Android by WhisperSystems.
the class PushNotificationReceiveJob method onRun.
@Override
public void onRun() throws IOException {
BackgroundMessageRetriever retriever = ApplicationDependencies.getBackgroundMessageRetriever();
boolean result = retriever.retrieveMessages(context, foregroundServiceDelayMs, new RestStrategy());
if (result) {
Log.i(TAG, "Successfully pulled messages.");
} else {
throw new PushNetworkException("Failed to pull messages.");
}
}
use of org.whispersystems.signalservice.api.push.exceptions.PushNetworkException in project Signal-Android by WhisperSystems.
the class RecaptchaProofActivity method handleToken.
private void handleToken(@NonNull String token) {
SimpleProgressDialog.DismissibleDialog dialog = SimpleProgressDialog.showDelayed(this, 1000, 500);
SimpleTask.run(() -> {
String challenge = SignalStore.rateLimit().getChallenge();
if (Util.isEmpty(challenge)) {
Log.w(TAG, "No challenge available?");
return new TokenResult(true, false);
}
try {
for (int i = 0; i < 3; i++) {
try {
ApplicationDependencies.getSignalServiceAccountManager().submitRateLimitRecaptchaChallenge(challenge, token);
RateLimitUtil.retryAllRateLimitedMessages(this);
Log.i(TAG, "Successfully completed reCAPTCHA.");
return new TokenResult(true, true);
} catch (PushNetworkException e) {
Log.w(TAG, "Network error during submission. Retrying.", e);
}
}
} catch (IOException e) {
Log.w(TAG, "Terminal failure during submission. Will clear state. May get a 428 later.", e);
return new TokenResult(true, false);
}
return new TokenResult(false, false);
}, result -> {
dialog.dismiss();
if (result.clearState) {
Log.i(TAG, "Considering the response sufficient to clear the slate.");
SignalStore.rateLimit().onProofAccepted();
}
if (!result.success) {
Log.w(TAG, "Response was not a true success.");
Toast.makeText(this, R.string.RecaptchaProofActivity_failed_to_submit, Toast.LENGTH_LONG).show();
}
finish();
});
}
Aggregations