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

Commit b7c06c17 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN Committed by Automerger Merge Worker
Browse files

Merge "Remove hidden API usage of Proxy.validate" am: a4a9e9bb am: 1065160b am: be34fb2c

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1552497

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I0581e1039bdfb55d9b12944a0f8e13b5ccce507e
parents 31b6f857 be34fb2c
Loading
Loading
Loading
Loading
+12 −17
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ import android.security.keystore.StrongBoxUnavailableException;
import android.service.restrictions.RestrictionsReceiver;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.DebugUtils;
import android.util.Log;
@@ -5349,29 +5350,23 @@ public class DevicePolicyManager {
        InetSocketAddress sa = (InetSocketAddress) proxySpec.address();
        String hostName = sa.getHostName();
        int port = sa.getPort();
        StringBuilder hostBuilder = new StringBuilder();
        final String hostSpec = hostBuilder.append(hostName)
                .append(":").append(Integer.toString(port)).toString();
        final String exclSpec;
        final List<String> trimmedExclList;
        if (exclusionList == null) {
            exclSpec = "";
            trimmedExclList = Collections.emptyList();
        } else {
            StringBuilder listBuilder = new StringBuilder();
            boolean firstDomain = true;
            trimmedExclList = new ArrayList<>(exclusionList.size());
            for (String exclDomain : exclusionList) {
                if (!firstDomain) {
                    listBuilder = listBuilder.append(",");
                } else {
                    firstDomain = false;
                trimmedExclList.add(exclDomain.trim());
            }
                listBuilder = listBuilder.append(exclDomain.trim());
        }
            exclSpec = listBuilder.toString();
        final ProxyInfo info = ProxyInfo.buildDirectProxy(hostName, port, trimmedExclList);
        // The hostSpec is built assuming that there is a specified port and hostname,
        // but ProxyInfo.isValid() accepts 0 / empty as unspecified: also reject them.
        if (port == 0 || TextUtils.isEmpty(hostName) || !info.isValid()) {
            throw new IllegalArgumentException();
        }
        if (android.net.Proxy.validate(hostName, Integer.toString(port), exclSpec)
                != android.net.Proxy.PROXY_VALID) throw new IllegalArgumentException();
        return new Pair<>(hostSpec, exclSpec);
        return new Pair<>(hostName + ":" + port, TextUtils.join(",", trimmedExclList));
    }
    /**