酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319

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


package com.alipay.android.a.a.a;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.text.TextUtils;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import com.huawei.hms.framework.common.ContainerUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.ConnectionPoolTimeoutException;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.cookie.Cookie;
import org.apache.http.entity.AbstractHttpEntity;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.mime.MIME;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import sdk.SdkMark;
import tmsdk.common.gourd.vine.IActionReportService;

@SdkMark(code = 54)
public final class w implements Callable<ab> {

    private static final HttpRequestRetryHandler f786e;

    protected r f787a;

    protected Context f788b;

    protected u f789c;

    String f790d;
    private HttpUriRequest f;
    private CookieManager i;
    private AbstractHttpEntity j;
    private HttpHost k;
    private URL l;
    private String q;
    private HttpContext g = new BasicHttpContext();
    private CookieStore h = new BasicCookieStore();
    private int m = 0;
    private boolean n = false;
    private boolean o = false;
    private String p = null;

    static {
        e.d.a();
        f786e = new e();
    }

    public w(r rVar, u uVar) {
        this.f787a = rVar;
        this.f788b = this.f787a.f772a;
        this.f789c = uVar;
    }

    private static long a(String[] strArr) {
        for (int i = 0; i < strArr.length; i++) {
            if ("max-age".equalsIgnoreCase(strArr[i])) {
                int i2 = i + 1;
                if (strArr[i2] != null) {
                    try {
                        return Long.parseLong(strArr[i2]);
                    } catch (Exception unused) {
                        continue;
                    }
                } else {
                    continue;
                }
            }
        }
        return 0L;
    }

