diff options
Diffstat (limited to 'services/java/com/android/server/ConnectivityService.java')
-rw-r--r-- | services/java/com/android/server/ConnectivityService.java | 94 |
1 files changed, 50 insertions, 44 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 9e06db8..01625dd 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -321,12 +321,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { // track the current default http proxy - tell the world if we get a new one (real change) private ProxyProperties mDefaultProxy = null; - private Object mDefaultProxyLock = new Object(); + private Object mProxyLock = new Object(); private boolean mDefaultProxyDisabled = false; // track the global proxy. private ProxyProperties mGlobalProxy = null; - private final Object mGlobalProxyLock = new Object(); private SettingsObserver mSettingsObserver; @@ -1471,8 +1470,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { loge("Error modifying route - no interface name"); return false; } - - if (r.isHostRoute() == false) { + if (r.hasGateway()) { RouteInfo bestRoute = RouteInfo.selectBestRoute(lp.getAllRoutes(), r.getGateway()); if (bestRoute != null) { if (bestRoute.getGateway().equals(r.getGateway())) { @@ -2348,28 +2346,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - for (RouteInfo r : routeDiff.added) { - if (isLinkDefault || ! r.isDefaultRoute()) { - addRoute(newLp, r, TO_DEFAULT_TABLE); - } else { - // add to a secondary route table - addRoute(newLp, r, TO_SECONDARY_TABLE); - - // many radios add a default route even when we don't want one. - // remove the default route unless somebody else has asked for it - String ifaceName = newLp.getInterfaceName(); - if (TextUtils.isEmpty(ifaceName) == false && mAddedRoutes.contains(r) == false) { - if (VDBG) log("Removing " + r + " for interface " + ifaceName); - try { - mNetd.removeRoute(ifaceName, r); - } catch (Exception e) { - // never crash - catch them all - if (DBG) loge("Exception trying to remove a route: " + e); - } - } - } - } - if (!isLinkDefault) { // handle DNS routes if (routesChanged) { @@ -2394,6 +2370,29 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } + + for (RouteInfo r : routeDiff.added) { + if (isLinkDefault || ! r.isDefaultRoute()) { + addRoute(newLp, r, TO_DEFAULT_TABLE); + } else { + // add to a secondary route table + addRoute(newLp, r, TO_SECONDARY_TABLE); + + // many radios add a default route even when we don't want one. + // remove the default route unless somebody else has asked for it + String ifaceName = newLp.getInterfaceName(); + if (TextUtils.isEmpty(ifaceName) == false && mAddedRoutes.contains(r) == false) { + if (VDBG) log("Removing " + r + " for interface " + ifaceName); + try { + mNetd.removeRoute(ifaceName, r); + } catch (Exception e) { + // never crash - catch them all + if (DBG) loge("Exception trying to remove a route: " + e); + } + } + } + } + return routesChanged; } @@ -3039,14 +3038,15 @@ public class ConnectivityService extends IConnectivityManager.Stub { // so this API change wouldn't have a benifit. It also breaks the passing // of proxy info to all the JVMs. // enforceAccessPermission(); - synchronized (mDefaultProxyLock) { - return mDefaultProxyDisabled ? null : mDefaultProxy; + synchronized (mProxyLock) { + if (mGlobalProxy != null) return mGlobalProxy; + return (mDefaultProxyDisabled ? null : mDefaultProxy); } } public void setGlobalProxy(ProxyProperties proxyProperties) { - enforceChangePermission(); - synchronized (mGlobalProxyLock) { + enforceConnectivityInternalPermission(); + synchronized (mProxyLock) { if (proxyProperties == mGlobalProxy) return; if (proxyProperties != null && proxyProperties.equals(mGlobalProxy)) return; if (mGlobalProxy != null && mGlobalProxy.equals(proxyProperties)) return; @@ -3063,16 +3063,21 @@ public class ConnectivityService extends IConnectivityManager.Stub { mGlobalProxy = null; } ContentResolver res = mContext.getContentResolver(); - Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, host); - Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, port); - Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST, - exclList); + final long token = Binder.clearCallingIdentity(); + try { + Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, host); + Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, port); + Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST, + exclList); + } finally { + Binder.restoreCallingIdentity(token); + } } if (mGlobalProxy == null) { proxyProperties = mDefaultProxy; } - //sendProxyBroadcast(proxyProperties); + sendProxyBroadcast(proxyProperties); } private void loadGlobalProxy() { @@ -3083,7 +3088,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST); if (!TextUtils.isEmpty(host)) { ProxyProperties proxyProperties = new ProxyProperties(host, port, exclList); - synchronized (mGlobalProxyLock) { + synchronized (mProxyLock) { mGlobalProxy = proxyProperties; } } @@ -3094,7 +3099,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { // so this API change wouldn't have a benifit. It also breaks the passing // of proxy info to all the JVMs. // enforceAccessPermission(); - synchronized (mGlobalProxyLock) { + synchronized (mProxyLock) { return mGlobalProxy; } } @@ -3103,11 +3108,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (proxy != null && TextUtils.isEmpty(proxy.getHost())) { proxy = null; } - synchronized (mDefaultProxyLock) { + synchronized (mProxyLock) { if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return; - if (mDefaultProxy == proxy) return; + if (mDefaultProxy == proxy) return; // catches repeated nulls mDefaultProxy = proxy; + if (mGlobalProxy != null) return; if (!mDefaultProxyDisabled) { sendProxyBroadcast(proxy); } @@ -3350,10 +3356,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { mDnsOverridden = true; } - // Temporarily disable the default proxy. - synchronized (mDefaultProxyLock) { + // Temporarily disable the default proxy (not global). + synchronized (mProxyLock) { mDefaultProxyDisabled = true; - if (mDefaultProxy != null) { + if (mGlobalProxy == null && mDefaultProxy != null) { sendProxyBroadcast(null); } } @@ -3368,9 +3374,9 @@ public class ConnectivityService extends IConnectivityManager.Stub { mHandler.sendEmptyMessage(EVENT_RESTORE_DNS); } } - synchronized (mDefaultProxyLock) { + synchronized (mProxyLock) { mDefaultProxyDisabled = false; - if (mDefaultProxy != null) { + if (mGlobalProxy == null && mDefaultProxy != null) { sendProxyBroadcast(mDefaultProxy); } } |