Example #1
0
 private static void wifiNotEnabled_DisableChecking(ProxyStatus status) {
   status.set(ProxyStatusProperties.PROXY_ENABLED, CheckStatusValues.NOT_CHECKED, false, false);
   status.set(
       ProxyStatusProperties.PROXY_VALID_HOSTNAME, CheckStatusValues.NOT_CHECKED, false, false);
   status.set(ProxyStatusProperties.PROXY_VALID_PORT, CheckStatusValues.NOT_CHECKED, false, false);
   status.set(ProxyStatusProperties.PROXY_REACHABLE, CheckStatusValues.NOT_CHECKED, false, false);
 }
Example #2
0
  private static void acquireProxyStatusSDK1_11(
      ProxyConfiguration conf, ProxyStatus status, EnumSet<ProxyCheckOptions> checkOptions) {
    // API version <= 11 (Older devices)
    status.set(ProxyStatusProperties.WIFI_ENABLED, CheckStatusValues.NOT_CHECKED, false, false);
    status.set(ProxyStatusProperties.WIFI_SELECTED, CheckStatusValues.NOT_CHECKED, false, false);

    LogWrapper.d(TAG, "Checking if proxy is enabled ...");
    status.set(isProxyEnabled(conf));
    broadCastUpdatedStatus();

    if (status.getProperty(ProxyStatusProperties.PROXY_ENABLED).result) {
      LogWrapper.d(TAG, "Checking if proxy is valid hostname ...");
      status.set(isProxyValidHostname(conf));
      broadCastUpdatedStatus();

      LogWrapper.d(TAG, "Checking if proxy is valid port ...");
      status.set(isProxyValidPort(conf));
      broadCastUpdatedStatus();

      if (checkOptions.contains(ProxyCheckOptions.ONLINE_CHECK)
          && status.getProperty(ProxyStatusProperties.PROXY_VALID_HOSTNAME).result
          && status.getProperty(ProxyStatusProperties.PROXY_VALID_PORT).result) {
        LogWrapper.d(TAG, "Checking if proxy is reachable ...");
        status.set(isProxyReachable(conf));
        broadCastUpdatedStatus();
      } else {
        status.set(
            ProxyStatusProperties.PROXY_REACHABLE, CheckStatusValues.NOT_CHECKED, false, false);
      }
    } else {
      wifiNotEnabled_DisableChecking(status);
    }
  }
Example #3
0
  /**
   * Can take a long time to execute this task. - Check if the proxy is enabled - Check if the proxy
   * address is valid - Check if the proxy is reachable (using a PING) - Check if is possible to
   * retrieve an URI resource using the proxy
   */
  public static void acquireProxyStatus(
      ProxyConfiguration conf,
      ProxyStatus status,
      EnumSet<ProxyCheckOptions> checkOptions,
      int timeout) {
    status.clear();
    status.startchecking();
    broadCastUpdatedStatus();

    if (Build.VERSION.SDK_INT >= 12) {
      acquireProxyStatusSDK12(conf, status, checkOptions);
    } else {
      acquireProxyStatusSDK1_11(conf, status, checkOptions);
    }

    if (checkOptions.contains(ProxyCheckOptions.ONLINE_CHECK)) {
      // Always check if WEB is reachable
      LogWrapper.d(TAG, "Checking if web is reachable ...");
      status.set(isWebReachable(conf, timeout));
      broadCastUpdatedStatus();
    } else {
      status.set(ProxyStatusProperties.WEB_REACHABLE, CheckStatusValues.NOT_CHECKED, false, false);
    }
  }