Returns {@code true} if the phone is connected to a network, or if we don't have the enough
permissions. Returns {@code false} otherwise.
513833
public static boolean isConnected(Context context) {
    if (!hasPermission(context, ACCESS_NETWORK_STATE)) {
      return true; // Assume we have a connection and try to upload.
    }
    ConnectivityManager cm = getSystemService(context, CONNECTIVITY_SERVICE);
    @SuppressLint("MissingPermission")
    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
  }
344504
public boolean isSocket() {
		if (permissions != null
				&& (permissions.longValue() & SftpFileAttributes.S_IFSOCK) == SftpFileAttributes.S_IFSOCK) {
			return true;
		}
		return false;
	}
38698
private boolean checkPermissions(Activity activity) {
        String[] permissions = getRequiredAndroidPermissions();
        return handler.areAllPermissionsGranted(activity, permissions);
    }
252258
public static boolean isOnline(Context context) {
        int res = context.checkCallingOrSelfPermission(Manifest.permission.ACCESS_NETWORK_STATE);
        if (res == PackageManager.PERMISSION_GRANTED) {
            ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo netInfo = cm.getActiveNetworkInfo();
            if (netInfo != null && netInfo.isConnectedOrConnecting()) {
                return true;
            }
            return false;
        }

        return true;
    }
574671
public boolean isAnyPermissionPermanentlyDenied() {
    boolean hasPermanentlyDeniedAnyPermission = false;

    for (PermissionDeniedResponse deniedResponse : deniedPermissionResponses) {
      if (deniedResponse.isPermanentlyDenied()) {
        hasPermanentlyDeniedAnyPermission = true;
        break;
      }
    }

    return hasPermanentlyDeniedAnyPermission;
  }
368419
private boolean hasVibratePermission(Context context) {
        PackageManager pm = context.getPackageManager();
        int hasPerm = pm.checkPermission(android.Manifest.permission.VIBRATE, context.getPackageName());
        return hasPerm == PackageManager.PERMISSION_GRANTED;
    }
350492
protected boolean checkConnection()
    {
        super.checkConnection();
        try
        {
            if (_jarConnection!=_connection)
                newConnection();
        }
        catch(IOException e)
        {
            LogSupport.ignore(log,e);
            _jarConnection=null;
        }
        
        return _jarConnection!=null;
    }
904080
public boolean isProtected() {
        List<String> requiredRoles = null;
        return !webRequest.isUnprotectedURI() &&
               webRequest.getMatchResponse() != null &&
               (requiredRoles = webRequest.getRequiredRoles()) != null &&
               !requiredRoles.isEmpty();
    }
734475
public static boolean isWifiConnected(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
        return networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI;
    }
642681
public boolean isConnected() {
    if (socket != null && socket.isConnected() && !socket.isInputShutdown() && !socket.isOutputShutdown())
      return true;
    return false;
  }
519239
function(callback) {
      var online = true;

      // first, check if navigator.online is available
      if(typeof navigator.onLine !== "undefined"){
        online = navigator.onLine;
      }

      // second, check if Phonegap is available and has online info
      if(online){
        //use phonegap to determin if the network is available
        if(typeof navigator.network !== "undefined" && typeof navigator.network.connection !== "undefined"){
          var networkType = navigator.network.connection.type;
          if(networkType === "none" || networkType === null) {
            online = false;
          }
        }
      }

      return callback(online);
    }
106887
public boolean isConnected(String clusterName) {
        boolean isConnected = false;
        synchronized (connections) {
            if (connections.containsKey(clusterName)) {
                isConnected = connections.get(clusterName).isConnected();
            }
        }
        return isConnected;
    }
1002987
public static boolean isAvailable(Context context){
        FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
        if(fingerprintManager!=null){
            return (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints());
        }
        return false;
    }
1299633
public static boolean canTelnet(String ip, int port, int timeout) {
        Socket socket = null;
        try {
            socket = new Socket();
            socket.connect(new InetSocketAddress(ip, port), timeout);
            return socket.isConnected() && !socket.isClosed();
        } catch (Exception e) {
            return false;
        } finally {
            IOUtils.closeQuietly(socket);
        }
    }
657849
private void getNetworkInfo() {
		// Create a listener to check for new network connections (e.g. switching from mobile to Wifi, or losing internet connection)
		NetworkConnectionListener listener = new NetworkConnectionListener() {

			@Override
			public void networkChanged(NetworkConnectionType newConnection) {
				Log.i("BMSCore", "New network connection: " + newConnection.toString());
			}
		};

		// Initilize the network monitor with the application context and network change listener
		this.networkMonitor = new NetworkMonitor(getApplicationContext(), listener);

		// Start listening for network changes
		networkMonitor.startMonitoringNetworkChanges();

		// See if the device currently has internet access, and see what type of connection it is using
		Log.i("BMSCore", "Is connected to the internet: " + networkMonitor.isInternetAccessAvailable());
		Log.i("BMSCore", "Connection type: " + networkMonitor.getCurrentConnectionType().toString());

		// Check that the user has given permissions to read the phone's state.
		// If permission is granted, get the type of mobile data network being used.
		int networkPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);
		if (networkPermission == PackageManager.PERMISSION_GRANTED) {
			Log.i("BMSCore", "Mobile network type: " + networkMonitor.getMobileNetworkType());
		}
		else {
			Log.i("BMSCore", "Obtaining permission to read phone state");
			if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_PHONE_STATE)) {
				// Asynchronously explain to the user why you are attempting to request this permission.
				// Once this is done, try to request the permission again.
			}
			else {
				ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, MY_PERMISSIONS_READ_PHONE_STATE);
			}
		}
	}
1332194
public boolean isValidAddress(NetworkParameters network) {
      byte version = getVersion();
      if (getAllAddressBytes().length != 21) {
         return false;
      }
      return ((byte) (network.getStandardAddressHeader() & 0xFF)) == version
            || ((byte) (network.getMultisigAddressHeader() & 0xFF)) == version;
   }
469000
public boolean hasPermission(AccessControlList acl, String[] permission, Identity user)
   {

      String userId = user.getUserId();

      if (userId.equals(IdentityConstants.SYSTEM))
      {
         // SYSTEM has permission everywhere
         return true;
      }
      else if (userId.equals(acl.getOwner()))
      {
         // Current user is owner of node so has all privileges
         return true;
      }
      else if (userId.equals(IdentityConstants.ANONIM))
      {
         List<String> anyPermissions = acl.getPermissions(IdentityConstants.ANY);

         if (anyPermissions.size() < permission.length)
            return false;

         for (int i = 0; i < permission.length; i++)
         {
            if (!anyPermissions.contains(permission[i]))
               return false;
         }

         return true;
      }
      else
      {

         if (acl.getPermissionsSize() > 0 && permission.length > 0)
         {
            // check permission to perform all of the listed actions
            for (int i = 0; i < permission.length; i++)
            {
               // check specific actions
               if (!isPermissionMatch(acl.getPermissionsList(), permission[i], user))
                  return false;
            }
            return true;
         }
         return false;

      }
   }