public static Boolean isConnected() { NetworkInfo ni = ProxyUtils.getCurrentNetworkInfo(); if (ni != null && ni.isAvailable() && ni.isConnected()) { return true; } else { return false; } }
private boolean validateBypass() { String value = proxyBypass.getExclusionString(); App.getLogger().d(TAG, "Exclusion list updated: " + value); ProxyStatusItem item = ProxyUtils.isProxyValidExclusionList(value); validationErrors.remove(item.statusCode); if (!item.result) { validationErrors.put(item.statusCode, item.message); return false; } else { selectedProxy.exclusion = value; return true; } }
protected static ProxyStatusItem isWebReachable(ProxyConfiguration conf, int timeout) { Boolean result = ProxyUtils.canGetWebResources(conf, timeout); if (result) { return new ProxyStatusItem( ProxyStatusProperties.WEB_REACHABLE, CheckStatusValues.CHECKED, true, APL.getContext().getString(R.string.status_web_reachable)); } else { return new ProxyStatusItem( ProxyStatusProperties.WEB_REACHABLE, CheckStatusValues.CHECKED, false, APL.getContext().getString(R.string.status_web_not_reachable)); } }
private boolean validateHost() { String value = proxyHost.getValue(); proxyHost.setError(null); ProxyStatusItem item = ProxyUtils.isProxyValidHostname(value); validationErrors.remove(item.statusCode); if (!item.result) { proxyHost.setError(item.message); validationErrors.put(item.statusCode, item.message); return false; } else { selectedProxy.host = value; return true; } }
private boolean validatePort() { Integer value = null; try { value = Integer.parseInt(proxyPort.getValue()); } catch (NumberFormatException e) { value = Integer.MAX_VALUE; } ProxyStatusItem item = ProxyUtils.isProxyValidPort(value); validationErrors.remove(item.statusCode); proxyPort.setError(null); if (!item.result) { proxyPort.setError(item.message); validationErrors.put(item.statusCode, item.message); return false; } else { selectedProxy.port = value; return true; } }
/** Try to PING the HOST specified in the current proxy configuration */ protected static ProxyStatusItem isProxyReachable(ProxyConfiguration conf) { if (conf.getProxy() != null && conf.getProxyType() != Proxy.Type.DIRECT) { Boolean result = ProxyUtils.isHostReachable(conf.getProxy()); if (result) { return new ProxyStatusItem( ProxyStatusProperties.PROXY_REACHABLE, CheckStatusValues.CHECKED, true, APL.getContext().getString(R.string.status_proxy_reachable)); } else { return new ProxyStatusItem( ProxyStatusProperties.PROXY_REACHABLE, CheckStatusValues.CHECKED, false, APL.getContext().getString(R.string.status_proxy_not_reachable)); } } else { return new ProxyStatusItem( ProxyStatusProperties.PROXY_REACHABLE, CheckStatusValues.CHECKED, false, APL.getContext().getString(R.string.status_proxy_not_valid_informations)); } }