Merge "Connectivity: start PAC global proxy after reboot." am: 22fbf24ce4 am: 1f2605f517
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/431599 Change-Id: I5bb6267ca876df8aef0b2df630c058726b195352
This commit is contained in:
@@ -73,6 +73,8 @@ public class ProxyTracker {
|
|||||||
@GuardedBy("mProxyLock")
|
@GuardedBy("mProxyLock")
|
||||||
private boolean mDefaultProxyEnabled = true;
|
private boolean mDefaultProxyEnabled = true;
|
||||||
|
|
||||||
|
private final Handler mConnectivityServiceHandler;
|
||||||
|
|
||||||
// The object responsible for Proxy Auto Configuration (PAC).
|
// The object responsible for Proxy Auto Configuration (PAC).
|
||||||
@NonNull
|
@NonNull
|
||||||
private final PacManager mPacManager;
|
private final PacManager mPacManager;
|
||||||
@@ -80,6 +82,7 @@ public class ProxyTracker {
|
|||||||
public ProxyTracker(@NonNull final Context context,
|
public ProxyTracker(@NonNull final Context context,
|
||||||
@NonNull final Handler connectivityServiceInternalHandler, final int pacChangedEvent) {
|
@NonNull final Handler connectivityServiceInternalHandler, final int pacChangedEvent) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mConnectivityServiceHandler = connectivityServiceInternalHandler;
|
||||||
mPacManager = new PacManager(context, connectivityServiceInternalHandler, pacChangedEvent);
|
mPacManager = new PacManager(context, connectivityServiceInternalHandler, pacChangedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,6 +152,9 @@ public class ProxyTracker {
|
|||||||
* Read the global proxy settings and cache them in memory.
|
* Read the global proxy settings and cache them in memory.
|
||||||
*/
|
*/
|
||||||
public void loadGlobalProxy() {
|
public void loadGlobalProxy() {
|
||||||
|
if (loadDeprecatedGlobalHttpProxy()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ContentResolver res = mContext.getContentResolver();
|
ContentResolver res = mContext.getContentResolver();
|
||||||
String host = Settings.Global.getString(res, GLOBAL_HTTP_PROXY_HOST);
|
String host = Settings.Global.getString(res, GLOBAL_HTTP_PROXY_HOST);
|
||||||
int port = Settings.Global.getInt(res, GLOBAL_HTTP_PROXY_PORT, 0);
|
int port = Settings.Global.getInt(res, GLOBAL_HTTP_PROXY_PORT, 0);
|
||||||
@@ -169,20 +175,24 @@ public class ProxyTracker {
|
|||||||
synchronized (mProxyLock) {
|
synchronized (mProxyLock) {
|
||||||
mGlobalProxy = proxyProperties;
|
mGlobalProxy = proxyProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(pacFileUrl)) {
|
||||||
|
mConnectivityServiceHandler.post(
|
||||||
|
() -> mPacManager.setCurrentProxyScriptUrl(proxyProperties));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
loadDeprecatedGlobalHttpProxy();
|
|
||||||
// TODO : shouldn't this function call mPacManager.setCurrentProxyScriptUrl ?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the global proxy from the deprecated Settings.Global.HTTP_PROXY setting and apply it.
|
* Read the global proxy from the deprecated Settings.Global.HTTP_PROXY setting and apply it.
|
||||||
|
* Returns {@code true} when global proxy was set successfully from deprecated setting.
|
||||||
*/
|
*/
|
||||||
public void loadDeprecatedGlobalHttpProxy() {
|
public boolean loadDeprecatedGlobalHttpProxy() {
|
||||||
final String proxy = Settings.Global.getString(mContext.getContentResolver(), HTTP_PROXY);
|
final String proxy = Settings.Global.getString(mContext.getContentResolver(), HTTP_PROXY);
|
||||||
if (!TextUtils.isEmpty(proxy)) {
|
if (!TextUtils.isEmpty(proxy)) {
|
||||||
String data[] = proxy.split(":");
|
String data[] = proxy.split(":");
|
||||||
if (data.length == 0) {
|
if (data.length == 0) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String proxyHost = data[0];
|
final String proxyHost = data[0];
|
||||||
@@ -191,12 +201,14 @@ public class ProxyTracker {
|
|||||||
try {
|
try {
|
||||||
proxyPort = Integer.parseInt(data[1]);
|
proxyPort = Integer.parseInt(data[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ProxyInfo p = new ProxyInfo(proxyHost, proxyPort, "");
|
final ProxyInfo p = new ProxyInfo(proxyHost, proxyPort, "");
|
||||||
setGlobalProxy(p);
|
setGlobalProxy(p);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user