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

Commit 3b9244b4 authored by Robert Greenwalt's avatar Robert Greenwalt Committed by Gerrit Code Review
Browse files

Merge "Fix for the invalid Global Proxy Setting"

parents 87c5eeb4 f89fade0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -115,6 +115,16 @@ public class ProxyProperties implements Parcelable {
        return false;
    }

    public boolean isValid() {
        try {
            Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort),
                    mExclusionList == null ? "" : mExclusionList);
        } catch (IllegalArgumentException e) {
            return false;
        }
        return true;
    }

    public java.net.Proxy makeProxy() {
        java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
        if (mHost != null) {
+14 −0
Original line number Diff line number Diff line
@@ -3117,6 +3117,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
            int port = 0;
            String exclList = "";
            if (proxyProperties != null && !TextUtils.isEmpty(proxyProperties.getHost())) {
                if (!proxyProperties.isValid()) {
                    if (DBG)
                        log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
                    return;
                }
                mGlobalProxy = new ProxyProperties(proxyProperties);
                host = mGlobalProxy.getHost();
                port = mGlobalProxy.getPort();
@@ -3150,6 +3155,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST);
        if (!TextUtils.isEmpty(host)) {
            ProxyProperties proxyProperties = new ProxyProperties(host, port, exclList);
            if (!proxyProperties.isValid()) {
                if (DBG) log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
                return;
            }

            synchronized (mProxyLock) {
                mGlobalProxy = proxyProperties;
            }
@@ -3173,6 +3183,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        synchronized (mProxyLock) {
            if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return;
            if (mDefaultProxy == proxy) return; // catches repeated nulls
            if (!proxy.isValid()) {
                if (DBG) log("Invalid proxy properties, ignoring: " + proxy.toString());
                return;
            }
            mDefaultProxy = proxy;

            if (mGlobalProxy != null) return;
+7 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.net.ProxyProperties;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -2159,6 +2160,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
        exclusionList = exclusionList.trim();
        ContentResolver res = mContext.getContentResolver();

        ProxyProperties proxyProperties = new ProxyProperties(data[0], proxyPort, exclusionList);
        if (!proxyProperties.isValid()) {
            Slog.e(TAG, "Invalid proxy properties, ignoring: " + proxyProperties.toString());
            return;
        }
        Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, data[0]);
        Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, proxyPort);
        Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST,