Return detailed reason of invalid proxy settings

Make Proxy.validate() return valid/invalid int code, instead of throwing
exceptions. If invalid, detailed reason code is returned (currently for
Settings UI use).

bug: 13248097
Change-Id: Ic68d03f666f1cd63667afc311de7dc370d233901
This commit is contained in:
Yuhao Zheng
2014-02-28 17:22:45 -08:00
parent f7830a6b87
commit 6b593934d3

View File

@@ -140,13 +140,9 @@ public class ProxyProperties implements Parcelable {
public boolean isValid() {
if (!TextUtils.isEmpty(mPacFileUrl)) return true;
try {
Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort),
mExclusionList == null ? "" : mExclusionList);
} catch (IllegalArgumentException e) {
return false;
}
return true;
return Proxy.PROXY_VALID == Proxy.validate(mHost == null ? "" : mHost,
mPort == 0 ? "" : Integer.toString(mPort),
mExclusionList == null ? "" : mExclusionList);
}
public java.net.Proxy makeProxy() {