summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2013-08-12 16:42:38 -0400
committerJason Monk <jmonk@google.com>2013-08-20 17:36:39 -0400
commit9ced3cd9d6ea414523051ec872fffc68f5fdbf08 (patch)
tree22d49c8bde1a17da9c9ff1588a3af3e176d0173a /core/java/android
parent58514937628dfcf3b2949e4cbc45d5526ecb8019 (diff)
Change PacProcessor to Android Service
This switches the PacProcessor over to an Android Service. The service is bound and unbound by the PacManager, which also adds it to the ServiceManager, allowing for Context-Free access by the PacProxySelector in all DVMs. bug:10182711 Change-Id: Id1ff7660be56e8976cdcccd76e041feb47a17a61
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/net/PacProxySelector.java26
-rw-r--r--core/java/android/net/Proxy.java8
2 files changed, 27 insertions, 7 deletions
diff --git a/core/java/android/net/PacProxySelector.java b/core/java/android/net/PacProxySelector.java
index d3ce2e509e14..b674324197ed 100644
--- a/core/java/android/net/PacProxySelector.java
+++ b/core/java/android/net/PacProxySelector.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package android.net;
@@ -25,19 +40,25 @@ public class PacProxySelector extends ProxySelector {
private static final String TAG = "PacProxySelector";
public static final String PROXY_SERVICE = "com.android.net.IProxyService";
private IProxyService mProxyService;
+ private final List<Proxy> mDefaultList;
public PacProxySelector() {
mProxyService = IProxyService.Stub.asInterface(
ServiceManager.getService(PROXY_SERVICE));
if (mProxyService == null) {
// Added because of b10267814 where mako is restarting.
- Log.e(TAG, "PackManager: no proxy service");
+ Log.e(TAG, "PacManager: no proxy service");
}
+ mDefaultList = Lists.newArrayList(java.net.Proxy.NO_PROXY);
}
@Override
public List<Proxy> select(URI uri) {
if (mProxyService == null) {
+ mProxyService = IProxyService.Stub.asInterface(
+ ServiceManager.getService(PROXY_SERVICE));
+ }
+ if (mProxyService == null) {
Log.e(TAG, "select: no proxy service return NO_PROXY");
return Lists.newArrayList(java.net.Proxy.NO_PROXY);
}
@@ -53,6 +74,9 @@ public class PacProxySelector extends ProxySelector {
} catch (RemoteException e) {
e.printStackTrace();
}
+ if (response == null) {
+ return mDefaultList;
+ }
return parseResponse(response);
}
diff --git a/core/java/android/net/Proxy.java b/core/java/android/net/Proxy.java
index 5b38f5793a74..c3e14381f3af 100644
--- a/core/java/android/net/Proxy.java
+++ b/core/java/android/net/Proxy.java
@@ -48,7 +48,6 @@ public final class Proxy {
private static final String TAG = "Proxy";
private static final ProxySelector sDefaultProxySelector;
- private static PacProxySelector sPacProxySelector;
/**
* Used to notify an app that's caching the default connection proxy
@@ -352,11 +351,8 @@ public final class Proxy {
System.clearProperty("http.nonProxyHosts");
System.clearProperty("https.nonProxyHosts");
}
- if ((pacFileUrl != null) && !TextUtils.isEmpty(pacFileUrl)) {
- if (sPacProxySelector == null) {
- sPacProxySelector = new PacProxySelector();
- }
- ProxySelector.setDefault(sPacProxySelector);
+ if (!TextUtils.isEmpty(pacFileUrl)) {
+ ProxySelector.setDefault(new PacProxySelector());
} else {
ProxySelector.setDefault(sDefaultProxySelector);
}