QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 QueenConfig.java 源代码,内容仅作参考


package com.tencent.common.http;

import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import com.facebook.common.util.UriUtil;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.tencent.basesupport.FLogger;
import com.tencent.common.http.Apn;
import com.tencent.common.http.HttpHeader;
import com.tencent.common.manifest.AppManifest;
import com.tencent.common.manifest.annotation.Extension;
import com.tencent.common.manifest.annotation.Service;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.common.utils.ThreadUtils;
import com.tencent.common.utils.UrlUtils;
import com.tencent.map.geolocation.util.DateUtils;
import com.tencent.mtt.AppInfoHolder;
import com.tencent.mtt.apkplugin.impl.IAPInjectService;
import com.tencent.tbs.common.internal.service.StatServerHolder;
import com.xiaomi.mipush.sdk.Constants;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;

public class QueenConfig {
    public static final int ERROR_CODE_API26 = 8;
    public static final int ERROR_CODE_DIRECT_REQUEST = 10;
    public static final int ERROR_CODE_DIRECT_URL = 4;
    public static final int ERROR_CODE_DISABLE = -2;
    public static final int ERROR_CODE_IPLIST_EMPTY = 2;
    public static final int ERROR_CODE_LOCAL_URL = 6;
    public static final int ERROR_CODE_OK = 0;
    public static final int ERROR_CODE_PROXY_ERROR = 3;
    public static final int ERROR_CODE_TOKEN_EMPTY = 1;
    public static final int ERROR_CODE_UNKNOWN = -1;
    public static final int ERROR_CODE_URL_CONNECTION = 9;
    public static final int ERROR_CODE_WHITE_LIST = 5;
    public static final int ERROR_CODE_WUP = 7;
    public static final String IPLIST_TYPE_HTTP = "queen_http";
    public static final String IPLIST_TYPE_HTTPS = "queen_https";
    public static final String TAG = "QueenConfig";

    static int f9641a;

    static int f9642b;

    static Object f9643c = new Object();

    static HashMap<String, QueenProxy> f9644d = null;
    static int e = 0;
    static int f = 0;
    static Object g = new Object();
    static HashMap<String, QueenProxy> h = null;
    static HashMap<String, ReportItem> i = null;
    static long j = 0;
    static Handler k = null;
    private static IQueenInfoProvider n = null;
    static AtomicBoolean l = new AtomicBoolean(false);
    static AtomicBoolean m = new AtomicBoolean(false);
    private static long o = 0;
    private static long p = 0;
    private static HostnameVerifier q = null;

    public static class DnsData {

        String f9645a;

        long f9646b;
        public String mIP;

        long f9647c = 1200000;
        public String mType = "NULL";
        public String mNetworkInfo = "";
        public int mFailTimes = 0;

        boolean a() {
            return System.currentTimeMillis() >= this.f9646b + this.f9647c;
        }

