APKPure.apk分析 / c.java


package e.g.a.c.l;

import android.text.TextUtils;
import com.tencent.beacon.base.net.adapter.AbstractNetAdapter;
import e.g.a.i0.q0;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import o.d;
import o.e;
import o.s.c.j;
import o.s.c.k;
import o.y.g;
import o.y.l;
import org.json.JSONObject;
import org.jsoup.helper.HttpConnection;

public final class c {

    /* renamed from: a  reason: collision with root package name */
    public static final c f4986a = null;
    public static final d<c> b = i.i.g.c.U(e.SYNCHRONIZED, a.b);

    public static final class a extends k implements o.s.b.a<c> {
        public static final a b = new a();

        public a() {
            super(0);
        }

        /* Return type fixed from 'java.lang.Object' to match base method */
        @Override // o.s.b.a
        public c b() {
            return new c();
        }
    }

    public static final c d() {
        return b.getValue();
    }

    public final void a(HttpURLConnection httpURLConnection) {
        try {
            httpURLConnection.disconnect();
        } catch (Throwable th) {
            q0.a("OfferRequestMock", j.k("Disconnect HttpConnection Exception : ", th));
        }
    }

    public final HttpURLConnection b(String str, List<String> list, Map<String, String> map, boolean z) {
        URLConnection openConnection = new URL(str).openConnection();
        Objects.requireNonNull(openConnection, "null cannot be cast to non-null type java.net.HttpURLConnection");
        HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
        httpURLConnection.setInstanceFollowRedirects(z);
        httpURLConnection.setRequestMethod("GET");
        httpURLConnection.setConnectTimeout(AbstractNetAdapter.READ_TIMEOUT);
        if (list != null) {
            for (String str2 : list) {
                List C = l.C(str2, new String[]{";"}, false, 0, 6);
                if (!C.isEmpty()) {
                    httpURLConnection.addRequestProperty("Cookie", (String) C.get(0));
                }
            }
        }
        httpURLConnection.setRequestProperty("Accept-Encoding", "gzip,deflate");
        if (map != null) {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
            }
        }
        return httpURLConnection;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:14:0x0053, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:0x0054, code lost:
        k.g.c.u(r2, r7);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:16:0x0057, code lost:
        throw r0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:29:0x0088, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:30:0x0089, code lost:
        k.g.c.u(r1, r7);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:31:0x008d, code lost:
        throw r0;
     */
    public final String c(HttpURLConnection httpURLConnection) throws IOException {
        StringBuilder sb = new StringBuilder();
        if (httpURLConnection.getHeaderField(HttpConnection.CONTENT_ENCODING) == null || !j.a(httpURLConnection.getHeaderField(HttpConnection.CONTENT_ENCODING), "gzip")) {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
            for (String str : k.g.c.U(bufferedReader)) {
                sb.append(str);
            }
            k.g.c.u(bufferedReader, null);
        } else {
            GZIPInputStream gZIPInputStream = new GZIPInputStream(httpURLConnection.getInputStream());
            InputStreamReader inputStreamReader = new InputStreamReader(gZIPInputStream, "GB2312");
            BufferedReader bufferedReader2 = new BufferedReader(inputStreamReader);
            for (String str2 : k.g.c.U(bufferedReader2)) {
                sb.append(str2);
            }
            k.g.c.u(bufferedReader2, null);
            inputStreamReader.close();
            gZIPInputStream.close();
        }
        return sb.toString();
    }

    public final void e(Exception exc) {
        q0.a("OfferRequestMock", j.k(exc instanceof MalformedURLException ? "MalformedURLException : " : exc instanceof IOException ? "IOException : " : "Exception : ", exc));
        exc.printStackTrace();
    }

    public final boolean f(String str) {
        j.e(str, "location");
        return l.E(str, "market://", false, 2) || (l.E(str, "https://play.google.com/", false, 2) && l.b(str, "referrer=", false, 2));
    }

    public final boolean g(String str) {
        j.e(str, "location");
        return l.E(str, "market://", false, 2) || l.E(str, "https://play.google.com/", false, 2) || l.E(str, "http://play.google.com", false, 2);
    }

    public final boolean h(int i2) {
        return i2 == 301 || i2 == 302 || i2 == 303;
    }

    public final String i(String str) {
        if (TextUtils.isEmpty(str) || !l.b(str, "requestId", false, 2)) {
            return "";
        }
        try {
            String string = new JSONObject(new g("null").d(str, "")).getString("requestId");
            j.d(string, "jsonObject.getString(KEY_REQUEST_ID)");
            return string;
        } catch (Exception e2) {
            e2.printStackTrace();
            return "";
        }
    }

    public final String j(String str) {
        String d = new g(" ").d(str, "");
        ArrayList arrayList = new ArrayList();
        arrayList.add("location*=*['|\"](http[^'|^\"]*)");
        arrayList.add("location[=|\\\\.replace\\\\(|\\\\.herf=|\\\\.assign\\\\(]*[\\'|\"](http[^\\'\"]*)");
        arrayList.add("<[meta|META]*http-equiv=[\\\"|\\'].*[URL|url]*=[\\'|\\\"]?(http[^\\'|^\\\"]*)");
        int size = arrayList.size();
        int i2 = 0;
        while (i2 < size) {
            int i3 = i2 + 1;
            Object obj = arrayList.get(i2);
            j.d(obj, "regularList[i]");
            Matcher matcher = Pattern.compile((String) obj).matcher(d);
            if (matcher.find()) {
                try {
                    q0.a("OfferRequestMock", j.k("Found value : ", matcher.group(1)));
                    return matcher.group(1);
                } catch (Exception e2) {
                    q0.a("OfferRequestMock", j.k("Can't parser content, Exception:", e2));
                    e2.printStackTrace();
                }
            } else {
                i2 = i3;
            }
        }
        return null;
    }

    public final String k(String str) {
        Matcher matcher = Pattern.compile("market://details\\?id=[^'|^\"]").matcher(new g(" ").d(str, ""));
        if (matcher.find()) {
            try {
                q0.a("OfferRequestMock", j.k("Found value : ", matcher.group(0)));
                return matcher.group(0);
            } catch (Exception e2) {
                q0.a("OfferRequestMock", j.k("Can't parser content, Exception:", e2));
                e2.printStackTrace();
            }
        }
        return null;
    }
}