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

Commit fa2349ea authored by narinder Rana's avatar narinder Rana
Browse files

refine code

parent be619999
Loading
Loading
Loading
Loading
Loading
+1 −20
Original line number Original line Diff line number Diff line
@@ -26,14 +26,6 @@ public class ConnectivityReceiver
    }
    }


    public static boolean isConnected()  {
    public static boolean isConnected()  {
//        ConnectivityManager
//                cm = (ConnectivityManager) MyApplication.getInstance().getApplicationContext()
//                .getSystemService(Context.CONNECTIVITY_SERVICE);
//        NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
//
//        return activeNetwork != null
//                && activeNetwork.isConnectedOrConnecting();

        try {
        try {
            String command = "ping -c 1 ecloud.global";
            String command = "ping -c 1 ecloud.global";
            return Runtime.getRuntime().exec(command).waitFor() == 0;
            return Runtime.getRuntime().exec(command).waitFor() == 0;
@@ -43,17 +35,6 @@ public class ConnectivityReceiver
     return false;
     return false;
    }
    }


    public boolean isConecctedToInternet() {

        Runtime runtime = Runtime.getRuntime();
        try {
            Process ipProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8");
            int     exitValue = ipProcess.waitFor();
            return (exitValue == 0);
        } catch (IOException e)          { e.printStackTrace(); }
        catch (InterruptedException e) { e.printStackTrace(); }
        return false;
    }




    @Override
    @Override
@@ -70,7 +51,7 @@ public class ConnectivityReceiver
                isConnected = activeNetwork != null
                isConnected = activeNetwork != null
                        && activeNetwork.isConnectedOrConnecting();
                        && activeNetwork.isConnectedOrConnecting();


                Log.e(TAG, "connectivityReceiverListener...isConnected." + isConnected());
                Log.e(TAG, "connectivityReceiverListener...." + isConnected());
                if (connectivityReceiverListener != null) {
                if (connectivityReceiverListener != null) {
                    connectivityReceiverListener.onNetworkConnectionChanged(isConnected);
                    connectivityReceiverListener.onNetworkConnectionChanged(isConnected);
                }
                }