try the next mirror on any network/HTTP/SSL errors

This labels all network, HTTP, and SSL related errors as CONNECTION_FAILED
so that the mirror selection logic will try the connection again with a new
mirror.
This commit is contained in:
Hans-Christoph Steiner 2018-06-25 11:20:30 +02:00
parent 06e922a35e
commit f1f56abd0f

View File

@ -31,16 +31,24 @@ import android.os.PatternMatcher;
import android.os.Process;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.util.Log;
import org.fdroid.fdroid.ProgressListener;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.SanitizedFile;
import org.fdroid.fdroid.installer.ApkCache;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLKeyException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLProtocolException;
import java.io.File;
import java.io.IOException;
import java.net.ConnectException;
import java.net.HttpRetryException;
import java.net.NoRouteToHostException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
/**
* DownloaderService is a service that handles asynchronous download requests
@ -215,7 +223,10 @@ public class DownloaderService extends Service {
}
} catch (InterruptedException e) {
sendBroadcast(uri, Downloader.ACTION_INTERRUPTED, localFile, repoId, originalUrlString);
} catch (ConnectException | SocketTimeoutException e) {
} catch (ConnectException | HttpRetryException | NoRouteToHostException | SocketTimeoutException
| SSLHandshakeException | SSLKeyException | SSLPeerUnverifiedException | SSLProtocolException
| UnknownHostException e) {
Log.e(TAG, e.getLocalizedMessage());
sendBroadcast(uri, Downloader.ACTION_CONNECTION_FAILED, localFile, repoId, originalUrlString);
} catch (IOException e) {
e.printStackTrace();