hasInternetConnection() will always return true if type=ethernet

This commit is contained in:
Daniel Gultsch 2018-09-06 23:18:06 +02:00
parent eadd0c5f7a
commit accc378c4b

View file

@ -943,7 +943,7 @@ public class XmppConnectionService extends Service {
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
try { try {
final NetworkInfo activeNetwork = cm == null ? null : cm.getActiveNetworkInfo(); final NetworkInfo activeNetwork = cm == null ? null : cm.getActiveNetworkInfo();
return activeNetwork != null && activeNetwork.isConnected(); return activeNetwork != null && (activeNetwork.isConnected() || activeNetwork.getType() == ConnectivityManager.TYPE_ETHERNET);
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(Config.LOGTAG, "unable to check for internet connection", e); Log.d(Config.LOGTAG, "unable to check for internet connection", e);
return true; //if internet connection can not be checked it is probably best to just try return true; //if internet connection can not be checked it is probably best to just try