summaryrefslogtreecommitdiffstats
path: root/core/java/android/net
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2015-04-22 11:52:48 +0900
committerLorenzo Colitti <lorenzo@google.com>2015-04-22 12:27:33 +0900
commitec4c555571c3b1cb2c5d39406b99ac40a2b9d7e6 (patch)
tree034b0cc740a228303c408e719f5118932fdf45a0 /core/java/android/net
parentfa57c489f621cd10add639cf7df59f630a7f41a4 (diff)
downloadframeworks_base-ec4c555571c3b1cb2c5d39406b99ac40a2b9d7e6.zip
frameworks_base-ec4c555571c3b1cb2c5d39406b99ac40a2b9d7e6.tar.gz
frameworks_base-ec4c555571c3b1cb2c5d39406b99ac40a2b9d7e6.tar.bz2
Don't require ACCESS_NETWORK_STATE in setProcessDefaultNetwork
The documentation for setProcessDefaultNetwork does not mention that it requires ACCESS_NETWORK_STATE, but a process without ACCESS_NETWORK_STATE that calls it will crash because we can't fetch the proxy properties. Because ACCESS_NETWORK_STATE is not required to obtain a Network object (Network objects can come from broadcasts too), it may not be reasonable to require the permission. We did not do so in L. For now, ignore the failure and don't crash the app. I've filed http://b/20470604 to track a longer term fix. Bug: 20081183 Bug: 20423580 Bug: 20470604 Change-Id: I158016130b4afb1d300357fe703804d2e7bc609b
Diffstat (limited to 'core/java/android/net')
-rw-r--r--core/java/android/net/ConnectivityManager.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index b80d91f..a48b324 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -2567,7 +2567,12 @@ public class ConnectivityManager {
if (NetworkUtils.bindProcessToNetwork(netId)) {
// Set HTTP proxy system properties to match network.
// TODO: Deprecate this static method and replace it with a non-static version.
- Proxy.setHttpProxySystemProperty(getInstance().getDefaultProxy());
+ try {
+ Proxy.setHttpProxySystemProperty(getInstance().getDefaultProxy());
+ } catch (SecurityException e) {
+ // The process doesn't have ACCESS_NETWORK_STATE, so we can't fetch the proxy.
+ Log.e(TAG, "Can't set proxy properties", e);
+ }
// Must flush DNS cache as new network may have different DNS resolutions.
InetAddress.clearDnsCache();
// Must flush socket pool as idle sockets will be bound to previous network and may