Example #1
0
  public static ProxyStatusItem isProxyValidExclusionList(String[] proxyExclusionList) {
    try {
      for (int i = 0; i < proxyExclusionList.length; i++) {
        String s = proxyExclusionList[i].trim();
        ProxyStatusItem status = isProxyValidExclusionAddress(s);

        if (!status.result) {
          return new ProxyStatusItem(
              ProxyStatusProperties.PROXY_VALID_EXCLUSION_LIST,
              CheckStatusValues.CHECKED,
              true,
              APL.getContext().getString(R.string.status_exclusion_list_notvalid));
        }
      }

      String msg =
          String.format(
              "%s %s",
              APL.getContext().getString(R.string.status_exclusion_item_valid),
              TextUtils.join(",", proxyExclusionList));
      return new ProxyStatusItem(
          ProxyStatusProperties.PROXY_VALID_EXCLUSION_ITEM, CheckStatusValues.CHECKED, true, msg);
    } catch (Exception e) {
      APL.getEventReport().send(e);
    }

    return new ProxyStatusItem(
        ProxyStatusProperties.PROXY_VALID_EXCLUSION_ITEM,
        CheckStatusValues.CHECKED,
        false,
        APL.getContext().getString(R.string.status_exclusion_item_notvalid));
  }
Example #2
0
  public static ProxyStatusItem isProxyValidExclusionAddress(String proxyExclusionAddress) {
    try {
      //            if (TextUtils.isEmpty(proxyExclusionAddress))
      //            {
      //                return new ProxyStatusItem(ProxyStatusProperties.PROXY_VALID_EXCLUSION_ITEM,
      // CheckStatusValues.CHECKED, false,
      // APL.getContext().getString(R.string.status_exclusion_item_empty));
      //            }
      //            else
      //            {
      Matcher match = APLConstants.EXCLUSION_PATTERN.matcher(proxyExclusionAddress);
      if (match.matches()) {
        String msg =
            String.format(
                "%s %s",
                APL.getContext().getString(R.string.status_exclusion_item_valid),
                proxyExclusionAddress);
        return new ProxyStatusItem(
            ProxyStatusProperties.PROXY_VALID_EXCLUSION_ITEM, CheckStatusValues.CHECKED, true, msg);
      }
      //            }
    } catch (Exception e) {
      APL.getEventReport().send(e);
    }

    return new ProxyStatusItem(
        ProxyStatusProperties.PROXY_VALID_EXCLUSION_ITEM,
        CheckStatusValues.CHECKED,
        false,
        APL.getContext().getString(R.string.status_exclusion_item_notvalid));
  }
Example #3
0
  public static ProxyStatusItem isProxyValidHostname(String proxyHost) {
    try {
      if (TextUtils.isEmpty(proxyHost)) {
        return new ProxyStatusItem(
            ProxyStatusProperties.PROXY_VALID_HOSTNAME,
            CheckStatusValues.CHECKED,
            false,
            APL.getContext().getString(R.string.status_hostname_empty));
      } else {
        Matcher match = APLConstants.HOSTNAME_PATTERN.matcher(proxyHost);
        if (match.matches()) {
          String hostnameValidMsg = APL.getContext().getString(R.string.status_hostname_valid);
          String msg = String.format("%s %s", hostnameValidMsg, proxyHost);
          return new ProxyStatusItem(
              ProxyStatusProperties.PROXY_VALID_HOSTNAME, CheckStatusValues.CHECKED, true, msg);
        }
      }
    } catch (Exception e) {
      APL.getEventReport().send(e);
    }

    return new ProxyStatusItem(
        ProxyStatusProperties.PROXY_VALID_HOSTNAME,
        CheckStatusValues.CHECKED,
        false,
        APL.getContext().getString(R.string.status_hostname_notvalid));
  }
Example #4
0
  protected static ProxyStatusItem isWifiEnabled(ProxyConfiguration conf) {
    ProxyStatusItem result = null;

    if (APL.getWifiManager().isWifiEnabled()) {
      NetworkInfo ni = APL.getConnectivityManager().getActiveNetworkInfo();
      if (ni != null && ni.isConnected() && ni.getType() == ConnectivityManager.TYPE_WIFI) {
        String status = APL.getContext().getString(R.string.status_wifi_enabled);
        result =
            new ProxyStatusItem(
                ProxyStatusProperties.WIFI_ENABLED, CheckStatusValues.CHECKED, true, true, status);
      } else {
        result =
            new ProxyStatusItem(
                ProxyStatusProperties.WIFI_ENABLED,
                CheckStatusValues.CHECKED,
                false,
                true,
                APL.getContext().getString(R.string.status_wifi_enabled_disconnected));
      }
    } else {
      result =
          new ProxyStatusItem(
              ProxyStatusProperties.WIFI_ENABLED,
              CheckStatusValues.CHECKED,
              false,
              true,
              APL.getContext().getString(R.string.status_wifi_not_enabled));
    }

    return result;
  }
