Esempio n. 1
0
	public static boolean isCWWAPConnect(Context context) {
		boolean result = false;
		ConnectivityManager connectivity = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = connectivity.getActiveNetworkInfo();
		if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE) {
			if ((Proxy.getDefaultHost() != null || Proxy.getHost(context) != null)
					&& (Proxy.getPort(context) != -1 || Proxy.getDefaultPort() != -1)) {
				result = true;
			}
		}
		return result;
	}
 /**
  * 检测wap状态 UrlConnection的代理
  *
  * @param context
  * @return @Title: checkUrlConnectionProxy
  */
 @SuppressWarnings("deprecation")
 public static java.net.Proxy checkUrlConnectionProxy(Context context) {
   if (isWap(context)) {
     String h = android.net.Proxy.getHost(context);
     int port = android.net.Proxy.getPort(context);
     if (h == null || TextUtils.isEmpty(h.trim())) {
       h = CheckRequestState.DEFAULT_PROXY_HOST;
     }
     if (port == -1) {
       port = 80;
     }
     return new Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress(h, port));
   }
   return null;
 }
 /**
  * 检测wap状态的httphost
  *
  * @param context
  * @return @Title: checkHttpHost
  */
 @SuppressWarnings("deprecation")
 public static HttpHost checkHttpHost(Context context) {
   if (isWap(context)) {
     String h = android.net.Proxy.getHost(context);
     int port = android.net.Proxy.getPort(context);
     if (h == null || TextUtils.isEmpty(h.trim())) {
       h = CheckRequestState.DEFAULT_PROXY_HOST;
     }
     if (port == -1) {
       port = 80;
     }
     return new HttpHost(h, port);
   }
   return null;
 }
  void populateFields(boolean useDefault) {
    String hostname = null;
    int port = -1;
    if (useDefault) {
      // Use the default proxy settings provided by the carrier
      hostname = Proxy.getDefaultHost();
      port = Proxy.getDefaultPort();
    } else {
      // Use the last setting given by the user
      hostname = Proxy.getHost(this);
      port = Proxy.getPort(this);
    }

    if (hostname == null) {
      hostname = "";
    }

    mHostnameField.setText(hostname);

    String portStr = port == -1 ? "" : Integer.toString(port);
    mPortField.setText(portStr);

    mProxyWifiOnly.setChecked(Proxy.isProxyForWifiOnly(this));

    Intent intent = getIntent();

    String buttonLabel = intent.getStringExtra("button-label");
    if (!TextUtils.isEmpty(buttonLabel)) {
      mOKButton.setText(buttonLabel);
    }

    String title = intent.getStringExtra("title");
    if (!TextUtils.isEmpty(title)) {
      setTitle(title);
    }
  }
Esempio n. 5
0
	public static String getProxyHost(Context context) {
		String res = Proxy.getHost(context);
		if (res == null)
			res = Proxy.getDefaultHost();
		return res;
	}