APKPure.apk(点击下载) / a.java


package e.g.a.h0.c;

import android.content.Context;
import android.text.TextUtils;
import android.webkit.WebSettings;
import com.apkpure.aegon.R;
import com.apkpure.aegon.app.newcard.model.AppCardData;
import com.apkpure.aegon.application.AegonApplication;
import com.apkpure.aegon.application.RealApplicationLike;
import com.apkpure.crabshell.GlobalConst;
import com.google.android.gms.common.internal.ImagesContract;
import com.j256.ormlite.stmt.query.SimpleComparison;
import com.tencent.beacon.base.net.BResponse;
import e.g.a.c.h;
import e.g.a.c.l.b;
import e.g.a.c.l.c;
import e.g.a.c.l.d;
import e.g.a.e.d.t;
import e.g.a.h0.a.j;
import e.g.a.i0.g0;
import e.g.a.i0.q0;
import e.g.a.i0.u0;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.locks.LockSupport;
import o.p.e;
import o.p.f;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import p.a.c0;
import p.a.h1;
import p.a.l0;
import p.a.p0;
import p.a.s1;
import p.a.u;
import p.a.x0;
import p.a.z;

public class a {

    /* renamed from: a  reason: collision with root package name */
    public static String f6052a = "https://t.apkpure.net/api/tracking?type=android";
    public static boolean b = true;
    public static final Long c = 100L;

    /* renamed from: e.g.a.h0.c.a$a  reason: collision with other inner class name */
    public class RunnableC0105a implements Runnable {
        public final /* synthetic */ String b;
        public final /* synthetic */ String c;
        public final /* synthetic */ Map d;

        /* renamed from: e  reason: collision with root package name */
        public final /* synthetic */ String f6053e;

        /* renamed from: f  reason: collision with root package name */
        public final /* synthetic */ String f6054f;

        /* renamed from: g  reason: collision with root package name */
        public final /* synthetic */ boolean f6055g;

        /* renamed from: h  reason: collision with root package name */
        public final /* synthetic */ String f6056h;

        /* renamed from: i  reason: collision with root package name */
        public final /* synthetic */ HashMap f6057i;

        public RunnableC0105a(String str, String str2, Map map, String str3, String str4, boolean z, String str5, HashMap hashMap) {
            this.b = str;
            this.c = str2;
            this.d = map;
            this.f6053e = str3;
            this.f6054f = str4;
            this.f6055g = z;
            this.f6056h = str5;
            this.f6057i = hashMap;
        }