Example #5
0
  protected static ProxyStatusItem isProxyEnabled(ProxyConfiguration conf) {
    ProxyStatusItem result;

    if (Build.VERSION.SDK_INT >= 12) {
      // On API version > Honeycomb 3.1 (HONEYCOMB_MR1)
      // Proxy is disabled by default on Mobile connection
      ConnectivityManager cm = APL.getConnectivityManager();
      if (cm != null) {
        NetworkInfo ni = cm.getActiveNetworkInfo();
        if (ni != null && ni.getType() == ConnectivityManager.TYPE_MOBILE) {
          result =
              new ProxyStatusItem(
                  ProxyStatusProperties.PROXY_ENABLED,
                  CheckStatusValues.CHECKED,
                  false,
                  APL.getContext().getString(R.string.status_proxy_mobile_disabled));
          return result;
        }
      }
    }

    if (conf.getProxySettings() == ProxySetting.UNASSIGNED
        || conf.getProxySettings() == ProxySetting.NONE) {
      result =
          new ProxyStatusItem(
              ProxyStatusProperties.PROXY_ENABLED,
              CheckStatusValues.CHECKED,
              false,
              APL.getContext().getString(R.string.status_proxy_disabled));
    } else {
      // if (proxyHost != null && proxyPort != null)
      // {
      // HTTP or SOCKS proxy
      result =
          new ProxyStatusItem(
              ProxyStatusProperties.PROXY_ENABLED,
              CheckStatusValues.CHECKED,
              true,
              APL.getContext().getString(R.string.status_proxy_enabled));
      // }
      // else
      // {
      // result = new ProxyStatusItem(ProxyStatusProperties.PROXY_ENABLED,
      // CheckStatusValues.CHECKED, false);
      // }
    }

    return result;
  }
Example #6
0
 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));
   }
 }
Example #7
0
 private static void broadCastUpdatedStatus() {
   //        LogWrapper.d(TAG, "Sending broadcast intent: " +
   // APLConstants.APL_UPDATED_PROXY_STATUS_CHECK);
   Intent intent = new Intent(APLIntents.APL_UPDATED_PROXY_STATUS_CHECK);
   // intent.putExtra(APLConstants.ProxyStatus, status);
   APL.getContext().sendBroadcast(intent);
 }
Example #8
0
  public static ProxyStatusItem isProxyValidPort(Integer proxyPort) {
    if ((proxyPort == null)) {
      return new ProxyStatusItem(
          ProxyStatusProperties.PROXY_VALID_PORT,
          CheckStatusValues.CHECKED,
          false,
          APL.getContext().getString(R.string.status_port_empty));
    }

    if ((proxyPort < 1) || (proxyPort > 65535)) {
      return new ProxyStatusItem(
          ProxyStatusProperties.PROXY_VALID_PORT,
          CheckStatusValues.CHECKED,
          false,
          APL.getContext().getString(R.string.status_port_notvalid));
    }

    String msg =
        String.format("%s %d", APL.getContext().getString(R.string.status_port_valid), proxyPort);
    return new ProxyStatusItem(
        ProxyStatusProperties.PROXY_VALID_PORT, CheckStatusValues.CHECKED, true, msg);
  }
Example #9
0
  protected static ProxyStatusItem isWifiSelected(ProxyConfiguration conf) {
    ProxyStatusItem result = null;

    if (conf.isCurrentNetwork()) {
      result =
          new ProxyStatusItem(
              ProxyStatusProperties.WIFI_SELECTED,
              CheckStatusValues.CHECKED,
              true,
              true,
              APL.getContext().getString(R.string.status_wifi_selected, conf.ap.ssid));
    } else {
      result =
          new ProxyStatusItem(
              ProxyStatusProperties.WIFI_SELECTED,
              CheckStatusValues.CHECKED,
              false,
              true,
              APL.getContext().getString(R.string.status_wifi_not_selected));
    }

    return result;
  }
Example #10
0
 /** 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));
   }
 }