Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a1778af authored by Oscar Montemayor's avatar Oscar Montemayor Committed by Android (Google) Code Review
Browse files

Merge "Fix for bug 2890320 Browser crashes, after adding bookmark. Simplified...

Merge "Fix for bug 2890320 Browser crashes, after adding bookmark. Simplified locking scheme in Proxy's getProxy(..) method. Also modified ContentObserver creation to be done from any thread."
parents 90d5e8c0 6f71b42b
Loading
Loading
Loading
Loading
+13 −23
Original line number Diff line number Diff line
@@ -150,30 +150,14 @@ public final class Proxy {
                    // Return no proxy
                    retval = java.net.Proxy.NO_PROXY;
                } else {
                    java.net.Proxy retProxy =
                    retval =
                        new java.net.Proxy(java.net.Proxy.Type.HTTP, sGlobalProxySpec.proxyAddress);
                    sProxyInfoLock.readLock().unlock();
                    if (isLocalHost(url)) {
                        sProxyInfoLock.readLock().lock();
                        retval = java.net.Proxy.NO_PROXY;
                    } else {
                        sProxyInfoLock.readLock().lock();
                        retval = retProxy;
                    }
                }
            } else {
                // If network is WiFi, return no proxy.
                // Otherwise, return the Mobile Operator proxy.
                if (!isNetworkWifi(ctx)) {
                    java.net.Proxy retProxy = getDefaultProxy(url);
                    sProxyInfoLock.readLock().unlock();
                    if (isLocalHost(url)) {
                        sProxyInfoLock.readLock().lock();
                        retval = java.net.Proxy.NO_PROXY;
                    } else {
                        sProxyInfoLock.readLock().lock();
                        retval = retProxy;
                    }
                    retval = getDefaultProxy(url);
                } else {
                    retval = java.net.Proxy.NO_PROXY;
                }
@@ -181,6 +165,9 @@ public final class Proxy {
        } finally {
            sProxyInfoLock.readLock().unlock();
        }
        if ((retval != java.net.Proxy.NO_PROXY) && (isLocalHost(url))) {
            retval = java.net.Proxy.NO_PROXY;
        }
        return retval;
    }

@@ -348,7 +335,7 @@ public final class Proxy {
        private Context mContext;

        SettingsObserver(Context ctx) {
            super(new Handler());
            super(new Handler(ctx.getMainLooper()));
            mContext = ctx;
        }

@@ -368,10 +355,13 @@ public final class Proxy {
        // No lock upgrading (from read to write) allowed
        sProxyInfoLock.readLock().unlock();
        sProxyInfoLock.writeLock().lock();
        try {
            sGlobalProxyChangedObserver = new SettingsObserver(ctx);
        } finally {
            // Downgrading locks (from write to read) is allowed
            sProxyInfoLock.readLock().lock();
            sProxyInfoLock.writeLock().unlock();
        }
        ctx.getContentResolver().registerContentObserver(uriGlobalProxy, false,
                sGlobalProxyChangedObserver);
        ctx.getContentResolver().registerContentObserver(uriGlobalExclList, false,