        public DnsData m30clone() {
            DnsData dnsData = new DnsData();
            dnsData.f9645a = this.f9645a;
            dnsData.mIP = this.mIP;
            dnsData.f9646b = this.f9646b;
            dnsData.f9647c = this.f9647c;
            dnsData.mType = this.mType;
            dnsData.mNetworkInfo = this.mNetworkInfo;
            return dnsData;
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof DnsData)) {
                return false;
            }
            DnsData dnsData = (DnsData) obj;
            return TextUtils.equals(this.mIP, dnsData.mIP) && TextUtils.equals(this.f9645a, dnsData.f9645a);
        }

        public int hashCode() {
            return (TextUtils.isEmpty(this.mIP) ? 0 : this.mIP.hashCode()) ^ (TextUtils.isEmpty(this.f9645a) ? 0 : this.f9645a.hashCode());
        }

        public String toString() {
            return "[domain=" + this.f9645a + ", ip=" + this.mIP + ", TTL=" + this.f9647c + ", expired=" + a() + ", type=" + this.mType + ", netInfo=" + this.mNetworkInfo + ", failTimes=" + this.mFailTimes + "]";
        }
    }

    @Extension
    @Service
    public interface IQueenInfoProvider {
        ArrayList<String> getHttpIPList();

        ArrayList<String> getHttpsIPList();

        DnsData getIPAddress(String str);

        String getToken();

        boolean handleCmd(String str);

        boolean isDownProxyEnable();

        boolean isInProxyList(String str);

        boolean isInWhiteList(String str);

        boolean isLocalProxyEnable();

        boolean isProxySwitchEnable();

        boolean isQueenSIM();

        boolean isQueenUser();

        boolean isTunnelProxyEnable();

        boolean isUrlDirect(String str);

        void refreshToken(IRefreshQueenTokenCallback iRefreshQueenTokenCallback);

        void updateIPList();
    }

    public interface IRefreshQueenTokenCallback {
        void onGetToken(String str);
    }

    public static class QueenConfigInfo {
        public QueenProxy proxyInfo = null;
        public Proxy proxy = null;
        public String url = null;
        public HashMap<String, String> headers = null;
        public boolean isHttpsRequest = false;
        public HostnameVerifier hostnameVerifier = null;
        public String guid = null;
        public String sQImei = null;
        public String sQImei36 = null;
        public String token = null;
        public String qua = null;
    }

    public static class QueenProxy {
        public int port;
        public String url;

        public QueenProxy(String str, int i) {
            this.url = null;
            this.port = 0;
            this.url = str;
            this.port = i;
        }

        public String toString() {
            return "[" + this.url + Constants.COLON_SEPARATOR + this.port + "]";
        }
    }

    public static class ReportItem {

        int f9648a = -1;

        String f9649b = null;

        String f9650c = null;

        String f9651d = null;
        int e = 0;
        long f = 0;
        int g = -1;
        int h = -1;
        boolean i = false;
        String j = null;

        ReportItem() {
        }
    }

    static Handler a() {
        Handler handler = k;
        if (handler != null) {
            return handler;
        }
        synchronized (QueenConfig.class) {
            if (k != null) {
                return k;
            }
            k = new Handler(BrowserExecutorSupplier.getLooperForRunLongTime()) {
                @Override
                public void handleMessage(Message message) {
                    if (message.what == 1001) {
                        QueenConfig.a((ReportItem) message.obj);
                    } else if (message.what == 1000) {
                        QueenConfig.d();
                    }
                }
            };
            return k;
        }
    }

    static String a(int i2) {
        switch (i2) {
            case 102:
                return "directrequest";
            case 103:
                return "urlConnection";
            case 104:
                return "download";
            case 105:
                return "wup";
            case 106:
                return "picture";
            case 107:
                return "music";
            case 108:
                return "feedsreport";
            case 109:
                return "videoreport";
            case 110:
                return "search";
            case 111:
                return "novel";
            case 112:
                return "httpcom";
            case 113:
                return "httpupload";
            case 114:
                return "apkdetect";
            case 115:
                return "videocache";
            case 116:
                return "videodownload";
            case 117:
            case 118:
            default:
                return IAPInjectService.EP_DEFAULT;
            case 119:
                return "sysmedia";
            case 120:
                return "x5audio";
        }
    }

    static String a(int i2, int i3) {
        if (i2 == 2) {
            return "iplistEmpty";
        }
        if (i2 == 1) {
            return "tokenEmpty";
        }
        if (i2 != 3) {
            return i2 == 4 ? "directUrl" : i2 == 5 ? "whiteList" : i2 == 6 ? "localUrl" : i2 == 7 ? "wup" : i2 == 8 ? "api26" : i2 == 9 ? "urlConnection" : i2 == 10 ? "directrequest" : "unknown";
        }
        return "statusCode_" + i3;
    }

    static void a(long j2) {
        try {
            Thread.sleep(j2);
        } catch (InterruptedException unused) {
        }
    }

    public static void a(MttRequestBase mttRequestBase, int i2, boolean z) {
        String str;
        String executeUrl = mttRequestBase.getExecuteUrl();
        if (mttRequestBase.isDirectionalEnable() && FreeFlow.isFreeFlowUser()) {
            long currentTimeMillis = System.currentTimeMillis();
            String host = UrlUtils.getHost(executeUrl);
            if (host.startsWith("127.0.0.1") || host.startsWith("localhost")) {
                return;
            }
            String convertUrlSync = FreeFlow.convertUrlSync(executeUrl);
            FLogger.d(TAG, "covertUrl cost: " + (System.currentTimeMillis() - currentTimeMillis));
            mttRequestBase.setDirectionalUrl(convertUrlSync);
            return;
        }
        if (isQueenProxyEnable()) {
            byte requestType = mttRequestBase.getRequestType();
            if (requestType == 105 || mttRequestBase.getIsWupRequest()) {
                FLogger.d(TAG, "wup request: " + executeUrl);
                mttRequestBase.setIsQueenFlow(true);
                mttRequestBase.setQueenProxyEnable(true);
                mttRequestBase.setQueenErrorCode(7);
                return;
            }
            if (requestType == 102) {
                FLogger.d(TAG, "direct request: " + executeUrl);
                mttRequestBase.setIsQueenFlow(true);
                mttRequestBase.setQueenProxyEnable(false);
                mttRequestBase.setQueenErrorCode(10);
                return;
            }
            if (requestType == 103) {
                FLogger.d(TAG, "url connection request: " + executeUrl);
                mttRequestBase.setIsQueenFlow(true);
                mttRequestBase.setQueenProxyEnable(false);
                mttRequestBase.setQueenErrorCode(9);
                return;
            }
            String host2 = UrlUtils.getHost(executeUrl);
            if ("127.0.0.1".equals(host2) || "localhost".equals(host2)) {
                FLogger.d(TAG, "is local url: " + executeUrl);
                mttRequestBase.setIsQueenFlow(true);
                mttRequestBase.setQueenProxyEnable(true);
                mttRequestBase.setQueenErrorCode(6);
                return;
            }
            IQueenInfoProvider infoProvider = getInfoProvider();
            if (infoProvider.isUrlDirect(executeUrl)) {
                FLogger.d(TAG, "direct url: " + executeUrl);
                mttRequestBase.setIsQueenFlow(false);
                mttRequestBase.setQueenProxyEnable(false);
                mttRequestBase.setQueenErrorCode(4);
                return;
            }
            boolean isHttpsUrl = UrlUtils.isHttpsUrl(executeUrl);
            if (isHttpsUrl && !z && Build.VERSION.SDK_INT >= 26) {
                mttRequestBase.setIsQueenFlow(false);
                mttRequestBase.setQueenProxyEnable(false);
                mttRequestBase.setQueenErrorCode(8);
                return;
            }
            if (infoProvider.isInProxyList(host2) || !infoProvider.isInWhiteList(host2)) {
                str = null;
            } else {
                FLogger.d(TAG, "find in white list: " + executeUrl);
                if (UrlUtils.isIpUrl(host2)) {
                    str = host2;
                } else {
                    DnsData iPAddress = getInfoProvider().getIPAddress(host2);
                    str = iPAddress != null ? iPAddress.mIP : null;
                }
                mttRequestBase.setIp(str);
                if (!TextUtils.isEmpty(str) && QueenDirectCache.getInstance().isIpDirect(str)) {
                    QueenConfigInfo queenConfigInfo = new QueenConfigInfo();
                    if (!str.equals(host2)) {
                        mttRequestBase.setTargetUrl(executeUrl.replaceFirst(host2, str));
                        queenConfigInfo.headers = new HashMap<>();
                        queenConfigInfo.headers.put("Host", host2);
                        queenConfigInfo.hostnameVerifier = getHostnameVerifier();
                    }
                    queenConfigInfo.isHttpsRequest = UrlUtils.isHttpsUrl(executeUrl);
                    mttRequestBase.setQueenConfig(queenConfigInfo);
                    mttRequestBase.setIsQueenFlow(true);
                    mttRequestBase.setQueenProxyEnable(true);
                    mttRequestBase.setQueenErrorCode(5);
                    return;
                }
            }
            if (!mttRequestBase.isQueenProxyEnable()) {
                FLogger.d(TAG, "proxy disable: " + executeUrl);
                mttRequestBase.setQueenConfig(null);
                return;
            }
            QueenProxy proxy = getProxy(getIpList(isHttpsUrl), isHttpsUrl ? 1 : 0);
            FLogger.d(TAG, "getProxy: " + proxy + " [" + mttRequestBase.getUrl() + "]");
            if (proxy == null) {
                mttRequestBase.setQueenErrorCode(2);
                return;
            }
            String token = getToken();
            FLogger.d(TAG, "getToken: " + token + " [" + mttRequestBase.getUrl() + "]");
            if (TextUtils.isEmpty(token)) {
                mttRequestBase.setQueenErrorCode(1);
                return;
            }
            QueenConfigInfo queenConfigInfo2 = new QueenConfigInfo();
            queenConfigInfo2.proxyInfo = proxy;
            queenConfigInfo2.proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy.url, proxy.port));
            queenConfigInfo2.isHttpsRequest = UrlUtils.isHttpsUrl(executeUrl);
            queenConfigInfo2.guid = AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_GUID);
            queenConfigInfo2.sQImei = AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_QIMEI_FORHTTPHEADER);
            queenConfigInfo2.sQImei36 = AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_QIMEI36_FORHTTPHEADER);
            queenConfigInfo2.qua = AppInfoHolder.getAppInfoByID(AppInfoHolder.AppInfoID.APP_INFO_QUA2_3);
            queenConfigInfo2.token = token;
            String a2 = a((int) mttRequestBase.getRequestType());
            if (queenConfigInfo2.isHttpsRequest) {
                StringBuilder sb = new StringBuilder();
                sb.append(HttpHeader.REQ.QGUID);
                sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
                sb.append(queenConfigInfo2.guid);
                sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
                sb.append(HttpHeader.REQ.QUA2);
                sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
                sb.append(queenConfigInfo2.qua);
                sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
                sb.append(HttpHeader.REQ.Q_TOKEN);
                sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
                sb.append(token);
                sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
                sb.append("Q-Type|");
                sb.append(a2);
                if (!TextUtils.isEmpty(str)) {
                    sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
                    sb.append("Q-DnsIp|");
                    sb.append(str);
                }
                if (i2 > 0) {
                    sb.append(",Q-Count|");
                    sb.append(i2);
                }
                if (!TextUtils.isEmpty(queenConfigInfo2.sQImei)) {
                    sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
                    sb.append(HttpHeader.REQ.Q_QIMEI);
                    sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
                    sb.append(queenConfigInfo2.sQImei);
                }
                if (!TextUtils.isEmpty(queenConfigInfo2.sQImei36)) {
                    sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
                    sb.append(HttpHeader.REQ.QIMEI36);
                    sb.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
                    sb.append(queenConfigInfo2.sQImei36);
                }
                queenConfigInfo2.headers = new HashMap<>();
                queenConfigInfo2.headers.put("Proxy-Authorization", sb.toString());
            } else {
                queenConfigInfo2.headers = new HashMap<>();
                queenConfigInfo2.headers.put(HttpHeader.REQ.QGUID, queenConfigInfo2.guid);
                queenConfigInfo2.headers.put(HttpHeader.REQ.QUA2, queenConfigInfo2.qua);
                queenConfigInfo2.headers.put(HttpHeader.REQ.Q_TOKEN, token);
                queenConfigInfo2.headers.put("Q-Type", a2);
                if (!TextUtils.isEmpty(queenConfigInfo2.sQImei)) {
                    queenConfigInfo2.headers.put(HttpHeader.REQ.Q_QIMEI, queenConfigInfo2.sQImei);
                }
                if (!TextUtils.isEmpty(queenConfigInfo2.sQImei36)) {
                    queenConfigInfo2.headers.put(HttpHeader.REQ.QIMEI36, queenConfigInfo2.sQImei36);
                }
                if (!TextUtils.isEmpty(str)) {
                    queenConfigInfo2.headers.put("Q-DnsIp", str);
                }
                if (i2 > 0) {
                    queenConfigInfo2.headers.put("Q-Count", i2 + "");
                }
            }
            mttRequestBase.setIsQueenFlow(true);
            mttRequestBase.setQueenConfig(queenConfigInfo2);
        }
    }

    static void a(ReportItem reportItem) {
        if (i == null) {
            i = new HashMap<>();
        }
        long currentTimeMillis = System.currentTimeMillis();
        if (j == 0) {
            j = currentTimeMillis;
        }
        Handler a2 = a();
        if (Math.abs(currentTimeMillis - j) > DateUtils.TEN_SECOND) {
            a2.removeMessages(1000);
            d();
        }
        String b2 = b(reportItem);
        ReportItem reportItem2 = i.get(b2);
        if (reportItem2 == null) {
            reportItem.f9649b = b2;
            i.put(b2, reportItem);
        } else {
            reportItem2.f += reportItem.f;
        }
        a2.removeMessages(1000);
        a2.sendEmptyMessageDelayed(1000, 3000L);
    }

    static int b() {
        ArrayList<String> ipList = getIpList(false);
        if (ipList != null) {
            return ipList.size();
        }
        return 0;
    }

    static String b(ReportItem reportItem) {
        return (reportItem.f9648a == 7 || reportItem.g == 106 || reportItem.g == 109 || reportItem.g == 108) ? UrlUtils.getHost(reportItem.f9649b) : reportItem.f9649b;
    }

    static int c() {
        ArrayList<String> ipList = getIpList(true);
        if (ipList != null) {
            return ipList.size();
        }
        return 0;
    }

    static void c(ReportItem reportItem) {
        HashMap hashMap = new HashMap();
        hashMap.put("module", UrlUtils.isHttpsUrl(reportItem.f9649b) ? "https_tunnel" : UriUtil.HTTP_SCHEME);
        hashMap.put("retcode", String.valueOf(reportItem.e));
        hashMap.put("url", reportItem.f9649b);
        String str = reportItem.f9651d;
        String str2 = IAPInjectService.EP_NULL;
        hashMap.put("refer", str != null ? reportItem.f9651d : IAPInjectService.EP_NULL);
        hashMap.put("bytes", String.valueOf(reportItem.f));
        hashMap.put("resourcetype", a(reportItem.g));
        hashMap.put("directreason", a(reportItem.f9648a, reportItem.h));
        if (!TextUtils.isEmpty(reportItem.f9650c)) {
            str2 = reportItem.f9650c;
        }
        hashMap.put("dnsip", str2);
        if (!TextUtils.isEmpty(reportItem.j)) {
            hashMap.put("callfrom", reportItem.j);
        }
        FLogger.d(TAG, "report: " + hashMap);
        StatServerHolder.statWithBeacon(reportItem.i ? "QUEEN_ERROR" : "QUEEN_PROXY", hashMap);
    }

    static void d() {
        HashMap<String, ReportItem> hashMap = i;
        if (hashMap == null || hashMap.size() < 1) {
            return;
        }
        for (Map.Entry<String, ReportItem> entry : i.entrySet()) {
            entry.getKey();
            c(entry.getValue());
        }
        i.clear();
        j = System.currentTimeMillis();
    }

    public static HostnameVerifier getHostnameVerifier() {
        HostnameVerifier hostnameVerifier = q;
        if (hostnameVerifier != null) {
            return hostnameVerifier;
        }
        synchronized (HostnameVerifier.class) {
            if (q == null) {
                q = new HostnameVerifier() {
                    @Override
                    public boolean verify(String str, SSLSession sSLSession) {
                        return str.equals(sSLSession.getPeerHost());
                    }
                };
            }
        }
        return q;
    }

    public static IQueenInfoProvider getInfoProvider() {
        IQueenInfoProvider iQueenInfoProvider = n;
        if (iQueenInfoProvider != null) {
            return iQueenInfoProvider;
        }
        synchronized (IQueenInfoProvider.class) {
            if (n == null) {
                try {
                    n = (IQueenInfoProvider) AppManifest.getInstance().queryExtension(IQueenInfoProvider.class, null);
                } catch (Throwable unused) {
                }
                if (n == null) {
                    n = new IQueenInfoProvider() {
                        @Override
                        public ArrayList<String> getHttpIPList() {
                            return null;
                        }

                        @Override
                        public ArrayList<String> getHttpsIPList() {
                            return null;
                        }

                        @Override
                        public DnsData getIPAddress(String str) {
                            return null;
                        }

                        @Override
                        public String getToken() {
                            return null;
                        }

                        @Override
                        public boolean handleCmd(String str) {
                            return false;
                        }

                        @Override
                        public boolean isDownProxyEnable() {
                            return false;
                        }

                        @Override
                        public boolean isInProxyList(String str) {
                            return false;
                        }

                        @Override
                        public boolean isInWhiteList(String str) {
                            return false;
                        }

                        @Override
                        public boolean isLocalProxyEnable() {
                            return false;
                        }

                        @Override
                        public boolean isProxySwitchEnable() {
                            return false;
                        }

                        @Override
                        public boolean isQueenSIM() {
                            return false;
                        }

                        @Override
                        public boolean isQueenUser() {
                            return false;
                        }

                        @Override
                        public boolean isTunnelProxyEnable() {
                            return false;
                        }

                        @Override
                        public boolean isUrlDirect(String str) {
                            return false;
                        }

                        @Override
                        public void refreshToken(IRefreshQueenTokenCallback iRefreshQueenTokenCallback) {
                        }

                        @Override
                        public void updateIPList() {
                        }
                    };
                }
            }
        }
        return n;
    }

    public static ArrayList<String> getIpList(boolean z) {
        ArrayList<String> httpIPList;
        IQueenInfoProvider infoProvider = getInfoProvider();
        if (z) {
            httpIPList = infoProvider.getHttpsIPList();
            int size = httpIPList != null ? httpIPList.size() : 0;
            if (size != e) {
                f = 0;
                e = size;
            }
        } else {
            httpIPList = infoProvider.getHttpIPList();
            int size2 = httpIPList != null ? httpIPList.size() : 0;
            if (size2 != f9641a) {
                f9642b = 0;
                f9641a = size2;
            }
        }
        if (httpIPList == null || httpIPList.size() < 1) {
            f9642b = 0;
            f = 0;
            f9641a = 0;
            e = 0;
            refreshIPListIfNeed();
            if (!ThreadUtils.isMainThread() && m.compareAndSet(false, true)) {
                FLogger.d(TAG, "WAIT IPLIST...");
                a(3000L);
                httpIPList = z ? infoProvider.getHttpsIPList() : infoProvider.getHttpIPList();
                int size3 = httpIPList != null ? httpIPList.size() : 0;
                if (z) {
                    e = size3;
                } else {
                    f9641a = size3;
                }
            }
        }
        return httpIPList;
    }

    protected static QueenProxy getProxy(ArrayList<String> arrayList, int i2) {
        QueenProxy queenProxy;
        QueenProxy queenProxy2;
        if (arrayList != null && arrayList.size() >= 1) {
            int i3 = -1;
            if (i2 == 0) {
                i3 = f9642b;
            } else if (i2 == 1) {
                i3 = f;
            }
            if (i3 < 0 || i3 >= arrayList.size()) {
                i3 = 0;
            }
            String str = arrayList.get(i3);
            if (str == null) {
                return null;
            }
            if (i2 == 0) {
                synchronized (f9643c) {
                    if (f9644d != null && (queenProxy2 = f9644d.get(str)) != null) {
                        return queenProxy2;
                    }
                    String[] split = str.split(Constants.COLON_SEPARATOR);
                    if (split != null && split.length >= 2) {
                        if (f9644d == null) {
                            f9644d = new HashMap<>();
                        }
                        QueenProxy queenProxy3 = new QueenProxy(split[0], Integer.parseInt(split[1]));
                        f9644d.put(str, queenProxy3);
                        return queenProxy3;
                    }
                    return null;
                }
            }
            if (i2 == 1) {
                synchronized (g) {
                    if (h != null && (queenProxy = h.get(str)) != null) {
                        return queenProxy;
                    }
                    String[] split2 = str.split(Constants.COLON_SEPARATOR);
                    if (split2 != null && split2.length >= 2) {
                        if (h == null) {
                            h = new HashMap<>();
                        }
                        QueenProxy queenProxy4 = new QueenProxy(split2[0], Integer.parseInt(split2[1]));
                        h.put(str, queenProxy4);
                        return queenProxy4;
                    }
                    return null;
                }
            }
        }
        return null;
    }

    public static String getToken() {
        IQueenInfoProvider infoProvider = getInfoProvider();
        String token = infoProvider.getToken();
        if (!TextUtils.isEmpty(token)) {
            return token;
        }
        refreshTokenIfNeed();
        if (ThreadUtils.isMainThread() || !l.compareAndSet(false, true)) {
            return token;
        }
        FLogger.d(TAG, "WAIT TOKEN...");
        a(3000L);
        return infoProvider.getToken();
    }

    public static boolean isQueenEnable() {
        IQueenInfoProvider infoProvider = getInfoProvider();
        return infoProvider.isDownProxyEnable() && infoProvider.isTunnelProxyEnable() && infoProvider.isQueenUser();
    }

    protected static boolean isQueenProxyEnable() {
        IQueenInfoProvider infoProvider = getInfoProvider();
        Apn.ApnInfo apnInfo = Apn.getApnInfo(true);
        return infoProvider.isProxySwitchEnable() || (apnInfo.isMobileNetwork() && !apnInfo.isWapPoint() && infoProvider.isDownProxyEnable() && infoProvider.isQueenUser());
    }

    public static boolean isQueenSIM() {
        return getInfoProvider().isQueenSIM();
    }

    public static void refreshIPListIfNeed() {
        long currentTimeMillis = System.currentTimeMillis();
        if (Math.abs(currentTimeMillis - o) < 5000) {
            return;
        }
        o = currentTimeMillis;
        getInfoProvider().updateIPList();
    }

    public static void refreshTokenIfNeed() {
        long currentTimeMillis = System.currentTimeMillis();
        if (Math.abs(currentTimeMillis - p) < 5000) {
            return;
        }
        p = currentTimeMillis;
        getInfoProvider().refreshToken(new IRefreshQueenTokenCallback() {
            @Override
            public void onGetToken(String str) {
                FLogger.d(QueenConfig.TAG, "onGetToken: " + str);
            }
        });
    }

    public static void report(int i2, String str, String str2, int i3, long j2, int i4, int i5, String str3, boolean z, String str4) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        ReportItem reportItem = new ReportItem();
        reportItem.f9648a = i2;
        reportItem.f9649b = str;
        reportItem.f9651d = str2;
        reportItem.e = i3;
        reportItem.f = j2;
        reportItem.g = i4;
        reportItem.h = i5;
        reportItem.f9650c = str3;
        reportItem.i = z;
        reportItem.j = str4;
        Message obtainMessage = a().obtainMessage();
        obtainMessage.obj = reportItem;
        obtainMessage.what = 1001;
        a().sendMessage(obtainMessage);
    }

    public static void reportProxyError(int i2, String str, int i3, String str2) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        HashMap hashMap = new HashMap();
        hashMap.put("code", String.valueOf(i2));
        hashMap.put("url", str);
        if (TextUtils.isEmpty(str2)) {
            str2 = IAPInjectService.EP_NULL;
        }
        hashMap.put("token", str2);
        FLogger.d(TAG, "report proxy error: " + hashMap);
        StatServerHolder.statWithBeacon("QUEEN_PROXY_ERROR", hashMap);
    }

    public static boolean switchHttpProxy() {
        int b2 = b();
        if (b2 < 1) {
            return false;
        }
        f9642b++;
        if (f9642b < b2) {
            return true;
        }
        f9642b = 0;
        return false;
    }

    public static boolean switchHttpsProxy() {
        int c2 = c();
        if (c2 < 1) {
            return false;
        }
        f++;
        if (f < c2) {
            return true;
        }
        f = 0;
        return false;
    }
}