    private ab a(HttpResponse httpResponse, int i, String str) {
        ByteArrayOutputStream byteArrayOutputStream;
        String str2;
        new StringBuilder("开始handle,handleResponse-1,").append(Thread.currentThread().getId());
        HttpEntity entity = httpResponse.getEntity();
        String str3 = null;
        if (entity == null || httpResponse.getStatusLine().getStatusCode() != 200) {
            if (entity != null) {
                return null;
            }
            httpResponse.getStatusLine().getStatusCode();
            return null;
        }
        new StringBuilder("200,开始处理,handleResponse-2,threadid = ").append(Thread.currentThread().getId());
        try {
            byteArrayOutputStream = new ByteArrayOutputStream();
            try {
                long currentTimeMillis = System.currentTimeMillis();
                a(entity, byteArrayOutputStream);
                byte[] byteArray = byteArrayOutputStream.toByteArray();
                this.o = false;
                this.f787a.c(System.currentTimeMillis() - currentTimeMillis);
                this.f787a.a(byteArray.length);
                new StringBuilder("res:").append(byteArray.length);
                v vVar = new v(a(httpResponse), i, str, byteArray);
                long b2 = b(httpResponse);
                Header contentType = httpResponse.getEntity().getContentType();
                if (contentType != null) {
                    HashMap<String, String> a2 = a(contentType.getValue());
                    str3 = a2.get("charset");
                    str2 = a2.get(MIME.CONTENT_TYPE);
                } else {
                    str2 = null;
                }
                vVar.b(str2);
                vVar.a(str3);
                vVar.a(System.currentTimeMillis());
                vVar.b(b2);
                try {
                    byteArrayOutputStream.close();
                    return vVar;
                } catch (IOException e2) {
                    throw new RuntimeException("ArrayOutputStream close error!", e2.getCause());
                }
            } catch (Throwable th) {
                th = th;
                if (byteArrayOutputStream != null) {
                    try {
                        byteArrayOutputStream.close();
                    } catch (IOException e3) {
                        throw new RuntimeException("ArrayOutputStream close error!", e3.getCause());
                    }
                }
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
            byteArrayOutputStream = null;
        }
    }

    private static p a(HttpResponse httpResponse) {
        p pVar = new p();
        for (Header header : httpResponse.getAllHeaders()) {
            pVar.a(header.getName(), header.getValue());
        }
        return pVar;
    }

    private static HashMap<String, String> a(String str) {
        HashMap<String, String> hashMap = new HashMap<>();
        for (String str2 : str.split(IActionReportService.COMMON_SEPARATOR)) {
            String[] split = str2.indexOf(61) == -1 ? new String[]{MIME.CONTENT_TYPE, str2} : str2.split(ContainerUtils.KEY_VALUE_DELIMITER);
            hashMap.put(split[0], split[1]);
        }
        return hashMap;
    }

    private void a(HttpEntity httpEntity, OutputStream outputStream) {
        InputStream a2 = f.a(httpEntity);
        long contentLength = httpEntity.getContentLength();
        try {
            try {
                byte[] bArr = new byte[2048];
                while (true) {
                    int read = a2.read(bArr);
                    if (read == -1 || this.f789c.h()) {
                        break;
                    }
                    outputStream.write(bArr, 0, read);
                    if (this.f789c.f() != null) {
                        int i = (contentLength > 0L ? 1 : (contentLength == 0L ? 0 : -1));
                    }
                }
                outputStream.flush();
            } catch (Exception e2) {
                e2.getCause();
                throw new IOException("HttpWorker Request Error!" + e2.getLocalizedMessage());
            }
        } finally {
            x.a(a2);
        }
    }

    private static long b(HttpResponse httpResponse) {
        Header firstHeader = httpResponse.getFirstHeader("Cache-Control");
        if (firstHeader != null) {
            String[] split = firstHeader.getValue().split(ContainerUtils.KEY_VALUE_DELIMITER);
            if (split.length >= 2) {
                try {
                    return a(split);
                } catch (NumberFormatException unused) {
                }
            }
        }
        Header firstHeader2 = httpResponse.getFirstHeader("Expires");
        if (firstHeader2 != null) {
            return f.b(firstHeader2.getValue()) - System.currentTimeMillis();
        }
        return 0L;
    }

    private URI b() {
        String a2 = this.f789c.a();
        String str = this.f790d;
        if (str != null) {
            a2 = str;
        }
        if (a2 != null) {
            return new URI(a2);
        }
        throw new RuntimeException("url should not be null");
    }

    private HttpUriRequest c() {
        HttpUriRequest httpUriRequest = this.f;
        if (httpUriRequest != null) {
            return httpUriRequest;
        }
        if (this.j == null) {
            byte[] b2 = this.f789c.b();
            String b3 = this.f789c.b("gzip");
            if (b2 != null) {
                if (TextUtils.equals(b3, "true")) {
                    this.j = f.a(b2);
                } else {
                    this.j = new ByteArrayEntity(b2);
                }
                this.j.setContentType(this.f789c.c());
            }
        }
        AbstractHttpEntity abstractHttpEntity = this.j;
        if (abstractHttpEntity != null) {
            HttpPost httpPost = new HttpPost(b());
            httpPost.setEntity(abstractHttpEntity);
            this.f = httpPost;
        } else {
            this.f = new HttpGet(b());
        }
        return this.f;
    }

    @Override
    public ab call() {
        boolean z;
        HttpHost httpHost;
        List<Cookie> cookies;
        int statusCode;
        ab a2;
        String a3;
        while (true) {
            try {
                try {
                    NetworkInfo[] allNetworkInfo = ((ConnectivityManager) this.f788b.getSystemService("connectivity")).getAllNetworkInfo();
                    boolean z2 = true;
                    if (allNetworkInfo != null) {
                        for (NetworkInfo networkInfo : allNetworkInfo) {
                            if (networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnectedOrConnecting()) {
                                z = true;
                                break;
                            }
                        }
                    }
                    z = false;
                    if (!z) {
                        throw new l(1, "The network is not available");
                    }
                    ArrayList<Header> d2 = this.f789c.d();
                    if (d2 != null && !d2.isEmpty()) {
                        Iterator<Header> it = d2.iterator();
                        while (it.hasNext()) {
                            c().addHeader(it.next());
                        }
                    }
                    f.a((HttpRequest) c());
                    f.b((HttpRequest) c());
                    c().addHeader("cookie", i().getCookie(this.f789c.a()));
                    this.g.setAttribute("http.cookie-store", this.h);
                    this.f787a.a().a(f786e);
                    long currentTimeMillis = System.currentTimeMillis();
                    StringBuilder sb = new StringBuilder("By Http/Https to request. operationType=");
                    sb.append(f());
                    sb.append(" url=");
                    sb.append(this.f.getURI().toString());
                    HttpParams params = this.f787a.a().getParams();
                    NetworkInfo activeNetworkInfo = ((ConnectivityManager) this.f788b.getSystemService("connectivity")).getActiveNetworkInfo();
                    HttpHost httpHost2 = null;
                    if (activeNetworkInfo != null && activeNetworkInfo.isAvailable()) {
                        String defaultHost = Proxy.getDefaultHost();
                        int defaultPort = Proxy.getDefaultPort();
                        if (defaultHost != null) {
                            httpHost = new HttpHost(defaultHost, defaultPort);
                            if (httpHost != null || !TextUtils.equals(httpHost.getHostName(), "127.0.0.1") || httpHost.getPort() != 8087) {
                                httpHost2 = httpHost;
                            }
                            params.setParameter("http.route.default-proxy", httpHost2);
                            if (this.k == null) {
                                URL h = h();
                                this.k = new HttpHost(h.getHost(), g(), h.getProtocol());
                            }
                            HttpHost httpHost3 = this.k;
                            if (g() == 80) {
                                httpHost3 = new HttpHost(h().getHost());
                            }
                            HttpResponse execute = this.f787a.a().execute(httpHost3, this.f, this.g);
                            this.f787a.b(System.currentTimeMillis() - currentTimeMillis);
                            cookies = this.h.getCookies();
                            if (this.f789c.e()) {
                                i().removeAllCookie();
                            }
                            if (!cookies.isEmpty()) {
                                for (Cookie cookie : cookies) {
                                    if (cookie.getDomain() != null) {
                                        StringBuilder sb2 = new StringBuilder();
                                        sb2.append(cookie.getName());
                                        sb2.append(ContainerUtils.KEY_VALUE_DELIMITER);
                                        sb2.append(cookie.getValue());
                                        sb2.append("; domain=");
                                        sb2.append(cookie.getDomain());
                                        sb2.append(cookie.isSecure() ? "; Secure" : "");
                                        i().setCookie(this.f789c.a(), sb2.toString());
                                        CookieSyncManager.getInstance().sync();
                                    }
                                }
                            }
                            statusCode = execute.getStatusLine().getStatusCode();
                            String reasonPhrase = execute.getStatusLine().getReasonPhrase();
                            if (statusCode != 200) {
                                if (statusCode != 304) {
                                    z2 = false;
                                }
                                if (!z2) {
                                    throw new l(Integer.valueOf(execute.getStatusLine().getStatusCode()), execute.getStatusLine().getReasonPhrase());
                                }
                            }
                            a2 = a(execute, statusCode, reasonPhrase);
                            if (((a2 != null || a2.b() == null) ? -1L : a2.b().length) == -1 && (a2 instanceof v)) {
                                try {
                                    Long.parseLong(((v) a2).a().a("Content-Length"));
                                } catch (Exception unused) {
                                }
                            }
                            a3 = this.f789c.a();
                            if (a3 != null && !TextUtils.isEmpty(f())) {
                                StringBuilder sb3 = new StringBuilder();
                                sb3.append(a3);
                                sb3.append("#");
                                sb3.append(f());
                            }
                            return a2;
                        }
                    }
                    httpHost = null;
                    if (httpHost != null) {
                    }
                    httpHost2 = httpHost;
                    params.setParameter("http.route.default-proxy", httpHost2);
                    if (this.k == null) {
                    }
                    HttpHost httpHost32 = this.k;
                    if (g() == 80) {
                    }
                    HttpResponse execute2 = this.f787a.a().execute(httpHost32, this.f, this.g);
                    this.f787a.b(System.currentTimeMillis() - currentTimeMillis);
                    cookies = this.h.getCookies();
                    if (this.f789c.e()) {
                    }
                    if (!cookies.isEmpty()) {
                    }
                    statusCode = execute2.getStatusLine().getStatusCode();
                    String reasonPhrase2 = execute2.getStatusLine().getReasonPhrase();
                    if (statusCode != 200) {
                    }
                    a2 = a(execute2, statusCode, reasonPhrase2);
                    if (((a2 != null || a2.b() == null) ? -1L : a2.b().length) == -1) {
                        Long.parseLong(((v) a2).a().a("Content-Length"));
                    }
                    a3 = this.f789c.a();
                    if (a3 != null) {
                        StringBuilder sb32 = new StringBuilder();
                        sb32.append(a3);
                        sb32.append("#");
                        sb32.append(f());
                    }
                    return a2;
                } catch (Exception e2) {
                    e();
                    if (this.f789c.f() != null) {
                        new StringBuilder().append(e2);
                    }
                    throw new l(0, String.valueOf(e2));
                }
            } catch (l e3) {
                e();
                if (this.f789c.f() != null) {
                    e3.a();
                    e3.b();
                }
                new StringBuilder().append(e3);
                throw e3;
            } catch (NullPointerException e4) {
                e();
                int i = this.m;
                if (i > 0) {
                    new StringBuilder().append(e4);
                    throw new l(0, String.valueOf(e4));
                }
                this.m = i + 1;
            } catch (SocketTimeoutException e5) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e5);
                }
                new StringBuilder().append(e5);
                throw new l(4, String.valueOf(e5));
            } catch (URISyntaxException e6) {
                throw new RuntimeException("Url parser error!", e6.getCause());
            } catch (UnknownHostException e7) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e7);
                }
                new StringBuilder().append(e7);
                throw new l(9, String.valueOf(e7));
            } catch (SSLHandshakeException e8) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e8);
                }
                new StringBuilder().append(e8);
                throw new l(2, String.valueOf(e8));
            } catch (SSLPeerUnverifiedException e9) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e9);
                }
                new StringBuilder().append(e9);
                throw new l(2, String.valueOf(e9));
            } catch (SSLException e10) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e10);
                }
                new StringBuilder().append(e10);
                throw new l(6, String.valueOf(e10));
            } catch (NoHttpResponseException e11) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e11);
                }
                new StringBuilder().append(e11);
                throw new l(5, String.valueOf(e11));
            } catch (ConnectionPoolTimeoutException e12) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e12);
                }
                new StringBuilder().append(e12);
                throw new l(3, String.valueOf(e12));
            } catch (ConnectTimeoutException e13) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e13);
                }
                new StringBuilder().append(e13);
                throw new l(3, String.valueOf(e13));
            } catch (HttpHostConnectException e14) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e14);
                }
                throw new l(8, String.valueOf(e14));
            } catch (IOException e15) {
                e();
                if (this.f789c.f() != null) {
                    new StringBuilder().append(e15);
                }
                new StringBuilder().append(e15);
                throw new l(6, String.valueOf(e15));
            }
        }
    }

    private void e() {
        HttpUriRequest httpUriRequest = this.f;
        if (httpUriRequest != null) {
            httpUriRequest.abort();
        }
    }

    private String f() {
        if (!TextUtils.isEmpty(this.q)) {
            return this.q;
        }
        this.q = this.f789c.b("operationType");
        return this.q;
    }

    private int g() {
        URL h = h();
        return h.getPort() == -1 ? h.getDefaultPort() : h.getPort();
    }

    private URL h() {
        URL url = this.l;
        if (url != null) {
            return url;
        }
        this.l = new URL(this.f789c.a());
        return this.l;
    }

    private CookieManager i() {
        CookieManager cookieManager = this.i;
        if (cookieManager != null) {
            return cookieManager;
        }
        this.i = CookieManager.getInstance();
        return this.i;
    }

    public final u a() {
        return this.f789c;
    }
}