        /* JADX WARNING: Removed duplicated region for block: B:66:0x031f A[Catch:{ all -> 0x036c }] */
        public void run() {
            HashMap hashMap;
            Object obj;
            Object obj2;
            Throwable th;
            StackTraceElement[] stackTrace;
            BResponse a2;
            String str;
            List<String> list;
            HashMap hashMap2 = new HashMap();
            hashMap2.put("recommend_id", this.b);
            hashMap2.put("package_name", this.c);
            hashMap2.put("module_name", this.d.get("module_name"));
            hashMap2.put("model_type", this.d.get("model_type"));
            hashMap2.put(AppCardData.KEY_SCENE, this.d.get(AppCardData.KEY_SCENE));
            hashMap2.put("sub_event_name", "TrackingStartRequest");
            hashMap2.put("is_ad", this.d.get("is_ad"));
            hashMap2.put("tracking_event", this.f6053e);
            try {
                Context context = RealApplicationLike.getContext();
                boolean l2 = g0.l(context);
                boolean j2 = g0.j(context);
                boolean k2 = g0.k(context);
                StringBuilder sb = new StringBuilder();
                try {
                    sb.append(a.f6052a);
                    sb.append("&");
                    sb.append("event_code");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(this.f6053e);
                    sb.append("&");
                    sb.append("gaid");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(h.b());
                    sb.append("&");
                    sb.append("download_id");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(this.f6054f);
                    sb.append("&");
                    sb.append("oaid");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(j.a().b());
                    sb.append("&");
                    sb.append("pkgname");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(this.c);
                    sb.append("&");
                    sb.append("android_id");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(h.a());
                    sb.append("&");
                    sb.append("is_install_vending");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                } catch (Throwable th2) {
                    th = th2;
                    obj2 = "return_code";
                    obj = "TrackingFinish";
                    try {
                        th.printStackTrace();
                        hashMap2.put(obj2, th.getMessage());
                        hashMap2.put("sub_event_name", "TrackingRequestResult");
                        stackTrace = th.getStackTrace();
                        if (stackTrace.length > 0) {
                            int length = stackTrace.length;
                            int i2 = 0;
                            while (true) {
                                if (i2 >= length) {
                                    break;
                                }
                                StackTraceElement stackTraceElement = stackTrace[i2];
                                if (a.class.getName().equals(stackTraceElement.getClassName())) {
                                    hashMap2.put("return_content", stackTraceElement.toString());
                                    break;
                                }
                                i2++;
                            }
                        }
                        e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                        q0.a("TrackingReportApi", "res crash:" + th.getMessage());
                        hashMap2.put("sub_event_name", obj);
                        hashMap = new HashMap(hashMap2);
                        e.g.a.h0.b.h.p("OfferRedirectSucceed", hashMap);
                    } catch (Throwable th3) {
                        hashMap2.put("sub_event_name", obj);
                        e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                        throw th3;
                    }
                }
                try {
                    sb.append(l2 ? "1" : "0");
                    sb.append("&");
                    sb.append("is_install_gms");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(j2 ? "1" : "0");
                    sb.append("&");
                    sb.append("is_install_gsf");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(k2 ? "1" : "0");
                    sb.append("&");
                    sb.append("version_code");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(GlobalConst.VERSIONCODE);
                    sb.append("&");
                    sb.append("is_update_task");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(this.f6055g ? 1 : 0);
                    sb.append("&");
                    sb.append("recommend_id");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(this.f6056h);
                    sb.append("&");
                    sb.append("use_vpn");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    String str2 = u0.f6569a;
                    sb.append(u0.n(RealApplicationLike.getContext()) ? "1" : "0");
                    sb.append("&");
                    sb.append("ext_info");
                    sb.append(SimpleComparison.EQUAL_TO_OPERATION);
                    sb.append(URLEncoder.encode(a.a(this.d)));
                    String sb2 = sb.toString();
                    q0.a("TrackingReportApi", "start reportEvent:" + sb2);
                    hashMap2.put(ImagesContract.URL, sb2);
                    e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                    String str3 = null;
                    a2 = e.g.a.h0.a.h.a(sb2, "GET", this.f6057i, null, false);
                    str = new String(a2.body, StandardCharsets.UTF_8);
                    q0.a("TrackingReportApi", "res:" + a2.code + ", content=" + str);
                    StringBuilder sb3 = new StringBuilder();
                    sb3.append(a2.code);
                    sb3.append("_");
                    sb3.append(str);
                    hashMap2.put("return_content", sb3.toString());
                    Map<String, List<String>> map = a2.headers;
                    Iterator<String> it = map.keySet().iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            list = null;
                            break;
                        }
                        String next = it.next();
                        if ("location".equalsIgnoreCase(next)) {
                            list = map.get(next);
                            break;
                        }
                    }
                    if (list != null) {
                        if (!list.isEmpty()) {
                            str3 = list.get(0);
                        }
                    }
                    c cVar = c.f4986a;
                    if (c.d().h(a2.code) && str3 != null) {
                        b bVar = b.f4985a;
                        if (b.b().d(this.c)) {
                            hashMap2.put("need_redirect", "1");
                            hashMap2.put("sub_event_name", "TrackingRequestResult");
                            e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                            e.g.a.c.l.a aVar = new e.g.a.c.l.a();
                            aVar.f4984a = this.c;
                            aVar.b = str3;
                            aVar.c = this.f6054f;
                            HashMap hashMap3 = new HashMap(hashMap2);
                            hashMap3.put("sub_event_name", "TrackingRedirect");
                            o.s.c.j.e(hashMap3, "map");
                            aVar.d = hashMap3;
                            b b2 = b.b();
                            int i3 = AegonApplication.f1165e;
                            b2.a(RealApplicationLike.getContext(), aVar, this.f6057i);
                            hashMap2.put("sub_event_name", "TrackingFinish");
                            hashMap = new HashMap(hashMap2);
                            e.g.a.h0.b.h.p("OfferRedirectSucceed", hashMap);
                        }
                    }
                    hashMap2.put("need_redirect", "0");
                    hashMap2.put("redirect_location", str3);
                    obj2 = "return_code";
                } catch (Throwable th4) {
                    th = th4;
                    obj = "TrackingFinish";
                    obj2 = "return_code";
                    th.printStackTrace();
                    hashMap2.put(obj2, th.getMessage());
                    hashMap2.put("sub_event_name", "TrackingRequestResult");
                    stackTrace = th.getStackTrace();
                    if (stackTrace.length > 0) {
                    }
                    e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                    q0.a("TrackingReportApi", "res crash:" + th.getMessage());
                    hashMap2.put("sub_event_name", obj);
                    hashMap = new HashMap(hashMap2);
                    e.g.a.h0.b.h.p("OfferRedirectSucceed", hashMap);
                }
                try {
                    hashMap2.put(obj2, Integer.valueOf(a2.code));
                    hashMap2.put("sub_event_name", "TrackingRequestResult");
                    e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                    try {
                        hashMap2.put(obj2, i.i.d.c.O(a.b(str, hashMap2), ':', '|'));
                    } catch (Throwable th5) {
                        hashMap2.put(obj2, th5.getMessage());
                        q0.a("TrackingReportApi", "getUrlListAndReport--urlList error:" + th5.getMessage());
                    }
                    hashMap2.put("sub_event_name", "TrackingThirdRequestResult");
                    e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                    hashMap2.put("sub_event_name", "TrackingFinish");
                    hashMap = new HashMap(hashMap2);
                } catch (Throwable th6) {
                    th = th6;
                    obj = "TrackingFinish";
                    th.printStackTrace();
                    hashMap2.put(obj2, th.getMessage());
                    hashMap2.put("sub_event_name", "TrackingRequestResult");
                    stackTrace = th.getStackTrace();
                    if (stackTrace.length > 0) {
                    }
                    e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                    q0.a("TrackingReportApi", "res crash:" + th.getMessage());
                    hashMap2.put("sub_event_name", obj);
                    hashMap = new HashMap(hashMap2);
                    e.g.a.h0.b.h.p("OfferRedirectSucceed", hashMap);
                }
            } catch (Throwable th7) {
                th = th7;
                obj = "TrackingFinish";
                obj2 = "return_code";
                th.printStackTrace();
                hashMap2.put(obj2, th.getMessage());
                hashMap2.put("sub_event_name", "TrackingRequestResult");
                stackTrace = th.getStackTrace();
                if (stackTrace.length > 0) {
                }
                e.g.a.h0.b.h.p("OfferRedirectSucceed", new HashMap(hashMap2));
                q0.a("TrackingReportApi", "res crash:" + th.getMessage());
                hashMap2.put("sub_event_name", obj);
                hashMap = new HashMap(hashMap2);
                e.g.a.h0.b.h.p("OfferRedirectSucceed", hashMap);
            }
            e.g.a.h0.b.h.p("OfferRedirectSucceed", hashMap);
        }
    }

    static {
        f();
        b bVar = b.f4985a;
        b.b().e();
    }

    public static String a(Map map) {
        if (map == null) {
            return "";
        }
        HashMap hashMap = new HashMap();
        if (map.containsKey("model_type")) {
            hashMap.put("model_type", map.get("model_type"));
        }
        if (map.containsKey("position")) {
            hashMap.put("position", map.get("position"));
        }
        if (map.containsKey("small_position")) {
            hashMap.put("small_position", map.get("small_position"));
        }
        if (map.containsKey(AppCardData.KEY_SCENE)) {
            hashMap.put(AppCardData.KEY_SCENE, map.get(AppCardData.KEY_SCENE));
        }
        if (map.containsKey("module_name")) {
            hashMap.put("module_name", map.get("module_name"));
        }
        return e.g.a.r.c.a.g(e.g.a.r.c.a.a(), hashMap);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:16:0x00b0, code lost:
        if (r1.get(r6) == null) goto L_0x00b2;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:9:0x0092, code lost:
        if (r1.get(r6) == null) goto L_0x00b2;
     */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x00c5  */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x00c6  */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x00d1 A[Catch:{ all -> 0x0117 }] */
    public static HashMap<String, String> b(String str, Map<String, Object> map) throws JSONException, IOException {
        p0 p0Var;
        p0 p0Var2;
        z zVar;
        JSONObject jSONObject = new JSONObject(str);
        String optString = jSONObject.optString("requestId");
        JSONArray optJSONArray = jSONObject.optJSONArray("urlList");
        if (optJSONArray == null) {
            return e.d.a.a.a.i0("", "urlEmpty");
        }
        q0.a("TrackingReportApi", "getUrlListAndReport--requestId:" + optString);
        q0.a("TrackingReportApi", "getUrlListAndReport--urlList length:" + optJSONArray.length() + ", " + optJSONArray);
        c cVar = c.f4986a;
        c d = c.d();
        Objects.requireNonNull(d);
        o.s.c.j.e(optJSONArray, "urls");
        o.s.c.j.e(map, "reportParams");
        f fVar = l0.b;
        u uVar = null;
        d dVar = new d(optJSONArray, d, map, null);
        e.a aVar = e.a.b;
        Thread currentThread = Thread.currentThread();
        e eVar = (e) fVar.get(aVar);
        if (eVar == null) {
            s1 s1Var = s1.f16478a;
            p0Var = s1.a();
            fVar = fVar.plus(p0Var);
            o.s.c.j.e(fVar, "context");
            zVar = l0.f16468a;
            if (fVar != zVar) {
            }
            p.a.f fVar2 = new p.a.f(fVar, currentThread, p0Var);
            fVar2.d0(c0.DEFAULT, fVar2, dVar);
            p0Var2 = fVar2.f16448f;
            if (p0Var2 != null) {
                int i2 = p0.f16471f;
                p0Var2.D(false);
            }
            while (!Thread.interrupted()) {
                try {
                    p0 p0Var3 = fVar2.f16448f;
                    long H = p0Var3 == null ? Long.MAX_VALUE : p0Var3.H();
                    if (!(fVar2.J() instanceof x0)) {
                        p0 p0Var4 = fVar2.f16448f;
                        if (p0Var4 != null) {
                            int i3 = p0.f16471f;
                            p0Var4.z(false);
                        }
                        Object a2 = h1.a(fVar2.J());
                        if (a2 instanceof u) {
                            uVar = (u) a2;
                        }
                        if (uVar == null) {
                            return (HashMap) a2;
                        }
                        throw uVar.f16480a;
                    }
                    LockSupport.parkNanos(fVar2, H);
                } catch (Throwable th) {
                    p0 p0Var5 = fVar2.f16448f;
                    if (p0Var5 != null) {
                        int i4 = p0.f16471f;
                        p0Var5.z(false);
                    }
                    throw th;
                }
            }
            InterruptedException interruptedException = new InterruptedException();
            fVar2.n(interruptedException);
            throw interruptedException;
        }
        if (eVar instanceof p0) {
            p0 p0Var6 = (p0) eVar;
        }
        s1 s1Var2 = s1.f16478a;
        p0Var = s1.b.get();
        o.s.c.j.e(fVar, "context");
        zVar = l0.f16468a;
        if (fVar != zVar) {
        }
        p.a.f fVar22 = new p.a.f(fVar, currentThread, p0Var);
        fVar22.d0(c0.DEFAULT, fVar22, dVar);
        p0Var2 = fVar22.f16448f;
        if (p0Var2 != null) {
        }
        while (!Thread.interrupted()) {
        }
        InterruptedException interruptedException2 = new InterruptedException();
        fVar22.n(interruptedException2);
        throw interruptedException2;
        fVar = fVar.plus(zVar);
        p.a.f fVar222 = new p.a.f(fVar, currentThread, p0Var);
        fVar222.d0(c0.DEFAULT, fVar222, dVar);
        p0Var2 = fVar222.f16448f;
        if (p0Var2 != null) {
        }
        while (!Thread.interrupted()) {
        }
        InterruptedException interruptedException22 = new InterruptedException();
        fVar222.n(interruptedException22);
        throw interruptedException22;
    }

    public static void c(String str, Map<String, Object> map) {
        String str2;
        if (!map.isEmpty()) {
            StringBuilder Z = e.d.a.a.a.Z("reportEvent needReport:");
            Z.append(b);
            q0.a("TrackingReportApi", Z.toString());
            if (b) {
                String valueOf = String.valueOf(map.get("apk_download_id"));
                String valueOf2 = String.valueOf(map.get("package_name"));
                String valueOf3 = String.valueOf(map.get("recommend_id"));
                Object obj = map.get("is_update_task");
                boolean z = (obj instanceof Boolean) && ((Boolean) obj).booleanValue();
                try {
                    str2 = URLEncoder.encode(valueOf3, StandardCharsets.UTF_8.name());
                } catch (UnsupportedEncodingException unused) {
                    str2 = "";
                }
                HashMap hashMap = new HashMap();
                try {
                    hashMap.put("Accept-Language", e.g.a.z.d.c().toString() + ";q=0.9");
                    int i2 = AegonApplication.f1165e;
                    hashMap.put("User-Agent", WebSettings.getDefaultUserAgent(RealApplicationLike.getContext()));
                } catch (Throwable th) {
                    th.printStackTrace();
                }
                t O = i.i.g.c.O();
                RunnableC0105a aVar = new RunnableC0105a(valueOf3, valueOf2, map, str, valueOf, z, str2, hashMap);
                int i3 = AegonApplication.f1165e;
                RealApplicationLike.getApplication().getString(R.string.arg_RES_2131821860);
                O.a(aVar);
            }
        }
    }

    public static void d(Map<String, Object> map, boolean z) {
        if (!map.isEmpty()) {
            map.put("is_update_task", Boolean.valueOf(z));
            c("halfDownload", map);
        }
    }

    public static void e(Map<String, Object> map, boolean z) {
        if (map != null && !map.isEmpty()) {
            map.put("is_update_task", Boolean.valueOf(z));
            c("startDownload", map);
        }
    }

    public static void f() {
        b = e.g.a.h0.b.j.c("downloadLogReportSample", c.longValue(), e.g.a.h0.a.h.d.longValue());
        HashMap hashMap = new HashMap();
        hashMap.put("return_code", b ? "1" : "0");
        e.g.a.d0.a.f(13, "TrackingNeedReport", hashMap);
        int i2 = AegonApplication.f1165e;
        String F = i.i.g.c.F(RealApplicationLike.getContext(), "downloadLogReportHost");
        if (!TextUtils.isEmpty(F)) {
            f6052a = F;
        }
    }
}