i伊藤.apk(点击下载) / hf.java


package com.amap.api.col.p0003s;

import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.SystemClock;
import android.text.TextUtils;
import com.alipay.sdk.m.u.i;
import com.amap.api.col.p0003s.jn;
import com.amap.api.col.p0003s.jq;
import com.amap.api.maps.AMapException;
import com.heytap.mcssdk.constant.Constants;
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.el.parse.Operators;
import io.dcloud.common.adapter.util.Logger;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.json.JSONException;
import org.json.JSONObject;

/* renamed from: com.amap.api.col.3s.hf  reason: invalid package */
/* compiled from: AuthConfigManager */
public final class hf {
    private static ConcurrentHashMap<String, Boolean> A = new ConcurrentHashMap<>();
    private static ArrayList<jn.a> B = new ArrayList<>();
    private static volatile boolean C = false;
    private static Queue<jn.c> D = new LinkedList();

    /* renamed from: a  reason: collision with root package name */
    public static int f3397a = -1;

    /* renamed from: b  reason: collision with root package name */
    public static String f3398b = "";

    /* renamed from: c  reason: collision with root package name */
    public static Context f3399c = null;

    /* renamed from: d  reason: collision with root package name */
    public static volatile boolean f3400d = false;

    /* renamed from: e  reason: collision with root package name */
    public static int f3401e = 5000;

    /* renamed from: f  reason: collision with root package name */
    public static boolean f3402f = true;

    /* renamed from: g  reason: collision with root package name */
    public static boolean f3403g = false;
    public static boolean h = true;
    public static boolean i = false;
    public static boolean j = false;
    private static String k = "6";
    private static String l = "4";
    private static String m = "9";
    private static String n = "8";
    private static volatile boolean o = true;
    private static Vector<e> p = new Vector<>();
    private static Map<String, Integer> q = new HashMap();
    private static String r = null;
    private static long s = 0;
    private static volatile ConcurrentHashMap<String, Long> t = new ConcurrentHashMap<>(8);
    private static volatile ConcurrentHashMap<String, Long> u = new ConcurrentHashMap<>(8);
    private static volatile ConcurrentHashMap<String, d> v = new ConcurrentHashMap<>(8);
    private static boolean w = false;
    private static int x = 3;
    private static int y = 3;
    private static ConcurrentHashMap<String, Boolean> z = new ConcurrentHashMap<>();

    /* renamed from: com.amap.api.col.3s.hf$a */
    /* compiled from: AuthConfigManager */
    public interface a {
        void a(b bVar);
    }

    /* renamed from: com.amap.api.col.3s.hf$b */
    /* compiled from: AuthConfigManager */
    public static class b {
        @Deprecated

        /* renamed from: a  reason: collision with root package name */
        public JSONObject f3408a;
        @Deprecated

        /* renamed from: b  reason: collision with root package name */
        public JSONObject f3409b;

        /* renamed from: c  reason: collision with root package name */
        public String f3410c;

        /* renamed from: d  reason: collision with root package name */
        public int f3411d = -1;

        /* renamed from: e  reason: collision with root package name */
        public long f3412e = 0;

        /* renamed from: f  reason: collision with root package name */
        public JSONObject f3413f;

        /* renamed from: g  reason: collision with root package name */
        public a f3414g;
        public C0054b h;
        private boolean i;

        /* renamed from: com.amap.api.col.3s.hf$b$a */
        /* compiled from: AuthConfigManager */
        public static class a {

            /* renamed from: a  reason: collision with root package name */
            public boolean f3415a;

            /* renamed from: b  reason: collision with root package name */
            public boolean f3416b;

            /* renamed from: c  reason: collision with root package name */
            public JSONObject f3417c;
        }

        /* renamed from: com.amap.api.col.3s.hf$b$b  reason: collision with other inner class name */
        /* compiled from: AuthConfigManager */
        public static class C0054b {

            /* renamed from: a  reason: collision with root package name */
            public boolean f3418a;
        }
    }

    /* access modifiers changed from: package-private */
    /* renamed from: com.amap.api.col.3s.hf$c */
    /* compiled from: AuthConfigManager */
    public static class c extends jk {
        private String h;
        private Map<String, String> i;
        private String j;
        private String k;
        private String l;

        c(Context context, hq hqVar, String str, Map<String, String> map, String str2, String str3, String str4) {
            super(context, hqVar);
            this.h = str;
            this.i = map;
            this.j = str2;
            this.k = str3;
            this.l = str4;
            setHttpProtocol(jq.c.HTTPS);
            setDegradeAbility(jq.a.FIX);
        }

        private static String a(String str, String str2) {
            try {
                return !TextUtils.isEmpty(str2) ? Uri.parse(str).buildUpon().encodedAuthority(str2).build().toString() : str;
            } catch (Throwable unused) {
                return str;
            }
        }

        @Override // com.amap.api.col.p0003s.jk
        public final byte[] c() {
            return null;
        }

        @Override // com.amap.api.col.p0003s.jk
        public final byte[] d() {
            String r = hi.r(((jk) this).f3728a);
            if (!TextUtils.isEmpty(r)) {
                r = hm.b(new StringBuilder(r).reverse().toString());
            }
            HashMap hashMap = new HashMap();
            hashMap.put("authkey", TextUtils.isEmpty(this.h) ? "" : this.h);
            hashMap.put("plattype", WXEnvironment.OS);
            hashMap.put("product", ((jk) this).f3729b.a());
            hashMap.put("version", ((jk) this).f3729b.b());
            hashMap.put("output", "json");
            StringBuilder sb = new StringBuilder();
            sb.append(Build.VERSION.SDK_INT);
            hashMap.put("androidversion", sb.toString());
            hashMap.put("deviceId", r);
            hashMap.put("manufacture", Build.MANUFACTURER);
            Map<String, String> map = this.i;
            if (map != null && !map.isEmpty()) {
                hashMap.putAll(this.i);
            }
            hashMap.put("abitype", hr.a(((jk) this).f3728a));
            hashMap.put("ext", ((jk) this).f3729b.d());
            return hr.a(hr.a(hashMap));
        }

        /* access modifiers changed from: protected */
        @Override // com.amap.api.col.p0003s.jk
        public final String e() {
            return "3.0";
        }

        /* access modifiers changed from: protected */
        @Override // com.amap.api.col.p0003s.jq
        public final String getIPDNSName() {
            if (!TextUtils.isEmpty(this.l)) {
                return this.l;
            }
            return super.getIPDNSName();
        }

        @Override // com.amap.api.col.p0003s.hl, com.amap.api.col.p0003s.jq
        public final String getIPV6URL() {
            return a("https://dualstack-arestapi.amap.com/v3/iasdkauth", this.k);
        }

