Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18f44313 authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

remove deprecated code in CommonUtils. haveNetworkConnexion(Context context)

parent d4b39f93
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.media.MediaScannerConnection;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.Uri;
import android.util.Log;
@@ -195,14 +196,13 @@ public abstract class CommonUtils {
        boolean haveConnectedMobile = false;

        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo[] netInfo = cm.getAllNetworkInfo();
        for (NetworkInfo ni : netInfo) {
            if (ni.getType()== ConnectivityManager.TYPE_WIFI) // Replaced the ni.getTypeName by ni.getType to make the test from ObserverServiceTest to work. But looks a better solution in all case
                if (ni.isConnected())
                    haveConnectedWifi = true;
            if (ni.getType()== ConnectivityManager.TYPE_MOBILE)
                if (ni.isConnected())
                    haveConnectedMobile = true;
        Network[] networks = cm.getAllNetworks();
        for (Network network : networks) {
            NetworkInfo networkInfo = cm.getNetworkInfo(network);
            if (networkInfo.getType()== ConnectivityManager.TYPE_WIFI)
                haveConnectedWifi |= networkInfo.isConnected();
            if (networkInfo.getType()== ConnectivityManager.TYPE_MOBILE)
                haveConnectedMobile |= networkInfo.isConnected();
        }
        return haveConnectedWifi || haveConnectedMobile;
    }