getProxy in ConnectivityService returns port w/PAC

Changes the PacManager to report message back to ConnectivityService
to send a broadcast once the download has completed.  This allows the
ConnectivityService to store the correct proxy info for getProxy().

This made the problem arise that ProxyProperties was not handling port
while it had PAC.  Added small fix for equals() and parcelization.

The combination of these fixes seems to resolve Bug: 11028616.

Bug: 11168706
Change-Id: I92d1343a8e804391ab77596b8167a2ef8d76b378
This commit is contained in:
Jason Monk
2013-10-10 14:02:51 -04:00
parent cabdbf9fec
commit a69f1b06de
2 changed files with 15 additions and 3 deletions

View File

@@ -178,7 +178,7 @@ public class ProxyProperties implements Parcelable {
// If PAC URL is present in either then they must be equal. // If PAC URL is present in either then they must be equal.
// Other parameters will only be for fall back. // Other parameters will only be for fall back.
if (!TextUtils.isEmpty(mPacFileUrl)) { if (!TextUtils.isEmpty(mPacFileUrl)) {
return mPacFileUrl.equals(p.getPacFileUrl()); return mPacFileUrl.equals(p.getPacFileUrl()) && mPort == p.mPort;
} }
if (!TextUtils.isEmpty(p.getPacFileUrl())) { if (!TextUtils.isEmpty(p.getPacFileUrl())) {
return false; return false;
@@ -219,6 +219,7 @@ public class ProxyProperties implements Parcelable {
if (mPacFileUrl != null) { if (mPacFileUrl != null) {
dest.writeByte((byte)1); dest.writeByte((byte)1);
dest.writeString(mPacFileUrl); dest.writeString(mPacFileUrl);
dest.writeInt(mPort);
return; return;
} else { } else {
dest.writeByte((byte)0); dest.writeByte((byte)0);
@@ -244,7 +245,9 @@ public class ProxyProperties implements Parcelable {
String host = null; String host = null;
int port = 0; int port = 0;
if (in.readByte() != 0) { if (in.readByte() != 0) {
return new ProxyProperties(in.readString()); String url = in.readString();
int localPort = in.readInt();
return new ProxyProperties(url, localPort);
} }
if (in.readByte() != 0) { if (in.readByte() != 0) {
host = in.readString(); host = in.readString();

View File

@@ -353,6 +353,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
*/ */
private static final int EVENT_SAMPLE_INTERVAL_ELAPSED = 15; private static final int EVENT_SAMPLE_INTERVAL_ELAPSED = 15;
/**
* PAC manager has received new port.
*/
private static final int EVENT_PROXY_HAS_CHANGED = 16;
/** Handler used for internal events. */ /** Handler used for internal events. */
private InternalHandler mHandler; private InternalHandler mHandler;
/** Handler used for incoming {@link NetworkStateTracker} events. */ /** Handler used for incoming {@link NetworkStateTracker} events. */
@@ -679,7 +684,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}, },
new IntentFilter(filter)); new IntentFilter(filter));
mPacManager = new PacManager(mContext); mPacManager = new PacManager(mContext, mHandler, EVENT_PROXY_HAS_CHANGED);
filter = new IntentFilter(); filter = new IntentFilter();
filter.addAction(CONNECTED_TO_PROVISIONING_NETWORK_ACTION); filter.addAction(CONNECTED_TO_PROVISIONING_NETWORK_ACTION);
@@ -3124,6 +3129,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
handleNetworkSamplingTimeout(); handleNetworkSamplingTimeout();
break; break;
} }
case EVENT_PROXY_HAS_CHANGED: {
handleApplyDefaultProxy((ProxyProperties)msg.obj);
break;
}
} }
} }
} }