        @Override // com.amap.api.col.p0003s.jq
        public final Map<String, String> getRequestHead() {
            if (TextUtils.isEmpty(this.l)) {
                return null;
            }
            HashMap hashMap = new HashMap();
            hashMap.put(com.alipay.sdk.m.l.c.f2245f, this.l);
            return hashMap;
        }

        @Override // com.amap.api.col.p0003s.jq
        public final String getURL() {
            return a("https://restsdk.amap.com/v3/iasdkauth", this.j);
        }
    }

    /* access modifiers changed from: private */
    /* renamed from: com.amap.api.col.3s.hf$d */
    /* compiled from: AuthConfigManager */
    public static class d {

        /* renamed from: a  reason: collision with root package name */
        hq f3419a;

        /* renamed from: b  reason: collision with root package name */
        String f3420b;

        /* renamed from: c  reason: collision with root package name */
        a f3421c;

        private d() {
        }

        /* synthetic */ d(byte b2) {
            this();
        }
    }

    /* renamed from: com.amap.api.col.3s.hf$e */
    /* compiled from: AuthConfigManager */
    public static class e {

        /* renamed from: a  reason: collision with root package name */
        private String f3422a;

        /* renamed from: b  reason: collision with root package name */
        private String f3423b;

        /* renamed from: c  reason: collision with root package name */
        private AtomicInteger f3424c;

        public e(String str, String str2, int i) {
            this.f3422a = str;
            this.f3423b = str2;
            this.f3424c = new AtomicInteger(i);
        }

        public final void a(String str) {
            this.f3423b = str;
        }

        public final String b() {
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("a", this.f3422a);
                jSONObject.put("f", this.f3423b);
                jSONObject.put("h", this.f3424c.get());
                return jSONObject.toString();
            } catch (Throwable unused) {
                return "";
            }
        }

        public final int a() {
            AtomicInteger atomicInteger = this.f3424c;
            if (atomicInteger == null) {
                return 0;
            }
            return atomicInteger.get();
        }

