mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Check connection on favicon timeout
This commit is contained in:
parent
eefa6dfa6b
commit
d93292707e
1 changed files with 11 additions and 2 deletions
|
@ -27,6 +27,8 @@ import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
@ -49,6 +51,7 @@ import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -364,7 +367,7 @@ public class ContactInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
if (isRecoverable(ex))
|
if (isRecoverable(ex, context))
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
else {
|
else {
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
|
@ -474,7 +477,13 @@ public class ContactInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isRecoverable(Throwable ex) {
|
private static boolean isRecoverable(Throwable ex, Context context) {
|
||||||
|
if (ex instanceof SocketTimeoutException) {
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
NetworkInfo ni = (cm == null ? null : cm.getActiveNetworkInfo());
|
||||||
|
return (ni == null || !ni.isConnected());
|
||||||
|
}
|
||||||
|
|
||||||
return !(ex instanceof ConnectException ||
|
return !(ex instanceof ConnectException ||
|
||||||
(ex instanceof UnknownHostException &&
|
(ex instanceof UnknownHostException &&
|
||||||
ex.getMessage() != null &&
|
ex.getMessage() != null &&
|
||||||
|
|
Loading…
Reference in a new issue