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

Commit 3c3711df authored by Serik Beketayev's avatar Serik Beketayev Committed by Gerrit Code Review
Browse files

Merge "[Mainline] Migrate ProxyInfo"

parents 771aa062 4abaecef
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.os.Build;
import android.text.TextUtils;
import android.util.Log;

import com.android.net.module.util.ProxyUtils;

import java.net.InetSocketAddress;
import java.net.ProxySelector;
import java.net.URI;
@@ -251,7 +253,7 @@ public final class Proxy {
        if (p != null) {
            host = p.getHost();
            port = Integer.toString(p.getPort());
            exclList = p.getExclusionListAsString();
            exclList = ProxyUtils.exclusionListAsString(p.getExclusionList());
            pacFileUrl = p.getPacFileUrl();
        }
        setHttpProxySystemProperty(host, port, exclList, pacFileUrl);
+8 −5
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.os.Parcelable;
import android.text.TextUtils;

import com.android.internal.annotations.VisibleForTesting;
import com.android.net.module.util.ProxyUtils;

import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
@@ -285,10 +286,12 @@ public final class VpnProfile implements Cloneable, Parcelable {
                String exclList = (values.length > 17) ? values[17] : "";
                String pacFileUrl = (values.length > 18) ? values[18] : "";
                if (!host.isEmpty() || !port.isEmpty() || !exclList.isEmpty()) {
                    profile.proxy = new ProxyInfo(host, port.isEmpty() ?
                            0 : Integer.parseInt(port), exclList);
                    profile.proxy =
                            ProxyInfo.buildDirectProxy(host, port.isEmpty() ?
                                    0 : Integer.parseInt(port),
                                    ProxyUtils.exclusionStringAsList(exclList));
                } else if (!pacFileUrl.isEmpty()) {
                    profile.proxy = new ProxyInfo(Uri.parse(pacFileUrl));
                    profile.proxy = ProxyInfo.buildPacProxy(Uri.parse(pacFileUrl));
                }
            } // else profile.proxy = null

@@ -337,8 +340,8 @@ public final class VpnProfile implements Cloneable, Parcelable {
            builder.append(VALUE_DELIMITER).append(proxy.getPort());
            builder.append(VALUE_DELIMITER)
                    .append(
                            proxy.getExclusionListAsString() != null
                                    ? proxy.getExclusionListAsString()
                            ProxyUtils.exclusionListAsString(proxy.getExclusionList()) != null
                                    ? ProxyUtils.exclusionListAsString(proxy.getExclusionList())
                                    : "");
            builder.append(VALUE_DELIMITER).append(proxy.getPacFileUrl().toString());
        } else {
+1 −1
Original line number Diff line number Diff line
@@ -390,7 +390,7 @@ public class PacManager {
            return;
        }
        if (!mHasSentBroadcast) {
            sendPacBroadcast(new ProxyInfo(mPacUrl, mLastPort));
            sendPacBroadcast(ProxyInfo.buildPacProxy(mPacUrl, mLastPort));
            mHasSentBroadcast = true;
        }
    }
+10 −5
Original line number Diff line number Diff line
@@ -38,7 +38,9 @@ import android.text.TextUtils;
import android.util.Log;

import com.android.internal.annotations.GuardedBy;
import com.android.net.module.util.ProxyUtils;

import java.util.Collections;
import java.util.Objects;

/**
@@ -163,9 +165,10 @@ public class ProxyTracker {
        if (!TextUtils.isEmpty(host) || !TextUtils.isEmpty(pacFileUrl)) {
            ProxyInfo proxyProperties;
            if (!TextUtils.isEmpty(pacFileUrl)) {
                proxyProperties = new ProxyInfo(Uri.parse(pacFileUrl));
                proxyProperties = ProxyInfo.buildPacProxy(Uri.parse(pacFileUrl));
            } else {
                proxyProperties = new ProxyInfo(host, port, exclList);
                proxyProperties = ProxyInfo.buildDirectProxy(host, port,
                        ProxyUtils.exclusionStringAsList(exclList));
            }
            if (!proxyProperties.isValid()) {
                if (DBG) Log.d(TAG, "Invalid proxy properties, ignoring: " + proxyProperties);
@@ -204,7 +207,8 @@ public class ProxyTracker {
                    return false;
                }
            }
            final ProxyInfo p = new ProxyInfo(proxyHost, proxyPort, "");
            final ProxyInfo p = ProxyInfo.buildDirectProxy(proxyHost, proxyPort,
                    Collections.emptyList());
            setGlobalProxy(p);
            return true;
        }
@@ -219,7 +223,8 @@ public class ProxyTracker {
     */
    public void sendProxyBroadcast() {
        final ProxyInfo defaultProxy = getDefaultProxy();
        final ProxyInfo proxyInfo = null != defaultProxy ? defaultProxy : new ProxyInfo("", 0, "");
        final ProxyInfo proxyInfo = null != defaultProxy ?
                defaultProxy : ProxyInfo.buildDirectProxy("", 0, Collections.emptyList());
        if (mPacManager.setCurrentProxyScriptUrl(proxyInfo) == PacManager.DONT_SEND_BROADCAST) {
            return;
        }
@@ -261,7 +266,7 @@ public class ProxyTracker {
                mGlobalProxy = new ProxyInfo(proxyInfo);
                host = mGlobalProxy.getHost();
                port = mGlobalProxy.getPort();
                exclList = mGlobalProxy.getExclusionListAsString();
                exclList = ProxyUtils.exclusionListAsString(mGlobalProxy.getExclusionList());
                pacFileUrl = Uri.EMPTY.equals(proxyInfo.getPacFileUrl())
                        ? "" : proxyInfo.getPacFileUrl().toString();
            } else {
+7 −4
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.util.Log;
import android.util.SparseArray;

import com.android.internal.annotations.VisibleForTesting;
import com.android.net.module.util.ProxyUtils;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
@@ -123,7 +124,8 @@ public class IpConfigStore {
            switch (config.proxySettings) {
                case STATIC:
                    ProxyInfo proxyProperties = config.httpProxy;
                    String exclusionList = proxyProperties.getExclusionListAsString();
                    String exclusionList = ProxyUtils.exclusionListAsString(
                            proxyProperties.getExclusionList());
                    out.writeUTF(PROXY_SETTINGS_KEY);
                    out.writeUTF(config.proxySettings.toString());
                    out.writeUTF(PROXY_HOST_KEY);
@@ -370,13 +372,14 @@ public class IpConfigStore {

                    switch (proxySettings) {
                        case STATIC:
                            ProxyInfo proxyInfo =
                                    new ProxyInfo(proxyHost, proxyPort, exclusionList);
                            ProxyInfo proxyInfo = ProxyInfo.buildDirectProxy(proxyHost, proxyPort,
                                    ProxyUtils.exclusionStringAsList(exclusionList));
                            config.proxySettings = proxySettings;
                            config.httpProxy = proxyInfo;
                            break;
                        case PAC:
                            ProxyInfo proxyPacProperties = new ProxyInfo(Uri.parse(pacFileUrl));
                            ProxyInfo proxyPacProperties =
                                    ProxyInfo.buildPacProxy(Uri.parse(pacFileUrl));
                            config.proxySettings = proxySettings;
                            config.httpProxy = proxyPacProperties;
                            break;
Loading