From 6b593934d320c8293643cc8992b6012c31f29f95 Mon Sep 17 00:00:00 2001 From: Yuhao Zheng Date: Fri, 28 Feb 2014 17:22:45 -0800 Subject: [PATCH] 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 --- core/java/android/net/ProxyProperties.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java index 54fc01d736..50f45e8b5e 100644 --- a/core/java/android/net/ProxyProperties.java +++ b/core/java/android/net/ProxyProperties.java @@ -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() {