Fix: ConnectivityManager is initialized with a wrong context
ActivityThread#setHttpProxy uses a system context to get a ConnectivityManager instance. If it's not already cached, the system service registry will cache this instance initialized with the system context, and subsequent calls to get this service will return the bad instance. This patch uses the application context instead, unless it's not available for some unlikely reason. A possible symptom of this issue is to have Bluetooth tethering failing with a security exception, because it's requested by the "android" package without system uid. Merged-In: Ib8815f010883cdb94fcad2cdfb237de39327b20a Bug: 73572062 Change-Id: Id652c1625194dc73dcbf8dfcad4b4e2e6fbebf4e
This commit is contained in:
committed by
Chalard Jean
parent
2aed62d664
commit
f9f15fce9d
@ -963,7 +963,8 @@ public final class ActivityThread {
|
||||
}
|
||||
|
||||
public void setHttpProxy(String host, String port, String exclList, Uri pacFileUrl) {
|
||||
final ConnectivityManager cm = ConnectivityManager.from(getSystemContext());
|
||||
final ConnectivityManager cm = ConnectivityManager.from(
|
||||
getApplication() != null ? getApplication() : getSystemContext());
|
||||
final Network network = cm.getBoundNetworkForProcess();
|
||||
if (network != null) {
|
||||
Proxy.setHttpProxySystemProperty(cm.getDefaultProxy());
|
||||
|
Reference in New Issue
Block a user