Esempio n. 1
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);
    }
  }