summaryrefslogtreecommitdiffstats
path: root/packages/services
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2013-08-21 15:57:30 -0400
committerJason Monk <jmonk@google.com>2013-08-22 16:33:26 -0400
commitda205a749fadb3a87357d9bd607f094c7717764a (patch)
tree659b1785d4fb97c342b72cd54f1a602107c56b2a /packages/services
parent6b223c6a5be788ca28d5d911ab10650be673684b (diff)
downloadframeworks_base-da205a749fadb3a87357d9bd607f094c7717764a.zip
frameworks_base-da205a749fadb3a87357d9bd607f094c7717764a.tar.gz
frameworks_base-da205a749fadb3a87357d9bd607f094c7717764a.tar.bz2
System binds PAC Local Proxy instead of self start
The PAC Local Proxy priviously caught proxy broadcasts and started itself when needed. Now it is bound by the system the same way the pac processing service is started. Bug: 10425091 Change-Id: I746daa21645a11aa18ef464f00c8cb5536d8c86f
Diffstat (limited to 'packages/services')
-rw-r--r--packages/services/Proxy/AndroidManifest.xml7
-rw-r--r--packages/services/Proxy/src/com/android/proxyhandler/ProxyServer.java24
-rw-r--r--packages/services/Proxy/src/com/android/proxyhandler/ProxyService.java47
-rw-r--r--packages/services/Proxy/src/com/android/proxyhandler/ProxyServiceReceiver.java29
4 files changed, 33 insertions, 74 deletions
diff --git a/packages/services/Proxy/AndroidManifest.xml b/packages/services/Proxy/AndroidManifest.xml
index 09b8327..bbcd6b9 100644
--- a/packages/services/Proxy/AndroidManifest.xml
+++ b/packages/services/Proxy/AndroidManifest.xml
@@ -13,12 +13,5 @@
android:exported="true">
</service>
- <receiver android:name=".ProxyServiceReceiver">
-
- <intent-filter>
- <action android:name="android.intent.action.PROXY_CHANGE" />
- </intent-filter>
- </receiver>
-
</application>
</manifest>
diff --git a/packages/services/Proxy/src/com/android/proxyhandler/ProxyServer.java b/packages/services/Proxy/src/com/android/proxyhandler/ProxyServer.java
index 5d8689e..77f3c8c 100644
--- a/packages/services/Proxy/src/com/android/proxyhandler/ProxyServer.java
+++ b/packages/services/Proxy/src/com/android/proxyhandler/ProxyServer.java
@@ -1,7 +1,20 @@
-
+/**
+ * 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 com.android.proxyhandler;
-import android.net.ProxyProperties;
import android.util.Log;
import com.google.android.collect.Lists;
@@ -36,7 +49,6 @@ public class ProxyServer extends Thread {
public boolean mIsRunning = false;
private ServerSocket serverSocket;
- private ProxyProperties mProxy;
private class ProxyConnection implements Runnable {
private Socket connection;
@@ -48,8 +60,6 @@ public class ProxyServer extends Thread {
@Override
public void run() {
try {
- android.net.Proxy.setHttpProxySystemProperty(mProxy);
-
String requestLine = getLine(connection.getInputStream());
if (requestLine == null) {
connection.close();
@@ -212,8 +222,4 @@ public class ProxyServer extends Thread {
}
}
}
-
- public void setProxy(ProxyProperties proxy) {
- mProxy = proxy;
- }
}
diff --git a/packages/services/Proxy/src/com/android/proxyhandler/ProxyService.java b/packages/services/Proxy/src/com/android/proxyhandler/ProxyService.java
index 18ed645..cef3659 100644
--- a/packages/services/Proxy/src/com/android/proxyhandler/ProxyService.java
+++ b/packages/services/Proxy/src/com/android/proxyhandler/ProxyService.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 com.android.proxyhandler;
import android.app.Service;
@@ -18,43 +33,17 @@ public class ProxyService extends Service {
/** Keep these values up-to-date with PacManager.java */
public static final String KEY_PROXY = "keyProxy";
public static final String HOST = "localhost";
+ // STOPSHIP This being a static port means it can be hijacked by other apps.
public static final int PORT = 8182;
public static final String EXCL_LIST = "";
@Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- if (intent != null) {
- if (handleCommand(intent)) {
- return START_REDELIVER_INTENT;
- }
- }
- return START_NOT_STICKY;
- }
-
- private boolean handleCommand(Intent intent) {
- Bundle bundle = intent.getExtras();
- ProxyProperties proxy = null;
- if ((bundle != null) && bundle.containsKey(Proxy.EXTRA_PROXY_INFO)) {
- proxy = bundle.getParcelable(Proxy.EXTRA_PROXY_INFO);
- if ((proxy != null) && !TextUtils.isEmpty(proxy.getPacFileUrl())) {
- startProxy(proxy);
- return true;
- } else {
- stopSelf();
- }
- } else {
- stopSelf();
- }
- return false;
- }
-
-
- private void startProxy(ProxyProperties proxy) {
+ public void onCreate() {
+ super.onCreate();
if (server == null) {
server = new ProxyServer();
server.startServer();
}
- server.setProxy(proxy);
}
@Override
diff --git a/packages/services/Proxy/src/com/android/proxyhandler/ProxyServiceReceiver.java b/packages/services/Proxy/src/com/android/proxyhandler/ProxyServiceReceiver.java
deleted file mode 100644
index 4638def..0000000
--- a/packages/services/Proxy/src/com/android/proxyhandler/ProxyServiceReceiver.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.android.proxyhandler;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Proxy;
-import android.net.ProxyProperties;
-import android.os.Bundle;
-import android.text.TextUtils;
-
-public class ProxyServiceReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- Intent service = new Intent(context, ProxyService.class);
- Bundle bundle = intent.getExtras();
- ProxyProperties proxy = null;
- if (bundle != null) {
- proxy = bundle.getParcelable(Proxy.EXTRA_PROXY_INFO);
- service.putExtra(Proxy.EXTRA_PROXY_INFO, proxy);
- }
- if ((proxy != null) && (!TextUtils.isEmpty(proxy.getPacFileUrl()))) {
- context.startService(service);
- } else {
- context.stopService(service);
- }
- }
-
-}