        public static e b(String str) {
            if (TextUtils.isEmpty(str)) {
                return null;
            }
            try {
                JSONObject jSONObject = new JSONObject(str);
                return new e(jSONObject.optString("a"), jSONObject.optString("f"), jSONObject.optInt("h"));
            } catch (Throwable unused) {
                return null;
            }
        }
    }

    /* renamed from: com.amap.api.col.3s.hf$f */
    /* compiled from: AuthConfigManager */
    public static class f {

        /* renamed from: a  reason: collision with root package name */
        public static boolean f3425a = true;

        /* renamed from: b  reason: collision with root package name */
        public static boolean f3426b = false;

        /* renamed from: c  reason: collision with root package name */
        public static boolean f3427c = true;

        /* renamed from: d  reason: collision with root package name */
        public static int f3428d = 0;

        /* renamed from: e  reason: collision with root package name */
        public static boolean f3429e = false;

        /* renamed from: f  reason: collision with root package name */
        public static int f3430f;
    }

    public static void a(Context context, String str) {
        he.a(context, str);
    }

    private static b b(Context context, hq hqVar, String str, Map<String, String> map) {
        return a(context, hqVar, str, map, null, null, null);
    }

    private static void c(Context context) {
        if (context != null) {
            f3402f = iy.a(context, "open_common", "a13", true);
            h = iy.a(context, "open_common", "a6", true);
            f3403g = iy.a(context, "open_common", "a7", false);
            f3401e = iy.a(context, "open_common", "a8", 5000);
            x = iy.a(context, "open_common", "a9", 3);
            i = iy.a(context, "open_common", "a10", false);
            y = iy.a(context, "open_common", "a11", 3);
            j = iy.a(context, "open_common", "a12", false);
        }
    }

    public static void d() {
        if (!f3400d) {
            try {
                Context context = f3399c;
                if (context != null) {
                    f3400d = true;
                    hk.a().a(context);
                    b(context);
                    c(context);
                    f.f3425a = iy.a(context, "open_common", "ucf", f.f3425a);
                    f.f3426b = iy.a(context, "open_common", "fsv2", f.f3426b);
                    f.f3427c = iy.a(context, "open_common", "usc", f.f3427c);
                    f.f3428d = iy.a(context, "open_common", "umv", f.f3428d);
                    f.f3429e = iy.a(context, "open_common", "ust", f.f3429e);
                    f.f3430f = iy.a(context, "open_common", "ustv", f.f3430f);
                }
            } catch (Throwable unused) {
            }
        }
    }

    public static boolean e(String str) {
        e a2;
        try {
            if (TextUtils.isEmpty(str) || !i) {
                return false;
            }
            if (!(A.get(str) == null)) {
                return false;
            }
            Context context = f3399c;
            if (context == null || (a2 = a(context, b(str, "a15"), "open_common")) == null || a2.a() < y) {
                return true;
            }
            return false;
        } catch (Throwable unused) {
        }
    }

    public static jn.c f() {
        synchronized (D) {
            jn.c poll = D.poll();
            if (poll != null) {
                return poll;
            }
            return null;
        }
    }

    private static void h() {
        try {
            Context context = f3399c;
            if (context != null) {
                String q2 = hi.q(context);
                if (!TextUtils.isEmpty(r) && !TextUtils.isEmpty(q2) && r.equals(q2) && System.currentTimeMillis() - s < Constants.MILLS_OF_MIN) {
                    return;
                }
                if (!TextUtils.isEmpty(q2)) {
                    r = q2;
                }
            } else if (System.currentTimeMillis() - s < Constants.MILLS_OF_EXCEPTION_TIME) {
                return;
            }
            s = System.currentTimeMillis();
            q.clear();
            Iterator it = Collections.list(NetworkInterface.getNetworkInterfaces()).iterator();
            while (it.hasNext()) {
                NetworkInterface networkInterface = (NetworkInterface) it.next();
                if (!networkInterface.getInterfaceAddresses().isEmpty()) {
                    String displayName = networkInterface.getDisplayName();
                    int i2 = 0;
                    for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses()) {
                        InetAddress address = interfaceAddress.getAddress();
                        if (address instanceof Inet6Address) {
                            if (!a((Inet6Address) address)) {
                                i2 |= 2;
                            }
                        } else if (address instanceof Inet4Address) {
                            Inet4Address inet4Address = (Inet4Address) address;
                            if (!a(inet4Address) && !inet4Address.getHostAddress().startsWith(hr.c("FMTkyLjE2OC40My4"))) {
                                i2 |= 1;
                            }
                        }
                    }
                    if (i2 != 0) {
                        if (displayName != null && displayName.startsWith("wlan")) {
                            q.put("WIFI", Integer.valueOf(i2));
                        } else if (displayName != null && displayName.startsWith("rmnet")) {
                            q.put("MOBILE", Integer.valueOf(i2));
                        }
                    }
                }
            }
        } catch (Throwable th) {
            ii.a(th, "at", "ipstack");
        }
    }

    private static boolean i() {
        Integer num;
        Context context = f3399c;
        if (context == null) {
            return false;
        }
        String q2 = hi.q(context);
        if (!TextUtils.isEmpty(q2) && (num = q.get(q2.toUpperCase())) != null && num.intValue() == 2) {
            return true;
        }
        return false;
    }

    public static boolean a(String str, boolean z2) {
        try {
            if (TextUtils.isEmpty(str)) {
                return z2;
            }
            String[] split = URLDecoder.decode(str).split(Operators.DIV);
            if (split[split.length - 1].charAt(4) % 2 == 1) {
                return true;
            }
            return false;
        } catch (Throwable unused) {
            return z2;
        }
    }

    public static boolean b() {
        Integer num;
        Context context = f3399c;
        if (context == null) {
            return false;
        }
        String q2 = hi.q(context);
        if (!TextUtils.isEmpty(q2) && (num = q.get(q2.toUpperCase())) != null && num.intValue() >= 2) {
            return true;
        }
        return false;
    }

    private static void b(Context context) {
        if (context != null) {
            o = iy.a(context, "open_common", "a2", true);
        }
    }

    public static jn.a e() {
        if (C) {
            return null;
        }
        synchronized (B) {
            if (C) {
                return null;
            }
            Collections.sort(B);
            if (B.size() <= 0) {
                return null;
            }
            jn.a a2 = B.get(0).clone();
            C = true;
            return a2;
        }
    }

    public static synchronized void b(String str, boolean z2) {
        synchronized (hf.class) {
            a(str, z2, (String) null, (String) null, (String) null);
        }
    }

    public static b a(Context context, hq hqVar, String str, Map<String, String> map) {
        return b(context, hqVar, str, map);
    }

    public static synchronized long c(String str) {
        synchronized (hf.class) {
            try {
                if (t == null) {
                    t = new ConcurrentHashMap<>(8);
                }
                if (t.containsKey(str)) {
                    return t.get(str).longValue();
                }
            } catch (Throwable th) {
                ii.a(th, "at", "glcut");
            }
            return 0;
        }
    }

    public static b a(Context context, hq hqVar, String str, String str2, String str3, String str4) {
        return a(context, hqVar, str, null, str2, str3, str4);
    }

    public static synchronized void b(String str) {
        synchronized (hf.class) {
            if (u != null) {
                if (u.containsKey(str)) {
                    u.remove(str);
                }
            }
        }
    }

    public static void a(Context context) {
        if (context != null) {
            f3399c = context.getApplicationContext();
        }
    }

    /* JADX DEBUG: Multi-variable search result rejected for r2v52, resolved type: byte[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v53, resolved type: byte[] */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARNING: Missing exception handler attribute for start block: B:67:0x014d */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x01cb A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:99:0x01cc  */
    private static b a(Context context, hq hqVar, String str, Map<String, String> map, String str2, String str3, String str4) {
        String str5;
        String str6;
        String str7;
        String str8;
        String str9;
        String str10;
        b bVar;
        String str11;
        byte[] bArr;
        jr jrVar;
        String str12;
        String str13;
        byte[] bArr2;
        hd e2;
        String str14;
        Context context2;
        IllegalBlockSizeException e3;
        Context context3;
        Throwable th;
        hd e4;
        byte[] bArr3;
        StringBuilder sb;
        b bVar2 = new b();
        bVar2.f3413f = new JSONObject();
        if (context != null) {
            f3399c = context.getApplicationContext();
        }
        d();
        String str15 = null;
        try {
            a(hqVar);
            new jj();
            boolean isEmpty = TextUtils.isEmpty(str);
            if (!isEmpty) {
                try {
                    sb = new StringBuilder();
                    str14 = str;
                } catch (hd e5) {
                    e4 = e5;
                    str14 = str;
                    str6 = "infocode";
                    str5 = "info";
                    str8 = "result";
                    str7 = "ver";
                    bVar = bVar2;
                    str10 = "at";
                    str11 = "lc";
                    try {
                        throw e4;
                    } catch (hd e6) {
                        e2 = e6;
                    } catch (IllegalBlockSizeException e7) {
                        e3 = e7;
                        str9 = str14;
                        jrVar = null;
                        context2 = null;
                        a(context, hqVar, e3);
                        bArr = context2;
                        if (bArr == null) {
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        str9 = str14;
                        jrVar = null;
                        context3 = null;
                        il.c(th, str10, str11);
                        a(context, hqVar, th);
                        bArr = context3;
                        if (bArr == null) {
                        }
                    }
                } catch (Throwable unused) {
                    str14 = str;
                    str9 = str14;
                    str6 = "infocode";
                    str5 = "info";
                    str8 = "result";
                    str7 = "ver";
                    bVar = bVar2;
                    str10 = "at";
                    str11 = "lc";
                    try {
                        throw new hd(AMapException.ERROR_UNKNOWN);
                    } catch (hd e8) {
                        e2 = e8;
                        jrVar = null;
                        bArr2 = null;
                        bVar.f3410c = e2.a();
                        a(context, hqVar, e2.a());
                        il.a(hqVar, "/v3/iasdkauth", e2);
                        bArr = bArr2;
                        if (bArr == null) {
                        }
                    } catch (IllegalBlockSizeException e9) {
                        e3 = e9;
                        jrVar = null;
                        context2 = null;
                        a(context, hqVar, e3);
                        bArr = context2;
                        if (bArr == null) {
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        jrVar = null;
                        context3 = null;
                        il.c(th, str10, str11);
                        a(context, hqVar, th);
                        bArr = context3;
                        if (bArr == null) {
                        }
                    }
                }
                try {
                    sb.append(str14);
                    sb.append(";15K;16H;17I;17S;183");
                    str9 = sb.toString();
                } catch (hd e10) {
                    e4 = e10;
                    str6 = "infocode";
                    str5 = "info";
                    str8 = "result";
                    str7 = "ver";
                    bVar = bVar2;
                    str10 = "at";
                    str11 = "lc";
                    throw e4;
                } catch (Throwable unused2) {
                    str9 = str14;
                    str6 = "infocode";
                    str5 = "info";
                    str8 = "result";
                    str7 = "ver";
                    bVar = bVar2;
                    str10 = "at";
                    str11 = "lc";
                    throw new hd(AMapException.ERROR_UNKNOWN);
                }
            } else {
                str9 = str;
            }
            try {
                d(context);
                Context context4 = context;
                str8 = "result";
                bVar = bVar2;
                str7 = "ver";
                str10 = "at";
                str6 = "infocode";
                str11 = "lc";
                str5 = "info";
                try {
                    jrVar = jj.a(new c(context4, hqVar, str9, map, str2, str3, str4));
                    if (isEmpty) {
                        return bVar;
                    }
                    if (jrVar != null) {
                        try {
                            byte[] bArr4 = jrVar.f3812a;
                            try {
                                Map<String, List<String>> map2 = jrVar.f3813b;
                                bArr3 = bArr4;
                                if (map2 != null) {
                                    bArr3 = bArr4;
                                    if (map2.containsKey("lct")) {
                                        List<String> list = map2.get("lct");
                                        bArr3 = bArr4;
                                        if (list != null) {
                                            bArr3 = bArr4;
                                            if (list.size() > 0) {
                                                String str16 = list.get(0);
                                                bArr3 = bArr4;
                                                if (!TextUtils.isEmpty(str16)) {
                                                    long longValue = Long.valueOf(str16).longValue();
                                                    bVar.f3412e = longValue;
                                                    bArr3 = bArr4;
                                                    if (hqVar != null) {
                                                        bArr3 = bArr4;
                                                        if (longValue != 0) {
                                                            String a2 = hqVar.a();
                                                            bArr3 = bArr4;
                                                            if (!TextUtils.isEmpty(a2)) {
                                                                b(a2, bVar.f3412e);
                                                                bArr3 = bArr4;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            } catch (Throwable th4) {
                                try {
                                    il.c(th4, str10, "lct");
                                    bArr3 = bArr4;
                                } catch (hd e11) {
                                    e2 = e11;
                                    bArr2 = context4;
                                    bVar.f3410c = e2.a();
                                    a(context, hqVar, e2.a());
                                    il.a(hqVar, "/v3/iasdkauth", e2);
                                    bArr = bArr2;
                                    if (bArr == null) {
                                    }
                                } catch (IllegalBlockSizeException e12) {
                                    e3 = e12;
                                    context2 = context4;
                                    a(context, hqVar, e3);
                                    bArr = context2;
                                    if (bArr == null) {
                                    }
                                } catch (Throwable th5) {
                                    th = th5;
                                    context3 = context4;
                                    il.c(th, str10, str11);
                                    a(context, hqVar, th);
                                    bArr = context3;
                                    if (bArr == null) {
                                    }
                                }
                            }
                        } catch (hd e13) {
                            e2 = e13;
                            bArr2 = null;
                            bVar.f3410c = e2.a();
                            a(context, hqVar, e2.a());
                            il.a(hqVar, "/v3/iasdkauth", e2);
                            bArr = bArr2;
                            if (bArr == null) {
                            }
                        } catch (IllegalBlockSizeException e14) {
                            e3 = e14;
                            context2 = null;
                            a(context, hqVar, e3);
                            bArr = context2;
                            if (bArr == null) {
                            }
                        } catch (Throwable th6) {
                            th = th6;
                            context3 = null;
                            il.c(th, str10, str11);
                            a(context, hqVar, th);
                            bArr = context3;
                            if (bArr == null) {
                            }
                        }
                    } else {
                        bArr3 = null;
                    }
                    byte[] bArr5 = new byte[16];
                    byte[] bArr6 = new byte[(bArr3.length - 16)];
                    System.arraycopy(bArr3, 0, bArr5, 0, 16);
                    System.arraycopy(bArr3, 16, bArr6, 0, bArr3.length - 16);
                    SecretKeySpec secretKeySpec = new SecretKeySpec(bArr5, hr.c("EQUVT"));
                    Cipher instance = Cipher.getInstance(hr.c("CQUVTL0NCQy9QS0NTNVBhZGRpbmc"));
                    instance.init(2, secretKeySpec, new IvParameterSpec(hr.c()));
                    str15 = hr.a(instance.doFinal(bArr6));
                    bArr = bArr3;
                    if (bArr == null) {
                        return bVar;
                    }
                    if (TextUtils.isEmpty(str15)) {
                        str15 = hr.a(bArr);
                    }
                    if (TextUtils.isEmpty(str15)) {
                        a(context, hqVar, "result is null");
                    }
                    try {
                        JSONObject jSONObject = new JSONObject(str15);
                        if (jSONObject.has("status")) {
                            int i2 = jSONObject.getInt("status");
                            if (i2 == 1) {
                                f3397a = 1;
                            } else if (i2 == 0) {
                                if (jrVar != null) {
                                    str12 = jrVar.f3814c;
                                    str13 = jrVar.f3815d;
                                } else {
                                    str12 = "authcsid";
                                    str13 = "authgsid";
                                }
                                hr.a(context, str12, str13, jSONObject);
                                f3397a = 0;
                                if (jSONObject.has(str5)) {
                                    f3398b = jSONObject.getString(str5);
                                }
                                String str17 = "";
                                if (jSONObject.has(str6)) {
                                    str17 = jSONObject.getString(str6);
                                }
                                il.a(hqVar, "/v3/iasdkauth", f3398b, str13, str12, str17);
                                if (f3397a == 0) {
                                    bVar.f3410c = f3398b;
                                    return bVar;
                                }
                            }
                            try {
                                if (jSONObject.has(str7)) {
                                    bVar.f3411d = jSONObject.getInt(str7);
                                }
                            } catch (Throwable th7) {
                                ii.a(th7, str10, str11);
                            }
                            if (hr.a(jSONObject, str8)) {
                                JSONObject jSONObject2 = jSONObject.getJSONObject(str8);
                                a(context, hqVar, str9, bVar, jSONObject2);
                                try {
                                    JSONObject jSONObject3 = jSONObject2.getJSONObject("15K");
                                    boolean a3 = a(jSONObject3.optString("isTargetAble"), false);
                                    if (!a(jSONObject3.optString("able"), false)) {
                                        hk.a();
                                        hk.b(context);
                                    } else {
                                        hk.a().a(context, a3);
                                    }
                                } catch (Throwable unused3) {
                                }
                            }
                        }
                    } catch (Throwable th8) {
                        ii.a(th8, str10, str11);
                    }
                    return bVar;
                } catch (hd e15) {
                    e4 = e15;
                    str14 = str9;
                    throw e4;
                } catch (Throwable unknown) {
                    throw new hd(AMapException.ERROR_UNKNOWN);
                }
            } catch (hd e16) {
                e4 = e16;
                str6 = "infocode";
                str5 = "info";
                str8 = "result";
                str7 = "ver";
                bVar = bVar2;
                str10 = "at";
                str11 = "lc";
                str14 = str9;
                throw e4;
            } catch (Throwable unused4) {
                str6 = "infocode";
                str5 = "info";
                str8 = "result";
                str7 = "ver";
                bVar = bVar2;
                str10 = "at";
                str11 = "lc";
                throw new hd(AMapException.ERROR_UNKNOWN);
            }
        } catch (hd e17) {
            e2 = e17;
            str14 = str;
            str6 = "infocode";
            str5 = "info";
            str8 = "result";
            str7 = "ver";
            bVar = bVar2;
            str10 = "at";
            str11 = "lc";
            str9 = str14;
            jrVar = null;
            bArr2 = null;
            bVar.f3410c = e2.a();
            a(context, hqVar, e2.a());
            il.a(hqVar, "/v3/iasdkauth", e2);
            bArr = bArr2;
            if (bArr == null) {
            }
        } catch (IllegalBlockSizeException e18) {
            e3 = e18;
            str14 = str;
            str6 = "infocode";
            str5 = "info";
            str8 = "result";
            str7 = "ver";
            bVar = bVar2;
            str10 = "at";
            str11 = "lc";
            str9 = str14;
            jrVar = null;
            context2 = null;
            a(context, hqVar, e3);
            bArr = context2;
            if (bArr == null) {
            }
        } catch (Throwable th9) {
            th = th9;
            str14 = str;
            str6 = "infocode";
            str5 = "info";
            str8 = "result";
            str7 = "ver";
            bVar = bVar2;
            str10 = "at";
            str11 = "lc";
            str9 = str14;
            jrVar = null;
            context3 = null;
            il.c(th, str10, str11);
            a(context, hqVar, th);
            bArr = context3;
            if (bArr == null) {
            }
        }
    }

    private static void d(Context context) {
        try {
            if (!w) {
                Cif.f3601d = iy.a(context, "open_common", "a4", true);
                Cif.f3602e = iy.a(context, "open_common", "a5", true);
                w = true;
            }
        } catch (Throwable unused) {
        }
    }

    private static synchronized void b(String str, long j2) {
        synchronized (hf.class) {
            try {
                if (v != null) {
                    if (v.containsKey(str)) {
                        if (t == null) {
                            t = new ConcurrentHashMap<>(8);
                        }
                        t.put(str, Long.valueOf(j2));
                        Context context = f3399c;
                        if (context != null) {
                            SharedPreferences.Editor a2 = iy.a(context, "open_common");
                            iy.a(a2, str, j2);
                            iy.a(a2);
                        }
                    }
                }
            } catch (Throwable th) {
                ii.a(th, "at", "ucut");
            }
        }
    }

    public static void c(jn.c cVar) {
        if (cVar != null && j) {
            synchronized (D) {
                D.offer(cVar);
                jn.b();
            }
        }
    }

    public static boolean d(String str) {
        e a2;
        try {
            if (TextUtils.isEmpty(str)) {
                return true;
            }
            if (!f3402f) {
                return false;
            }
            if (!(z.get(str) == null)) {
                return false;
            }
            Context context = f3399c;
            if (context == null || (a2 = a(context, b(str, "a14"), "open_common")) == null || a2.a() < x) {
                return true;
            }
            return false;
        } catch (Throwable unused) {
            return true;
        }
    }

    public static void c() {
        try {
            e a2 = a(f3399c, "IPV6_CONFIG_NAME", "open_common");
            String a3 = hr.a(System.currentTimeMillis(), Logger.TIMESTAMP_YYYY_MM_DD);
            if (!a3.equals(a2.f3423b)) {
                a2.a(a3);
                a2.f3424c.set(0);
            }
            a2.f3424c.incrementAndGet();
            a(f3399c, "IPV6_CONFIG_NAME", "open_common", a2);
        } catch (Throwable unused) {
        }
    }

    private static String b(String str, String str2) {
        String a2 = hm.a(str.getBytes());
        return str2 + "_" + a2;
    }

    public static void b(jn.c cVar) {
        int i2;
        synchronized (B) {
            boolean z2 = false;
            for (int i3 = 0; i3 < B.size(); i3++) {
                jn.a aVar = B.get(i3);
                if (cVar.f3766c.equals(aVar.f3756b) && cVar.f3767d.equals(aVar.f3759e) && cVar.m == (i2 = aVar.f3760f)) {
                    if (i2 == 1) {
                        aVar.i = ((((long) aVar.j.get()) * aVar.i) + cVar.f3769f) / ((long) (aVar.j.get() + 1));
                    }
                    aVar.j.getAndIncrement();
                    z2 = true;
                }
            }
            if (!z2) {
                B.add(new jn.a(cVar));
            }
            jn.b();
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:101:0x0244 A[SYNTHETIC, Splitter:B:101:0x0244] */
    /* JADX WARNING: Removed duplicated region for block: B:126:0x02e3 A[SYNTHETIC, Splitter:B:126:0x02e3] */
    /* JADX WARNING: Removed duplicated region for block: B:132:0x02fb A[SYNTHETIC, Splitter:B:132:0x02fb] */
    /* JADX WARNING: Removed duplicated region for block: B:141:? A[RETURN, SYNTHETIC] */
    private static void a(Context context, hq hqVar, String str, b bVar, JSONObject jSONObject) throws JSONException {
        String str2;
        String str3;
        String str4;
        Context context2;
        Throwable th;
        boolean a2;
        boolean a3;
        boolean a4;
        String[] strArr;
        b.a aVar = new b.a();
        aVar.f3415a = false;
        aVar.f3416b = false;
        bVar.f3414g = aVar;
        try {
            String[] split = str.split(i.f2452b);
            if (split != null && split.length > 0) {
                int length = split.length;
                int i2 = 0;
                while (i2 < length) {
                    String str5 = split[i2];
                    if (jSONObject.has(str5)) {
                        strArr = split;
                        bVar.f3413f.putOpt(str5, jSONObject.get(str5));
                    } else {
                        strArr = split;
                    }
                    i2++;
                    split = strArr;
                }
            }
        } catch (Throwable th2) {
            ii.a(th2, "at", "co");
        }
        if (hr.a(jSONObject, "16H")) {
            try {
                bVar.i = a(jSONObject.getJSONObject("16H").optString("able"), false);
            } catch (Throwable th3) {
                ii.a(th3, "AuthConfigManager", "load 16H");
            }
        }
        if (hr.a(jSONObject, "11K")) {
            try {
                JSONObject jSONObject2 = jSONObject.getJSONObject("11K");
                aVar.f3415a = a(jSONObject2.getString("able"), false);
                if (jSONObject2.has("off")) {
                    aVar.f3417c = jSONObject2.getJSONObject("off");
                }
            } catch (Throwable th4) {
                ii.a(th4, "AuthConfigManager", "load 11K");
            }
        }
        if (hr.a(jSONObject, "145")) {
            try {
                bVar.f3408a = jSONObject.getJSONObject("145");
            } catch (Throwable th5) {
                ii.a(th5, "AuthConfigManager", "load 145");
            }
        }
        if (hr.a(jSONObject, "14D")) {
            try {
                bVar.f3409b = jSONObject.getJSONObject("14D");
            } catch (Throwable th6) {
                ii.a(th6, "AuthConfigManager", "load 14D");
            }
        }
        if (hr.a(jSONObject, "151")) {
            try {
                JSONObject jSONObject3 = jSONObject.getJSONObject("151");
                b.C0054b bVar2 = new b.C0054b();
                if (jSONObject3 != null) {
                    bVar2.f3418a = a(jSONObject3.optString("able"), false);
                }
                bVar.h = bVar2;
            } catch (Throwable th7) {
                ii.a(th7, "AuthConfigManager", "load 151");
            }
        }
        if (hr.a(jSONObject, "17S")) {
            try {
                JSONObject jSONObject4 = jSONObject.getJSONObject("17S");
                if (!(jSONObject4 == null || (a4 = a(jSONObject4.optString("able"), false)) == o)) {
                    o = a4;
                    if (context != null) {
                        SharedPreferences.Editor a5 = iy.a(context, "open_common");
                        iy.a(a5, "a2", a4);
                        iy.a(a5);
                    }
                }
                if (jSONObject4 != null) {
                    boolean a6 = a(jSONObject4.optString("static_enable"), true);
                    boolean a7 = a(jSONObject4.optString("static_ip_direct_enable"), false);
                    int optInt = jSONObject4.optInt("static_timeout", 5) * 1000;
                    int optInt2 = jSONObject4.optInt("static_retry", 3);
                    str4 = "ustv";
                    try {
                        a2 = a(jSONObject4.optString("bgp_enable"), true);
                        str3 = "ust";
                        try {
                            a3 = a(jSONObject4.optString("bgp_ip_direct_enable"), false);
                            str2 = "umv";
                        } catch (Throwable th8) {
                            th = th8;
                            str2 = "umv";
                            ii.a(th, "AuthConfigManager", "load 17S");
                            if (hr.a(jSONObject, "15K")) {
                            }
                            context2 = context;
                            if (hr.a(jSONObject, "183")) {
                            }
                            if (hr.a(jSONObject, "17I")) {
                            }
                        }
                    } catch (Throwable th9) {
                        th = th9;
                        str3 = "ust";
                        str2 = "umv";
                        ii.a(th, "AuthConfigManager", "load 17S");
                        if (hr.a(jSONObject, "15K")) {
                        }
                        context2 = context;
                        if (hr.a(jSONObject, "183")) {
                        }
                        if (hr.a(jSONObject, "17I")) {
                        }
                    }
                    try {
                        int optInt3 = jSONObject4.optInt("bgp_retry", 3);
                        boolean a8 = a(jSONObject4.optString("perf_data_upload_enable"), false);
                        if (!(a6 == f3402f && a7 == f3403g && optInt == f3401e && optInt2 == x && a2 == h && a3 == i && optInt3 == y && a8 == j)) {
                            f3402f = a6;
                            f3403g = a7;
                            f3401e = optInt;
                            x = optInt2;
                            h = a2;
                            i = a3;
                            y = optInt3;
                            j = a8;
                            if (context != null) {
                                SharedPreferences.Editor a9 = iy.a(context, "open_common");
                                iy.a(a9, "a13", a6);
                                iy.a(a9, "a6", a2);
                                iy.a(a9, "a7", a7);
                                iy.a(a9, "a8", optInt);
                                iy.a(a9, "a9", optInt2);
                                iy.a(a9, "a10", a3);
                                iy.a(a9, "a11", optInt3);
                                iy.a(a9, "a12", a8);
                                iy.a(a9);
                            }
                        }
                        new StringBuilder("static_enable=").append(f3402f);
                        jn.b();
                        new StringBuilder("bgp_enable=").append(h);
                        jn.b();
                        new StringBuilder("static_ip_direct_enable=").append(f3403g);
                        jn.b();
                        new StringBuilder("bgp_ip_direct_enable=").append(i);
                        jn.b();
                        new StringBuilder("perf_data_upload_enable=").append(j);
                        jn.b();
                    } catch (Throwable th10) {
                        th = th10;
                        ii.a(th, "AuthConfigManager", "load 17S");
                        if (hr.a(jSONObject, "15K")) {
                        }
                        context2 = context;
                        if (hr.a(jSONObject, "183")) {
                        }
                        if (hr.a(jSONObject, "17I")) {
                        }
                    }
                    if (hr.a(jSONObject, "15K")) {
                        try {
                            JSONObject jSONObject5 = jSONObject.getJSONObject("15K");
                            if (jSONObject5 != null) {
                                boolean a10 = a(jSONObject5.optString("ucf"), f.f3425a);
                                boolean a11 = a(jSONObject5.optString("fsv2"), f.f3426b);
                                boolean a12 = a(jSONObject5.optString("usc"), f.f3427c);
                                int optInt4 = jSONObject5.optInt(str2, f.f3428d);
                                boolean a13 = a(jSONObject5.optString(str3), f.f3429e);
                                int optInt5 = jSONObject5.optInt(str4, f.f3430f);
                                if (!(a10 == f.f3425a && a11 == f.f3426b && a12 == f.f3427c && optInt4 == f.f3428d && a13 == f.f3429e && optInt5 == f.f3428d)) {
                                    f.f3425a = a10;
                                    f.f3426b = a11;
                                    f.f3427c = a12;
                                    f.f3428d = optInt4;
                                    f.f3429e = a13;
                                    f.f3430f = optInt5;
                                    context2 = context;
                                    try {
                                        SharedPreferences.Editor a14 = iy.a(context2, "open_common");
                                        iy.a(a14, "ucf", f.f3425a);
                                        iy.a(a14, "fsv2", f.f3426b);
                                        iy.a(a14, "usc", f.f3427c);
                                        iy.a(a14, str2, f.f3428d);
                                        iy.a(a14, str3, f.f3429e);
                                        iy.a(a14, str4, f.f3430f);
                                        iy.a(a14);
                                    } catch (Throwable unused) {
                                    }
                                    if (hr.a(jSONObject, "183")) {
                                        try {
                                            jm.a(hqVar, jSONObject.getJSONObject("183"));
                                        } catch (Throwable th11) {
                                            ii.a(th11, "AuthConfigManager", "load 183");
                                        }
                                    }
                                    if (hr.a(jSONObject, "17I")) {
                                        try {
                                            JSONObject jSONObject6 = jSONObject.getJSONObject("17I");
                                            boolean a15 = a(jSONObject6.optString("na"), false);
                                            boolean a16 = a(jSONObject6.optString("aa"), false);
                                            Cif.f3601d = a15;
                                            Cif.f3602e = a16;
                                            SharedPreferences.Editor a17 = iy.a(context2, "open_common");
                                            iy.a(a17, "a4", a15);
                                            iy.a(a17, "a5", a16);
                                            iy.a(a17);
                                            return;
                                        } catch (Throwable th12) {
                                            ii.a(th12, "AuthConfigManager", "load 17I");
                                            return;
                                        }
                                    } else {
                                        return;
                                    }
                                }
                            }
                        } catch (Throwable th13) {
                            context2 = context;
                            ii.a(th13, "AuthConfigManager", "load 15K");
                        }
                    }
                    context2 = context;
                    if (hr.a(jSONObject, "183")) {
                    }
                    if (hr.a(jSONObject, "17I")) {
                    }
                }
            } catch (Throwable th14) {
                th = th14;
                str4 = "ustv";
                str3 = "ust";
                str2 = "umv";
                ii.a(th, "AuthConfigManager", "load 17S");
                if (hr.a(jSONObject, "15K")) {
                }
                context2 = context;
                if (hr.a(jSONObject, "183")) {
                }
                if (hr.a(jSONObject, "17I")) {
                }
            }
        }
        str4 = "ustv";
        str3 = "ust";
        str2 = "umv";
        if (hr.a(jSONObject, "15K")) {
        }
        context2 = context;
        if (hr.a(jSONObject, "183")) {
        }
        if (hr.a(jSONObject, "17I")) {
        }
    }

    private static void a(Context context, hq hqVar, Throwable th) {
        a(context, hqVar, th.getMessage());
    }

    public static void a(String str, boolean z2, boolean z3, boolean z4) {
        if (!TextUtils.isEmpty(str) && f3399c != null) {
            HashMap hashMap = new HashMap();
            hashMap.put("url", str);
            hashMap.put("downLevel", String.valueOf(z2));
            String str2 = "0";
            hashMap.put("ant", hi.n(f3399c) == 0 ? str2 : "1");
            if (z4) {
                hashMap.put("type", z2 ? m : n);
            } else {
                hashMap.put("type", z2 ? k : l);
            }
            if (!z3) {
                str2 = "1";
            }
            hashMap.put("status", str2);
            String jSONObject = new JSONObject(hashMap).toString();
            if (!TextUtils.isEmpty(jSONObject)) {
                try {
                    jy jyVar = new jy(f3399c, "core", "2.0", "O002");
                    jyVar.a(jSONObject);
                    jz.a(jyVar, f3399c);
                } catch (hd unused) {
                }
            }
        }
    }

    public static void a(jn.c cVar) {
        if (cVar != null && f3399c != null) {
            HashMap hashMap = new HashMap();
            hashMap.put("serverip", cVar.f3766c);
            hashMap.put("hostname", cVar.f3768e);
            hashMap.put("path", cVar.f3767d);
            hashMap.put("csid", cVar.f3764a);
            hashMap.put("degrade", String.valueOf(cVar.f3765b.a()));
            hashMap.put("errorcode", String.valueOf(cVar.m));
            hashMap.put("errorsubcode", String.valueOf(cVar.n));
            hashMap.put("connecttime", String.valueOf(cVar.h));
            hashMap.put("writetime", String.valueOf(cVar.i));
            hashMap.put("readtime", String.valueOf(cVar.j));
            hashMap.put("datasize", String.valueOf(cVar.l));
            hashMap.put("totaltime", String.valueOf(cVar.f3769f));
            String jSONObject = new JSONObject(hashMap).toString();
            "--埋点--".concat(String.valueOf(jSONObject));
            jn.b();
            if (!TextUtils.isEmpty(jSONObject)) {
                try {
                    jy jyVar = new jy(f3399c, "core", "2.0", "O008");
                    jyVar.a(jSONObject);
                    jz.a(jyVar, f3399c);
                } catch (hd unused) {
                }
            }
        }
    }

    private static void a(Context context, hq hqVar, String str) {
        HashMap hashMap = new HashMap();
        hashMap.put("amap_sdk_auth_fail", "1");
        hashMap.put("amap_sdk_auth_fail_type", str);
        hashMap.put("amap_sdk_name", hqVar.a());
        hashMap.put("amap_sdk_version", hqVar.c());
        String jSONObject = new JSONObject(hashMap).toString();
        if (!TextUtils.isEmpty(jSONObject)) {
            try {
                jy jyVar = new jy(context, "core", "2.0", "O001");
                jyVar.a(jSONObject);
                jz.a(jyVar, context);
            } catch (hd unused) {
            }
        }
    }

    public static boolean a() {
        e a2;
        if (f3399c != null) {
            h();
            if (!b()) {
                return false;
            }
            if (i()) {
                return true;
            }
        }
        return o && (a2 = a(f3399c, "IPV6_CONFIG_NAME", "open_common")) != null && a2.a() < 5;
    }

    private static boolean a(InetAddress inetAddress) {
        return inetAddress.isLoopbackAddress() || inetAddress.isLinkLocalAddress() || inetAddress.isAnyLocalAddress();
    }

    private static void a(Context context, String str, String str2, e eVar) {
        if (eVar != null && !TextUtils.isEmpty(eVar.f3422a)) {
            String b2 = eVar.b();
            if (!TextUtils.isEmpty(b2) && context != null) {
                SharedPreferences.Editor a2 = iy.a(context, str2);
                a2.putString(str, b2);
                iy.a(a2);
            }
        }
    }

    public static synchronized void a(Context context, hq hqVar, String str, a aVar) {
        synchronized (hf.class) {
            if (context != null && hqVar != null) {
                try {
                    if (f3399c == null) {
                        f3399c = context.getApplicationContext();
                    }
                    String a2 = hqVar.a();
                    if (!TextUtils.isEmpty(a2)) {
                        a(hqVar);
                        if (v == null) {
                            v = new ConcurrentHashMap<>(8);
                        }
                        if (u == null) {
                            u = new ConcurrentHashMap<>(8);
                        }
                        if (t == null) {
                            t = new ConcurrentHashMap<>(8);
                        }
                        if (!v.containsKey(a2)) {
                            d dVar = new d((byte) 0);
                            dVar.f3419a = hqVar;
                            dVar.f3420b = str;
                            dVar.f3421c = aVar;
                            v.put(a2, dVar);
                            t.put(a2, Long.valueOf(iy.b(f3399c, "open_common", a2)));
                            d(f3399c);
                        }
                    }
                } catch (Throwable th) {
                    ii.a(th, "at", "rglc");
                }
            }
        }
    }

    public static synchronized boolean a(String str, long j2) {
        synchronized (hf.class) {
            boolean z2 = false;
            try {
                if (TextUtils.isEmpty(str)) {
                    return false;
                }
                if (j2 > c(str)) {
                    long j3 = 0;
                    if (u != null && u.containsKey(str)) {
                        j3 = u.get(str).longValue();
                    }
                    if (SystemClock.elapsedRealtime() - j3 > 30000) {
                        z2 = true;
                    }
                }
                return z2;
            } catch (Throwable unused) {
            }
        }
    }

    public static synchronized void a(final String str, boolean z2, final String str2, final String str3, final String str4) {
        synchronized (hf.class) {
            try {
                if (!TextUtils.isEmpty(str)) {
                    if (u == null) {
                        u = new ConcurrentHashMap<>(8);
                    }
                    u.put(str, Long.valueOf(SystemClock.elapsedRealtime()));
                    if (v != null) {
                        if (v.containsKey(str)) {
                            if (!TextUtils.isEmpty(str)) {
                                if (z2) {
                                    jm.a(true, str);
                                }
                                kq.a().a(new kr() {
                                    /* class com.amap.api.col.p0003s.hf.AnonymousClass1 */

                                    @Override // com.amap.api.col.p0003s.kr
                                    public final void runTask() {
                                        d dVar = (d) hf.v.get(str);
                                        if (dVar != null) {
                                            a aVar = dVar.f3421c;
                                            b a2 = hf.a(hf.f3399c, dVar.f3419a, dVar.f3420b, str2, str3, str4);
                                            if (a2 != null && aVar != null) {
                                                aVar.a(a2);
                                            }
                                        }
                                    }
                                });
                            }
                        }
                    }
                }
            } catch (Throwable th) {
                ii.a(th, "at", "lca");
            }
        }
    }

    public static synchronized boolean a(String str) {
        synchronized (hf.class) {
            try {
                if (TextUtils.isEmpty(str)) {
                    return false;
                }
                if (v == null) {
                    return false;
                }
                if (u == null) {
                    u = new ConcurrentHashMap<>(8);
                }
                if (v.containsKey(str) && !u.containsKey(str)) {
                    u.put(str, Long.valueOf(SystemClock.elapsedRealtime()));
                    return true;
                }
                return false;
            } catch (Throwable th) {
                ii.a(th, "at", "cslct");
            }
        }
    }

    private static void a(hq hqVar) {
        if (hqVar != null) {
            try {
                if (!TextUtils.isEmpty(hqVar.a())) {
                    String c2 = hqVar.c();
                    if (TextUtils.isEmpty(c2)) {
                        c2 = hqVar.b();
                    }
                    if (!TextUtils.isEmpty(c2)) {
                        Cif.a(hqVar.a(), c2);
                    }
                }
            } catch (Throwable unused) {
            }
        }
    }

    public static void a(boolean z2, String str) {
        Boolean bool = Boolean.TRUE;
        try {
            "--markHostNameFailed---hostname=".concat(String.valueOf(str));
            jn.b();
            if (!f3402f && !z2) {
                return;
            }
            if ((!i && z2) || TextUtils.isEmpty(str)) {
                return;
            }
            if (!z2) {
                if (z.get(str) == null) {
                    z.put(str, bool);
                    a(b(str, "a14"), "open_common");
                }
            } else if (A.get(str) == null) {
                A.put(str, bool);
                a(b(str, "a15"), "open_common");
            }
        } catch (Throwable unused) {
        }
    }

    private static void a(String str, String str2) {
        e a2 = a(f3399c, str, str2);
        String a3 = hr.a(System.currentTimeMillis(), Logger.TIMESTAMP_YYYY_MM_DD);
        if (!a3.equals(a2.f3423b)) {
            a2.a(a3);
            a2.f3424c.set(0);
        }
        a2.f3424c.incrementAndGet();
        a(f3399c, str, str2, a2);
    }

    public static void a(boolean z2, jn.a aVar) {
        if (C && aVar != null) {
            synchronized (B) {
                if (z2) {
                    Iterator<jn.a> it = B.iterator();
                    while (it.hasNext()) {
                        jn.a next = it.next();
                        if (next.f3756b.equals(aVar.f3756b) && next.f3759e.equals(aVar.f3759e) && next.f3760f == aVar.f3760f) {
                            if (next.j == aVar.j) {
                                it.remove();
                                jn.b();
                            } else {
                                next.j.set(next.j.get() - aVar.j.get());
                                jn.b();
                            }
                        }
                    }
                }
                C = false;
                Iterator<jn.a> it2 = B.iterator();
                jn.b();
                while (it2.hasNext()) {
                    jn.a next2 = it2.next();
                    StringBuilder sb = new StringBuilder("----path=");
                    sb.append(next2.f3759e);
                    sb.append("-counts=");
                    sb.append(next2.j);
                    sb.append("-code=");
                    sb.append(next2.f3760f);
                    sb.append("----");
                    jn.b();
                }
                jn.b();
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:15:0x002f A[DONT_GENERATE] */
    /* JADX WARNING: Removed duplicated region for block: B:17:0x0031  */
    private static synchronized e a(Context context, String str, String str2) {
        e eVar;
        synchronized (hf.class) {
            if (!TextUtils.isEmpty(str)) {
                int i2 = 0;
                while (true) {
                    if (i2 >= p.size()) {
                        break;
                    }
                    eVar = p.get(i2);
                    if (eVar != null && str.equals(eVar.f3422a)) {
                        break;
                    }
                    i2++;
                }
                if (eVar == null) {
                    return eVar;
                }
                if (context == null) {
                    return null;
                }
                e b2 = e.b(iy.b(context, str2, str, ""));
                String a2 = hr.a(System.currentTimeMillis(), Logger.TIMESTAMP_YYYY_MM_DD);
                if (b2 == null) {
                    b2 = new e(str, a2, 0);
                }
                if (!a2.equals(b2.f3423b)) {
                    b2.a(a2);
                    b2.f3424c.set(0);
                }
                p.add(b2);
                return b2;
            }
            eVar = null;
            if (eVar == null) {
            }
        }
    }
}