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

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


package kcsdkint;

import android.content.Context;
import android.os.Build;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Pair;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.tencent.map.geolocation.util.DateUtils;
import com.tencent.mtt.base.task.Task;
import com.tencent.mtt.browser.jsextension.open.IOpenJsApis;
import com.tencent.mtt.compliance.MethodDelegate;
import com.xiaomi.mipush.sdk.Constants;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ProtocolException;
import java.net.Proxy;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Map;
import oicq.wlogin_sdk.tools.util;

public final class jr {
    private static volatile boolean s;
    private static volatile String t;
    private static volatile boolean u;
    private static volatile boolean v;
    private static volatile long w;
    private static volatile long x;
    private static volatile String z;

    HttpURLConnection f84434a;

    private String f84437d;
    private byte[] f;
    private boolean o;
    private boolean p;
    private String q;
    private int r;
    private static Object y = new Object();
    private static ArrayList<Pair<Integer, Long>> A = new ArrayList<>();
    private String e = "GET";

    int f84435b = -1;

    Hashtable<String, String> f84436c = new Hashtable<>(0);
    private boolean g = false;
    private boolean h = true;
    private byte i = 0;
    private byte j = 0;
    private byte k = 0;
    private int l = 30000;
    private int m = 30000;
    private boolean n = true;

    private jr(Context context, String str) {
        this.f84437d = str;
        b(context);
    }

    public static jr a(Context context, String str, boolean z2, String str2, int i) {
        b(context);
        if (!kc.f(context) && Thread.currentThread().getId() == Looper.getMainLooper().getThread().getId()) {
            throw new kl();
        }
        if (str == null || str.length() == 0) {
            throw new kk(-1000, "url is null!");
        }
        jr jrVar = new jr(context, str);
        jrVar.o = true;
        jrVar.p = z2;
        jrVar.q = str2;
        jrVar.r = i;
        jrVar.n = false;
        jrVar.a(str, z2, str2, i);
        return jrVar;
    }

