summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2013-09-23 13:32:39 -0400
committerJohn Huang <jsh@google.com>2013-09-26 23:06:32 +0000
commitd443479a45279f8f52daf4034698f2ab3c3e62f1 (patch)
tree263b04586d652f54c9f96753f86bcc7ff6550f14 /services
parentf95c9aa7e1229963a4cb92eed46eafc205b03cb3 (diff)
downloadframeworks_base-d443479a45279f8f52daf4034698f2ab3c3e62f1.zip
frameworks_base-d443479a45279f8f52daf4034698f2ab3c3e62f1.tar.gz
frameworks_base-d443479a45279f8f52daf4034698f2ab3c3e62f1.tar.bz2
Fix Sending PAC Broadcast before downloaded
The PacManager now waits until the local proxy is bound and the PAC file is downloaded before sending out the proxy broadcast. Bug: 10895515 Change-Id: Iaa7fc0989b52453aeeb720b44df0fca0fcb959ca
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/connectivity/PacManager.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/services/java/com/android/server/connectivity/PacManager.java b/services/java/com/android/server/connectivity/PacManager.java
index 53e1dc2..1cb2fe3 100644
--- a/services/java/com/android/server/connectivity/PacManager.java
+++ b/services/java/com/android/server/connectivity/PacManager.java
@@ -86,6 +86,9 @@ public class PacManager {
private int mCurrentDelay;
private int mLastPort;
+ private boolean mHasSentBroadcast;
+ private boolean mHasDownloaded;
+
/**
* Used for locking when setting mProxyService and all references to mPacUrl or mCurrentPac.
*/
@@ -110,6 +113,8 @@ public class PacManager {
setCurrentProxyScript(file);
}
}
+ mHasDownloaded = true;
+ sendProxyIfNeeded();
longSchedule();
} else {
reschedule();
@@ -155,6 +160,8 @@ public class PacManager {
mPacUrl = proxy.getPacFileUrl();
}
mCurrentDelay = DELAY_1;
+ mHasSentBroadcast = false;
+ mHasDownloaded = false;
getAlarmManager().cancel(mPacRefreshIntent);
bind();
return true;
@@ -311,10 +318,14 @@ public class PacManager {
callbackService.getProxyPort(new IProxyPortListener.Stub() {
@Override
public void setProxyPort(int port) throws RemoteException {
+ if (mLastPort != -1) {
+ // Always need to send if port changed
+ mHasSentBroadcast = false;
+ }
mLastPort = port;
if (port != -1) {
Log.d(TAG, "Local proxy is bound on " + port);
- sendPacBroadcast(new ProxyProperties(mPacUrl, port));
+ sendProxyIfNeeded();
} else {
Log.e(TAG, "Received invalid port from Local Proxy,"
+ " PAC will not be operational");
@@ -341,6 +352,7 @@ public class PacManager {
mProxyConnection = null;
}
mProxyService = null;
+ mLastPort = -1;
}
private void sendPacBroadcast(ProxyProperties proxy) {
@@ -355,4 +367,14 @@ public class PacManager {
Binder.restoreCallingIdentity(ident);
}
}
+
+ private synchronized void sendProxyIfNeeded() {
+ if (!mHasDownloaded || (mLastPort == -1)) {
+ return;
+ }
+ if (!mHasSentBroadcast) {
+ sendPacBroadcast(new ProxyProperties(mPacUrl, mLastPort));
+ mHasSentBroadcast = true;
+ }
+ }
}