    private void a(Context context, String str, int i) {
        try {
            f();
            if (i != 0) {
                if (3 == i) {
                    Proxy proxy = new Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved(kc.d(context), kc.e(context)));
                    System.currentTimeMillis();
                    this.f84434a = (HttpURLConnection) new URL(str).openConnection(proxy);
                    System.currentTimeMillis();
                    this.g = true;
                    return;
                }
                System.currentTimeMillis();
                this.f84434a = (HttpURLConnection) new URL(str).openConnection();
                System.currentTimeMillis();
                this.g = false;
                this.f84434a.setReadTimeout(this.m);
                this.f84434a.setConnectTimeout(this.l);
            }
        } catch (IOException e) {
            throw new kk(-1056, "IOException : " + e.getMessage());
        } catch (IllegalArgumentException e2) {
            throw new kk(-1057, "IllegalArgumentException : " + e2.getMessage());
        } catch (SecurityException e3) {
            throw new kk(-1058, "SecurityException: " + e3.getMessage());
        } catch (UnsupportedOperationException e4) {
            throw new kk(-1059, "UnsupportedOperationException: " + e4.getMessage());
        }
    }

    private void a(String str, boolean z2, String str2, int i) {
        try {
            f();
            if (z2) {
                if (str2 == null) {
                    str2 = "10.0.0.172";
                }
                if (i < 0) {
                    i = 80;
                }
                this.f84434a = (HttpURLConnection) new URL(str).openConnection(new Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved(str2, i)));
                this.g = true;
            } else {
                this.f84434a = (HttpURLConnection) new URL(str).openConnection();
                this.g = false;
            }
            this.f84434a.setReadTimeout(30000);
            this.f84434a.setConnectTimeout(this.l);
        } catch (IOException e) {
            throw new kk(-1056, "IOException : " + e.getMessage());
        } catch (IllegalArgumentException e2) {
            throw new kk(-1057, "IllegalArgumentException : " + e2.getMessage());
        } catch (SecurityException e3) {
            throw new kk(-1058, "SecurityException: " + e3.getMessage());
        } catch (UnsupportedOperationException e4) {
            throw new kk(-1059, "UnsupportedOperationException: " + e4.getMessage());
        }
    }

    private void a(Hashtable<String, String> hashtable) {
        if (hashtable == null || hashtable.size() == 0 || this.f84434a == null) {
            return;
        }
        for (Map.Entry<String, String> entry : hashtable.entrySet()) {
            this.f84434a.setRequestProperty(entry.getKey(), entry.getValue());
        }
    }

    private static void b(Context context) {
        kb kbVar = new kb(context, "wup");
        x = kbVar.a().getLong("dnc", 0L);
        String string = kbVar.a().getString("cn_t_a", "");
        z = string;
        if (TextUtils.isEmpty(string)) {
            return;
        }
        for (String str : z.split("\\|")) {
            if (!TextUtils.isEmpty(str)) {
                String[] split = str.split(Constants.ACCEPT_TIME_SEPARATOR_SP);
                try {
                    synchronized (A) {
                        if (A.size() <= 4) {
                            A.add(new Pair<>(Integer.valueOf(split[0]), Long.valueOf(split[1])));
                        }
                    }
                } catch (Exception unused) {
                    continue;
                }
            }
        }
    }

    private void b(String str) {
        this.e = str;
        if ("GET".equalsIgnoreCase(str)) {
            this.e = "GET";
        } else if ("POST".equalsIgnoreCase(str)) {
            this.e = "POST";
        }
    }

    private int c(Context context) {
        byte[] bArr;
        b();
        if (this.o) {
            a(this.f84437d, this.p, this.q, this.r);
        } else {
            if (kc.a(context) == 0) {
                throw new kk(-1052, "no connecition!");
            }
            a(context, this.f84437d, kc.a(context));
        }
        b(this.e);
        if ("POST".equalsIgnoreCase(this.e) && (bArr = this.f) != null) {
            this.f = bArr;
        }
        a(this.f84436c);
        return a(context);
    }

    private static boolean c() {
        synchronized (y) {
            long currentTimeMillis = System.currentTimeMillis();
            return !(((x - currentTimeMillis) > 5184000L ? 1 : ((x - currentTimeMillis) == 5184000L ? 0 : -1)) > 0) && (((x - currentTimeMillis) > 0L ? 1 : ((x - currentTimeMillis) == 0L ? 0 : -1)) >= 0);
        }
    }

    private static String[] c(String str) {
        String[] strArr = new String[2];
        int indexOf = str.indexOf("://");
        if (-1 != indexOf) {
            str = str.substring(indexOf + 3);
        }
        int indexOf2 = str.indexOf("/");
        if (-1 != indexOf2) {
            strArr[0] = str.substring(0, indexOf2);
            strArr[1] = str.substring(indexOf2);
        } else {
            strArr[0] = str;
            strArr[1] = "";
        }
        return strArr;
    }

    private String d() {
        try {
            return this.f84434a.getHeaderField("Content-Type");
        } catch (Exception e) {
            throw new kk(-56, "get content type: " + e.getMessage());
        }
    }

    private String e() {
        try {
            return this.f84434a.getHeaderField("Location");
        } catch (Exception e) {
            throw new kk(-56, "get redirect url: " + e.getMessage());
        }
    }

    private String f() {
        String str = this.f84437d;
        if (str == null) {
            return "";
        }
        HttpURLConnection httpURLConnection = this.f84434a;
        String host = httpURLConnection != null ? httpURLConnection.getURL().getHost() : c(str)[0];
        if ((host == null || host.length() == 0) && this.f84434a == null) {
            host = c(this.f84437d)[0];
        }
        try {
            InetAddress byName = InetAddress.getByName(host);
            if (byName != null) {
                return MethodDelegate.getHostAddress(byName);
            }
        } catch (SecurityException | UnknownHostException unused) {
        }
        return "";
    }

    public final int a(Context context) {
        int i;
        UnknownHostException e;
        byte[] bArr;
        int i2;
        while (!c()) {
            try {
                if (Build.VERSION.SDK_INT < 8) {
                    System.setProperty("http.keepAlive", "false");
                }
                this.f84434a.setUseCaches(false);
                this.f84434a.setRequestProperty("Pragma", "no-cache");
                this.f84434a.setRequestProperty("Cache-Control", "no-cache");
                this.f84434a.setInstanceFollowRedirects(false);
                i = "GET".equalsIgnoreCase(this.e);
            } catch (IllegalAccessError e2) {
                e = e2;
                i = 0;
            } catch (IllegalStateException e3) {
                e = e3;
                i = 0;
            } catch (ProtocolException e4) {
                e = e4;
                i = 0;
            } catch (SocketException e5) {
                e = e5;
                i = 0;
            } catch (SocketTimeoutException e6) {
                e = e6;
                i = 0;
            } catch (UnknownHostException e7) {
                e = e7;
                i = 0;
            } catch (kk e8) {
                e = e8;
                i = 0;
            } catch (Exception e9) {
                e = e9;
                i = 0;
            }
            try {
                if (i != 0) {
                    i2 = -3000;
                    this.f84434a.setRequestMethod("GET");
                } else {
                    i2 = util.E_LOGIN_THROUGH_WEB;
                    this.f84434a.setRequestMethod("POST");
                    if (!this.f84436c.containsKey("Accept")) {
                        this.f84434a.setRequestProperty("Accept", "*/*");
                        this.f84434a.setRequestProperty("Accept-Charset", "utf-8");
                    }
                    this.f84434a.setDoOutput(true);
                    this.f84434a.setDoInput(true);
                    if (this.f != null) {
                        if (!this.f84436c.containsKey("Content-Type")) {
                            this.f84434a.setRequestProperty("Content-Type", com.tencent.luggage.wxa.rt.a.f24957a);
                        }
                        HttpURLConnection httpURLConnection = this.f84434a;
                        StringBuilder sb = new StringBuilder();
                        sb.append(this.f.length);
                        httpURLConnection.setRequestProperty("Content-length", sb.toString());
                        long currentTimeMillis = System.currentTimeMillis();
                        OutputStream outputStream = this.f84434a.getOutputStream();
                        long currentTimeMillis2 = System.currentTimeMillis() - currentTimeMillis;
                        if (currentTimeMillis2 > 0 && currentTimeMillis2 < DateUtils.ONE_MINUTE && A.size() <= 4) {
                            synchronized (A) {
                                A.add(new Pair<>(Integer.valueOf(jk.j), Long.valueOf(currentTimeMillis2)));
                                if (4 == A.size()) {
                                    StringBuilder sb2 = new StringBuilder();
                                    for (int i3 = 0; i3 < A.size(); i3++) {
                                        Pair<Integer, Long> pair = A.get(i3);
                                        if (pair != null) {
                                            sb2.append(pair.first);
                                            sb2.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
                                            sb2.append(pair.second);
                                            if (A.size() - 1 != i3) {
                                                sb2.append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
                                            }
                                        }
                                    }
                                    z = sb2.toString();
                                    new kb(context, "wup").a().edit().putString("cn_t_a", z).commit();
                                }
                            }
                        }
                        outputStream.write(this.f);
                        outputStream.flush();
                        outputStream.close();
                    }
                }
                this.f84435b = this.f84434a.getResponseCode();
                if (this.f84435b >= 301 && this.f84435b <= 305) {
                    byte b2 = this.i;
                    this.i = (byte) (b2 + 1);
                    if (b2 < 3) {
                        this.f84437d = e();
                        return c(context);
                    }
                } else if (this.f84435b == 200) {
                    String d2 = d();
                    if (this.g && d2 != null && d2.toLowerCase().indexOf("vnd.wap.wml") != -1) {
                        byte b3 = this.j;
                        this.j = (byte) (b3 + 1);
                        if (b3 <= 0) {
                            return c(context);
                        }
                    }
                }
                int i4 = this.f84435b;
                if (i4 == 206 || i4 == 200) {
                    return this.f84435b;
                }
                byte b4 = this.k;
                this.k = (byte) (b4 + 1);
                if (b4 < 2) {
                    if (i2 == -1 && IOpenJsApis.TRUE.equals(System.getProperty("http.keepAlive"))) {
                        System.setProperty("http.keepAlive", "false");
                    }
                    return c(context);
                }
                throw new kk(i2 + i4, "response code is unnormal: " + this.f84435b + " SDK Version:" + Build.VERSION.SDK_INT);
            } catch (IllegalStateException e10) {
                e = e10;
                byte b5 = this.k;
                this.k = (byte) (b5 + 1);
                if (b5 < 2) {
                    return c(context);
                }
                throw new kk(i - 61, "sendRequest IllegalStateException: " + e.getMessage());
            } catch (ProtocolException e11) {
                e = e11;
                byte b6 = this.k;
                this.k = (byte) (b6 + 1);
                if (b6 < 2) {
                    return c(context);
                }
                throw new kk(i - 51, "sendRequest ProtocolException: " + e.getMessage());
            } catch (SocketException e12) {
                e = e12;
                byte b7 = this.k;
                this.k = (byte) (b7 + 1);
                if (b7 < 2) {
                    return c(context);
                }
                throw new kk(i - 54, "sendRequest SocketException: " + e.getMessage());
            } catch (SocketTimeoutException e13) {
                e = e13;
                byte b8 = this.k;
                this.k = (byte) (b8 + 1);
                if (b8 < 2) {
                    this.l = Task.MAX_TRYING_TIME;
                    this.m = Task.MAX_TRYING_TIME;
                    return c(context);
                }
                throw new kk(i - 55, "sendRequest" + e.getMessage());
            } catch (UnknownHostException e14) {
                e = e14;
                byte b9 = this.k;
                this.k = (byte) (b9 + 1);
                if (b9 < 2) {
                    f();
                    return c(context);
                }
                if (this.h) {
                    this.h = false;
                    b();
                    if (this.g) {
                        a(context, this.f84437d, 4);
                    } else if (2 == kc.a(context)) {
                        String d3 = kc.d(context);
                        if (d3 == null || d3.length() <= 0 || kc.e(context) <= 0) {
                            throw new kk(i - 62, "sendRequest UnknownHostException: " + e.getMessage() + " networktype:" + kc.a(context));
                        }
                        a(context, this.f84437d, 3);
                    }
                    if (this.f84434a != null) {
                        b(this.e);
                        if ("POST".equalsIgnoreCase(this.e) && (bArr = this.f) != null) {
                            this.f = bArr;
                        }
                        a(this.f84436c);
                    }
                }
                throw new kk(i - 62, "sendRequest UnknownHostException: " + e.getMessage() + " networktype:" + kc.a(context));
            } catch (kk e15) {
                e = e15;
                byte b10 = this.k;
                this.k = (byte) (b10 + 1);
                if (b10 < 2) {
                    return c(context);
                }
                throw new kk(i - 56, "sendRequest NetWorkException: " + e.getMessage());
            } catch (Exception e16) {
                e = e16;
                byte b11 = this.k;
                this.k = (byte) (b11 + 1);
                if (b11 < 2) {
                    return c(context);
                }
                throw new kk(i, "sendRequest " + e.getClass().getName() + " : " + e.getMessage());
            } catch (IllegalAccessError e17) {
                e = e17;
                byte b12 = this.k;
                this.k = (byte) (b12 + 1);
                if (b12 < 2) {
                    return c(context);
                }
                throw new kk(i - 60, "sendRequest IllegalAccessError: " + e.getMessage());
            }
        }
        throw new kk(-1000, "sendRequest() is forbidden couldNotConnect");
    }

    public final InputStream a() {
        try {
            return this.f84434a.getInputStream();
        } catch (Exception e) {
            throw new kk(-56, "get inputStream: " + e.getMessage());
        }
    }

    public final String a(String str) {
        try {
            return this.f84434a.getHeaderField(str);
        } catch (Exception e) {
            throw new kk(-56, "get header field: " + e.getMessage());
        }
    }

    public final void b() {
        HttpURLConnection httpURLConnection = this.f84434a;
        if (httpURLConnection != null) {
            httpURLConnection.disconnect();
            this.f84434a = null;
        }
    }
}