%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD.apk(点击下载) / m.java


package com.loc;

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.amap.api.maps.AMapException;
import com.loc.bj;
import com.loc.bl;
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.performance.WXInstanceApm;
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;

/* compiled from: AuthConfigManager */
public final class m {
    private static ConcurrentHashMap<String, Boolean> A = new ConcurrentHashMap<>();
    private static ArrayList<bj.a> B = new ArrayList<>();
    private static volatile boolean C = false;
    private static Queue<bj.c> D = new LinkedList();
    public static int a = -1;
    public static String b = "";
    public static Context c = null;
    public static volatile boolean d = false;
    public static int e = 5000;
    public static boolean f = true;
    public static boolean g = 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<>();

    /* compiled from: AuthConfigManager */
    public interface a {
        void a(b bVar);
    }

    /* compiled from: AuthConfigManager */
    public static class b {
        @Deprecated
        public JSONObject a;
        @Deprecated
        public JSONObject b;
        public String c;
        public int d = -1;
        public long e = 0;
        public JSONObject f;
        public a g;
        public C0016b h;
        private boolean i;

        /* compiled from: AuthConfigManager */
        public static class a {
            public boolean a;
            public boolean b;
            public JSONObject c;
        }

        /* renamed from: com.loc.m$b$b  reason: collision with other inner class name */
        /* compiled from: AuthConfigManager */
        public static class C0016b {
            public boolean a;
        }
    }

    /* access modifiers changed from: package-private */
    /* compiled from: AuthConfigManager */
    public static class c extends bh {
        private String h;
        private Map<String, String> i = null;
        private String j;
        private String k;
        private String l;

        c(Context context, w wVar, String str, String str2, String str3, String str4) {
            super(context, wVar);
            this.h = str;
            this.j = str2;
            this.k = str3;
            this.l = str4;
            a(bl.c.HTTPS);
            a(bl.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.loc.bl
        public final Map<String, String> a() {
            if (TextUtils.isEmpty(this.l)) {
                return null;
            }
            HashMap hashMap = new HashMap();
            hashMap.put("host", this.l);
            return hashMap;
        }

        @Override // com.loc.bh
        public final byte[] a_() {
            return null;
        }

        @Override // com.loc.bl
        public final String b() {
            return a("https://restsdk.amap.com/v3/iasdkauth", this.j);
        }

        @Override // com.loc.bh
        public final byte[] b_() {
            String u = o.u(this.a);
            if (!TextUtils.isEmpty(u)) {
                u = s.a(new StringBuilder(u).reverse().toString());
            }
            HashMap hashMap = new HashMap();
            hashMap.put("authkey", TextUtils.isEmpty(this.h) ? "" : this.h);
            hashMap.put("plattype", WXEnvironment.OS);
            hashMap.put("product", this.b.a());
            hashMap.put("version", this.b.b());
            hashMap.put("output", "json");
            StringBuilder sb = new StringBuilder();
            sb.append(Build.VERSION.SDK_INT);
            hashMap.put("androidversion", sb.toString());
            hashMap.put("deviceId", u);
            hashMap.put("manufacture", Build.MANUFACTURER);
            Map<String, String> map = this.i;
            if (map != null && !map.isEmpty()) {
                hashMap.putAll(this.i);
            }
            hashMap.put("abitype", x.a(this.a));
            hashMap.put("ext", this.b.d());
            return x.a(x.a(hashMap));
        }

        @Override // com.loc.r, com.loc.bl
        public final String c() {
            return a("https://dualstack-arestapi.amap.com/v3/iasdkauth", this.k);
        }

        /* access modifiers changed from: protected */
        @Override // com.loc.bh
        public final String f() {
            return "3.0";
        }

        /* access modifiers changed from: protected */
        @Override // com.loc.bl
        public final String g() {
            return !TextUtils.isEmpty(this.l) ? this.l : super.g();
        }
    }

    /* access modifiers changed from: private */
    /* compiled from: AuthConfigManager */
    public static class d {
        w a;
        String b;
        a c;

        private d() {
        }

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

    /* compiled from: AuthConfigManager */
    public static class e {
        private String a;
        private String b;
        private AtomicInteger c;

        public e(String str, String str2, int i) {
            this.a = str;
            this.b = str2;
            this.c = new AtomicInteger(i);
        }

        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;
            }
        }

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

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

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

    /* compiled from: AuthConfigManager */
    public static class f {
        public static boolean a = true;
        public static boolean b = false;
        public static boolean c = true;
        public static int d = 0;
        public static boolean e = false;
        public static int f;
    }

    public static b a(Context context, w wVar, String str, String str2, String str3, String str4) {
        return b(context, wVar, str, str2, str3, str4);
    }

    /* 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 (m.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.a)) {
                        break;
                    }
                    i2++;
                }
                if (eVar == null) {
                    return eVar;
                }
                if (context == null) {
                    return null;
                }
                e b2 = e.b(av.b(context, str2, str, ""));
                String a2 = x.a(System.currentTimeMillis(), Logger.TIMESTAMP_YYYY_MM_DD);
                if (b2 == null) {
                    b2 = new e(str, a2, 0);
                }
                if (!a2.equals(b2.b)) {
                    b2.a(a2);
                    b2.c.set(0);
                }
                p.add(b2);
                return b2;
            }
            eVar = null;
            if (eVar == null) {
            }
        }
    }

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

    private static void a(Context context, w wVar, 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", wVar.a());
        hashMap.put("amap_sdk_version", wVar.c());
        String jSONObject = new JSONObject(hashMap).toString();
        if (!TextUtils.isEmpty(jSONObject)) {
            try {
                br brVar = new br(context, "core", "2.0", "O001");
                brVar.a(jSONObject);
                bs.a(brVar, context);
            } catch (k unused) {
            }
        }
    }

    public static synchronized void a(Context context, w wVar, String str, a aVar) {
        synchronized (m.class) {
            if (context != null && wVar != null) {
                try {
                    if (c == null) {
                        c = context.getApplicationContext();
                    }
                    String a2 = wVar.a();
                    if (!TextUtils.isEmpty(a2)) {
                        a(wVar);
                        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.a = wVar;
                            dVar.b = str;
                            dVar.c = aVar;
                            v.put(a2, dVar);
                            t.put(a2, Long.valueOf(av.b(c, "open_common", a2)));
                            d(c);
                        }
                    }
                } catch (Throwable th) {
                    ak.a(th, "at", "rglc");
                }
            }
        }
    }

    /* 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:0x02e5 A[SYNTHETIC, Splitter:B:126:0x02e5] */
    /* JADX WARNING: Removed duplicated region for block: B:132:0x02fd A[SYNTHETIC, Splitter:B:132:0x02fd] */
    /* JADX WARNING: Removed duplicated region for block: B:141:? A[RETURN, SYNTHETIC] */
    private static void a(Context context, w wVar, 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.a = false;
        aVar.b = false;
        bVar.g = aVar;
        try {
            String[] split = str.split(";");
            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.f.putOpt(str5, jSONObject.get(str5));
                    } else {
                        strArr = split;
                    }
                    i2++;
                    split = strArr;
                }
            }
        } catch (Throwable th2) {
            ak.a(th2, "at", "co");
        }
        if (x.a(jSONObject, "16H")) {
            try {
                bVar.i = a(jSONObject.getJSONObject("16H").optString("able"), false);
            } catch (Throwable th3) {
                ak.a(th3, "AuthConfigManager", "load 16H");
            }
        }
        if (x.a(jSONObject, "11K")) {
            try {
                JSONObject jSONObject2 = jSONObject.getJSONObject("11K");
                aVar.a = a(jSONObject2.getString("able"), false);
                if (jSONObject2.has("off")) {
                    aVar.c = jSONObject2.getJSONObject("off");
                }
            } catch (Throwable th4) {
                ak.a(th4, "AuthConfigManager", "load 11K");
            }
        }
        if (x.a(jSONObject, "145")) {
            try {
                bVar.a = jSONObject.getJSONObject("145");
            } catch (Throwable th5) {
                ak.a(th5, "AuthConfigManager", "load 145");
            }
        }
        if (x.a(jSONObject, "14D")) {
            try {
                bVar.b = jSONObject.getJSONObject("14D");
            } catch (Throwable th6) {
                ak.a(th6, "AuthConfigManager", "load 14D");
            }
        }
        if (x.a(jSONObject, "151")) {
            try {
                JSONObject jSONObject3 = jSONObject.getJSONObject("151");
                b.C0016b bVar2 = new b.C0016b();
                if (jSONObject3 != null) {
                    bVar2.a = a(jSONObject3.optString("able"), false);
                }
                bVar.h = bVar2;
            } catch (Throwable th7) {
                ak.a(th7, "AuthConfigManager", "load 151");
            }
        }
        if (x.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 = av.a(context, "open_common");
                        av.a(a5, "a2", a4);
                        av.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";
                            ak.a(th, "AuthConfigManager", "load 17S");
                            if (x.a(jSONObject, "15K")) {
                            }
                            context2 = context;
                            if (x.a(jSONObject, "183")) {
                            }
                            if (x.a(jSONObject, "17I")) {
                            }
                        }
                    } catch (Throwable th9) {
                        th = th9;
                        str3 = "ust";
                        str2 = "umv";
                        ak.a(th, "AuthConfigManager", "load 17S");
                        if (x.a(jSONObject, "15K")) {
                        }
                        context2 = context;
                        if (x.a(jSONObject, "183")) {
                        }
                        if (x.a(jSONObject, "17I")) {
                        }
                    }
                    try {
                        int optInt3 = jSONObject4.optInt("bgp_retry", 3);
                        boolean a8 = a(jSONObject4.optString("perf_data_upload_enable"), false);
                        if (!(a6 == f && a7 == g && optInt == e && optInt2 == x && a2 == h && a3 == i && optInt3 == y && a8 == j)) {
                            f = a6;
                            g = a7;
                            e = optInt;
                            x = optInt2;
                            h = a2;
                            i = a3;
                            y = optInt3;
                            j = a8;
                            if (context != null) {
                                SharedPreferences.Editor a9 = av.a(context, "open_common");
                                av.a(a9, "a13", a6);
                                av.a(a9, "a6", a2);
                                av.a(a9, "a7", a7);
                                av.a(a9, "a8", optInt);
                                av.a(a9, "a9", optInt2);
                                av.a(a9, "a10", a3);
                                av.a(a9, "a11", optInt3);
                                av.a(a9, "a12", a8);
                                av.a(a9);
                            }
                        }
                        new StringBuilder("static_enable=").append(f);
                        bj.a();
                        new StringBuilder("bgp_enable=").append(h);
                        bj.a();
                        new StringBuilder("static_ip_direct_enable=").append(g);
                        bj.a();
                        new StringBuilder("bgp_ip_direct_enable=").append(i);
                        bj.a();
                        new StringBuilder("perf_data_upload_enable=").append(j);
                        bj.a();
                    } catch (Throwable th10) {
                        th = th10;
                        ak.a(th, "AuthConfigManager", "load 17S");
                        if (x.a(jSONObject, "15K")) {
                        }
                        context2 = context;
                        if (x.a(jSONObject, "183")) {
                        }
                        if (x.a(jSONObject, "17I")) {
                        }
                    }
                    if (x.a(jSONObject, "15K")) {
                        try {
                            JSONObject jSONObject5 = jSONObject.getJSONObject("15K");
                            if (jSONObject5 != null) {
                                boolean a10 = a(jSONObject5.optString("ucf"), f.a);
                                boolean a11 = a(jSONObject5.optString("fsv2"), f.b);
                                boolean a12 = a(jSONObject5.optString("usc"), f.c);
                                int optInt4 = jSONObject5.optInt(str2, f.d);
                                boolean a13 = a(jSONObject5.optString(str3), f.e);
                                int optInt5 = jSONObject5.optInt(str4, f.f);
                                if (!(a10 == f.a && a11 == f.b && a12 == f.c && optInt4 == f.d && a13 == f.e && optInt5 == f.d)) {
                                    f.a = a10;
                                    f.b = a11;
                                    f.c = a12;
                                    f.d = optInt4;
                                    f.e = a13;
                                    f.f = optInt5;
                                    context2 = context;
                                    try {
                                        SharedPreferences.Editor a14 = av.a(context2, "open_common");
                                        av.a(a14, "ucf", f.a);
                                        av.a(a14, "fsv2", f.b);
                                        av.a(a14, "usc", f.c);
                                        av.a(a14, str2, f.d);
                                        av.a(a14, str3, f.e);
                                        av.a(a14, str4, f.f);
                                        av.a(a14);
                                    } catch (Throwable unused) {
                                    }
                                    if (x.a(jSONObject, "183")) {
                                        try {
                                            bi.a(wVar, jSONObject.getJSONObject("183"));
                                        } catch (Throwable th11) {
                                            ak.a(th11, "AuthConfigManager", "load 183");
                                        }
                                    }
                                    if (x.a(jSONObject, "17I")) {
                                        try {
                                            JSONObject jSONObject6 = jSONObject.getJSONObject("17I");
                                            boolean a15 = a(jSONObject6.optString("na"), false);
                                            boolean a16 = a(jSONObject6.optString("aa"), false);
                                            ag.d = a15;
                                            ag.e = a16;
                                            SharedPreferences.Editor a17 = av.a(context2, "open_common");
                                            av.a(a17, "a4", a15);
                                            av.a(a17, "a5", a16);
                                            av.a(a17);
                                            return;
                                        } catch (Throwable th12) {
                                            ak.a(th12, "AuthConfigManager", "load 17I");
                                            return;
                                        }
                                    } else {
                                        return;
                                    }
                                }
                            }
                        } catch (Throwable th13) {
                            context2 = context;
                            ak.a(th13, "AuthConfigManager", "load 15K");
                        }
                    }
                    context2 = context;
                    if (x.a(jSONObject, "183")) {
                    }
                    if (x.a(jSONObject, "17I")) {
                    }
                }
            } catch (Throwable th14) {
                th = th14;
                str4 = "ustv";
                str3 = "ust";
                str2 = "umv";
                ak.a(th, "AuthConfigManager", "load 17S");
                if (x.a(jSONObject, "15K")) {
                }
                context2 = context;
                if (x.a(jSONObject, "183")) {
                }
                if (x.a(jSONObject, "17I")) {
                }
            }
        }
        str4 = "ustv";
        str3 = "ust";
        str2 = "umv";
        if (x.a(jSONObject, "15K")) {
        }
        context2 = context;
        if (x.a(jSONObject, "183")) {
        }
        if (x.a(jSONObject, "17I")) {
        }
    }

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

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

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

    public static void a(bj.c cVar) {
        if (cVar != null && c != null) {
            HashMap hashMap = new HashMap();
            hashMap.put("serverip", cVar.c);
            hashMap.put("hostname", cVar.e);
            hashMap.put("path", cVar.d);
            hashMap.put("csid", cVar.a);
            hashMap.put("degrade", String.valueOf(cVar.b.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.f));
            String jSONObject = new JSONObject(hashMap).toString();
            "--埋点--".concat(String.valueOf(jSONObject));
            bj.a();
            if (!TextUtils.isEmpty(jSONObject)) {
                try {
                    br brVar = new br(c, "core", "2.0", "O008");
                    brVar.a(jSONObject);
                    bs.a(brVar, c);
                } catch (k unused) {
                }
            }
        }
    }

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

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

    public static synchronized void a(final String str, boolean z2, final String str2, final String str3, final String str4) {
        synchronized (m.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) {
                                    bi.a(true, str);
                                }
                                cj.a().b(new ck() {
                                    /* class com.loc.m.AnonymousClass1 */

                                    @Override // com.loc.ck
                                    public final void a() {
                                        d dVar = (d) m.v.get(str);
                                        if (dVar != null) {
                                            a aVar = dVar.c;
                                            b a2 = m.a(m.c, dVar.a, dVar.b, str2, str3, str4);
                                            if (a2 != null && aVar != null) {
                                                aVar.a(a2);
                                            }
                                        }
                                    }
                                });
                            }
                        }
                    }
                }
            } catch (Throwable th) {
                ak.a(th, "at", "lca");
            }
        }
    }

    public static void a(String str, boolean z2, boolean z3, boolean z4) {
        if (!TextUtils.isEmpty(str) && c != null) {
            HashMap hashMap = new HashMap();
            hashMap.put("url", str);
            hashMap.put("downLevel", String.valueOf(z2));
            int o2 = o.o(c);
            String str2 = WXInstanceApm.VALUE_ERROR_CODE_DEFAULT;
            hashMap.put("ant", o2 == 0 ? str2 : "1");
            hashMap.put("type", z4 ? z2 ? m : n : z2 ? k : l);
            if (!z3) {
                str2 = "1";
            }
            hashMap.put("status", str2);
            String jSONObject = new JSONObject(hashMap).toString();
            if (!TextUtils.isEmpty(jSONObject)) {
                try {
                    br brVar = new br(c, "core", "2.0", "O002");
                    brVar.a(jSONObject);
                    bs.a(brVar, c);
                } catch (k unused) {
                }
            }
        }
    }

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

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

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

    public static synchronized boolean a(String str) {
        synchronized (m.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) {
                ak.a(th, "at", "cslct");
            }
        }
    }

    public static synchronized boolean a(String str, long j2) {
        synchronized (m.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 boolean a(String str, boolean z2) {
        try {
            if (TextUtils.isEmpty(str)) {
                return z2;
            }
            String[] split = URLDecoder.decode(str).split("/");
            return split[split.length - 1].charAt(4) % 2 == 1;
        } catch (Throwable unused) {
            return z2;
        }
    }

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

    /* 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:0x0146 */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x01b9 A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:99:0x01ba  */
    private static b b(Context context, w wVar, String str, String str2, String str3, String str4) {
        String str5;
        String str6;
        String str7;
        String str8;
        String str9;
        b bVar;
        String str10;
        byte[] bArr;
        bm bmVar;
        String str11;
        String str12;
        byte[] bArr2;
        k e2;
        String str13;
        Context context2;
        IllegalBlockSizeException th;
        Context context3;
        k e3;
        Context context4;
        byte[] bArr3;
        StringBuilder sb;
        b bVar2 = new b();
        bVar2.f = new JSONObject();
        if (context != null) {
            c = context.getApplicationContext();
        }
        e();
        String str14 = null;
        try {
            a(wVar);
            new bg();
            boolean isEmpty = TextUtils.isEmpty(str);
            if (!isEmpty) {
                try {
                    sb = new StringBuilder();
                    str13 = str;
                } catch (k e4) {
                    e3 = e4;
                    str13 = str;
                    str5 = "infocode";
                    str7 = "result";
                    str6 = "ver";
                    bVar = bVar2;
                    str9 = "at";
                    str10 = "lc";
                    try {
                        throw e3;
                    } catch (k e5) {
                        e2 = e5;
                    } catch (IllegalBlockSizeException e6) {
                        th = e6;
                        str8 = str13;
                        bmVar = null;
                        context2 = null;
                        a(context, wVar, th);
                        bArr = context2;
                        if (bArr == null) {
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        str8 = str13;
                        bmVar = null;
                        context3 = null;
                        an.b(th, str9, str10);
                        context2 = context3;
                        a(context, wVar, th);
                        bArr = context2;
                        if (bArr == null) {
                        }
                    }
                } catch (Throwable unused) {
                    str13 = str;
                    str8 = str13;
                    str5 = "infocode";
                    str7 = "result";
                    str6 = "ver";
                    bVar = bVar2;
                    str9 = "at";
                    str10 = "lc";
                    try {
                        throw new k(AMapException.ERROR_UNKNOWN);
                    } catch (k e7) {
                        e2 = e7;
                        bmVar = null;
                        bArr2 = null;
                        bVar.c = e2.a();
                        a(context, wVar, e2.a());
                        an.a(wVar, "/v3/iasdkauth", e2);
                        bArr = bArr2;
                        if (bArr == null) {
                        }
                    } catch (IllegalBlockSizeException e8) {
                        th = e8;
                        bmVar = null;
                        context2 = null;
                        a(context, wVar, th);
                        bArr = context2;
                        if (bArr == null) {
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        bmVar = null;
                        context3 = null;
                        an.b(th, str9, str10);
                        context2 = context3;
                        a(context, wVar, th);
                        bArr = context2;
                        if (bArr == null) {
                        }
                    }
                }
                try {
                    sb.append(str13);
                    sb.append(";15K;16H;17I;17S;183");
                    str8 = sb.toString();
                } catch (k e9) {
                    e3 = e9;
                    str5 = "infocode";
                    str7 = "result";
                    str6 = "ver";
                    bVar = bVar2;
                    str9 = "at";
                    str10 = "lc";
                    throw e3;
                } catch (Throwable unused2) {
                    str8 = str13;
                    str5 = "infocode";
                    str7 = "result";
                    str6 = "ver";
                    bVar = bVar2;
                    str9 = "at";
                    str10 = "lc";
                    throw new k(AMapException.ERROR_UNKNOWN);
                }
            } else {
                str8 = str;
            }
            try {
                d(context);
                context4 = context;
                str7 = "result";
                bVar = bVar2;
                str6 = "ver";
                str9 = "at";
                str5 = "infocode";
                str10 = "lc";
            } catch (k e10) {
                e3 = e10;
                str5 = "infocode";
                str7 = "result";
                str6 = "ver";
                bVar = bVar2;
                str9 = "at";
                str10 = "lc";
                str13 = str8;
                throw e3;
            } catch (Throwable unused3) {
                str5 = "infocode";
                str7 = "result";
                str6 = "ver";
                bVar = bVar2;
                str9 = "at";
                str10 = "lc";
                throw new k(AMapException.ERROR_UNKNOWN);
            }
            try {
                bmVar = bg.a(new c(context4, wVar, str8, str2, str3, str4));
                if (isEmpty) {
                    return bVar;
                }
                if (bmVar != null) {
                    try {
                        byte[] bArr4 = bmVar.a;
                        try {
                            Map<String, List<String>> map = bmVar.b;
                            bArr3 = bArr4;
                            if (map != null) {
                                bArr3 = bArr4;
                                if (map.containsKey("lct")) {
                                    List<String> list = map.get("lct");
                                    bArr3 = bArr4;
                                    if (list != null) {
                                        bArr3 = bArr4;
                                        if (list.size() > 0) {
                                            String str15 = list.get(0);
                                            bArr3 = bArr4;
                                            if (!TextUtils.isEmpty(str15)) {
                                                bVar.e = Long.valueOf(str15).longValue();
                                                bArr3 = bArr4;
                                                if (wVar != null) {
                                                    bArr3 = bArr4;
                                                    if (bVar.e != 0) {
                                                        String a2 = wVar.a();
                                                        bArr3 = bArr4;
                                                        if (!TextUtils.isEmpty(a2)) {
                                                            b(a2, bVar.e);
                                                            bArr3 = bArr4;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        } catch (Throwable th4) {
                            try {
                                an.b(th4, str9, "lct");
                                bArr3 = bArr4;
                            } catch (k e11) {
                                e2 = e11;
                                bArr2 = context4;
                                bVar.c = e2.a();
                                a(context, wVar, e2.a());
                                an.a(wVar, "/v3/iasdkauth", e2);
                                bArr = bArr2;
                                if (bArr == null) {
                                }
                            } catch (IllegalBlockSizeException e12) {
                                th = e12;
                                context2 = context4;
                                a(context, wVar, th);
                                bArr = context2;
                                if (bArr == null) {
                                }
                            } catch (Throwable th5) {
                                th = th5;
                                context3 = context4;
                                an.b(th, str9, str10);
                                context2 = context3;
                                a(context, wVar, th);
                                bArr = context2;
                                if (bArr == null) {
                                }
                            }
                        }
                    } catch (k e13) {
                        e2 = e13;
                        bArr2 = null;
                        bVar.c = e2.a();
                        a(context, wVar, e2.a());
                        an.a(wVar, "/v3/iasdkauth", e2);
                        bArr = bArr2;
                        if (bArr == null) {
                        }
                    } catch (IllegalBlockSizeException e14) {
                        th = e14;
                        context2 = null;
                        a(context, wVar, th);
                        bArr = context2;
                        if (bArr == null) {
                        }
                    } catch (Throwable th6) {
                        th = th6;
                        context3 = null;
                        an.b(th, str9, str10);
                        context2 = context3;
                        a(context, wVar, th);
                        bArr = context2;
                        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, x.c("EQUVT"));
                Cipher instance = Cipher.getInstance(x.c("CQUVTL0NCQy9QS0NTNVBhZGRpbmc"));
                instance.init(2, secretKeySpec, new IvParameterSpec(x.c()));
                str14 = x.a(instance.doFinal(bArr6));
                bArr = bArr3;
                if (bArr == null) {
                    return bVar;
                }
                if (TextUtils.isEmpty(str14)) {
                    str14 = x.a(bArr);
                }
                if (TextUtils.isEmpty(str14)) {
                    a(context, wVar, "result is null");
                }
                try {
                    JSONObject jSONObject = new JSONObject(str14);
                    if (jSONObject.has("status")) {
                        int i2 = jSONObject.getInt("status");
                        if (i2 == 1) {
                            a = 1;
                        } else if (i2 == 0) {
                            if (bmVar != null) {
                                str11 = bmVar.c;
                                str12 = bmVar.d;
                            } else {
                                str11 = "authcsid";
                                str12 = "authgsid";
                            }
                            x.a(context, str11, str12, jSONObject);
                            a = 0;
                            if (jSONObject.has("info")) {
                                b = jSONObject.getString("info");
                            }
                            String str16 = "";
                            if (jSONObject.has(str5)) {
                                str16 = jSONObject.getString(str5);
                            }
                            an.a(wVar, "/v3/iasdkauth", b, str12, str11, str16);
                            if (a == 0) {
                                bVar.c = b;
                                return bVar;
                            }
                        }
                        try {
                            if (jSONObject.has(str6)) {
                                bVar.d = jSONObject.getInt(str6);
                            }
                        } catch (Throwable th7) {
                            ak.a(th7, str9, str10);
                        }
                        if (x.a(jSONObject, str7)) {
                            JSONObject jSONObject2 = jSONObject.getJSONObject(str7);
                            a(context, wVar, str8, bVar, jSONObject2);
                            try {
                                JSONObject jSONObject3 = jSONObject2.getJSONObject("15K");
                                boolean a3 = a(jSONObject3.optString("isTargetAble"), false);
                                if (!a(jSONObject3.optString("able"), false)) {
                                    q.a();
                                    q.b(context);
                                } else {
                                    q.a().a(context, a3);
                                }
                            } catch (Throwable unused4) {
                            }
                        }
                    }
                } catch (Throwable th8) {
                    ak.a(th8, str9, str10);
                }
                return bVar;
            } catch (k e15) {
                e3 = e15;
                str13 = str8;
                throw e3;
            } catch (Throwable unknown) {
                throw new k(AMapException.ERROR_UNKNOWN);
            }
        } catch (k e16) {
            e2 = e16;
            str13 = str;
            str5 = "infocode";
            str7 = "result";
            str6 = "ver";
            bVar = bVar2;
            str9 = "at";
            str10 = "lc";
            str8 = str13;
            bmVar = null;
            bArr2 = null;
            bVar.c = e2.a();
            a(context, wVar, e2.a());
            an.a(wVar, "/v3/iasdkauth", e2);
            bArr = bArr2;
            if (bArr == null) {
            }
        } catch (IllegalBlockSizeException e17) {
            th = e17;
            str13 = str;
            str5 = "infocode";
            str7 = "result";
            str6 = "ver";
            bVar = bVar2;
            str9 = "at";
            str10 = "lc";
            str8 = str13;
            bmVar = null;
            context2 = null;
            a(context, wVar, th);
            bArr = context2;
            if (bArr == null) {
            }
        } catch (Throwable th9) {
            th = th9;
            str13 = str;
            str5 = "infocode";
            str7 = "result";
            str6 = "ver";
            bVar = bVar2;
            str9 = "at";
            str10 = "lc";
            str8 = str13;
            bmVar = null;
            context3 = null;
            an.b(th, str9, str10);
            context2 = context3;
            a(context, wVar, th);
            bArr = context2;
            if (bArr == null) {
            }
        }
    }

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

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

    public static void b(bj.c cVar) {
        synchronized (B) {
            boolean z2 = false;
            for (int i2 = 0; i2 < B.size(); i2++) {
                bj.a aVar = B.get(i2);
                if (cVar.c.equals(aVar.b) && cVar.d.equals(aVar.e) && cVar.m == aVar.f) {
                    if (aVar.f == 1) {
                        aVar.i = ((((long) aVar.j.get()) * aVar.i) + cVar.f) / ((long) (aVar.j.get() + 1));
                    }
                    aVar.j.getAndIncrement();
                    z2 = true;
                }
            }
            if (!z2) {
                B.add(new bj.a(cVar));
            }
            bj.a();
        }
    }

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

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

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

    public static boolean b() {
        Integer num;
        Context context = c;
        if (context == null) {
            return false;
        }
        String t2 = o.t(context);
        return !TextUtils.isEmpty(t2) && (num = q.get(t2.toUpperCase())) != null && num.intValue() == 2;
    }

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

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

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

    public static boolean c() {
        Integer num;
        Context context = c;
        if (context == null) {
            return false;
        }
        String t2 = o.t(context);
        return !TextUtils.isEmpty(t2) && (num = q.get(t2.toUpperCase())) != null && num.intValue() >= 2;
    }

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

    private static void d(Context context) {
        try {
            if (!w) {
                ag.d = av.a(context, "open_common", "a4", true);
                ag.e = av.a(context, "open_common", "a5", true);
                w = true;
            }
        } catch (Throwable unused) {
        }
    }

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

    public static void e() {
        if (!d) {
            try {
                Context context = c;
                if (context != null) {
                    d = true;
                    q.a().a(context);
                    b(context);
                    c(context);
                    f.a = av.a(context, "open_common", "ucf", f.a);
                    f.b = av.a(context, "open_common", "fsv2", f.b);
                    f.c = av.a(context, "open_common", "usc", f.c);
                    f.d = av.a(context, "open_common", "umv", f.d);
                    f.e = av.a(context, "open_common", "ust", f.e);
                    f.f = av.a(context, "open_common", "ustv", f.f);
                }
            } 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 = c;
            return context == null || (a2 = a(context, b(str, "a15"), "open_common")) == null || a2.a() < y;
        } catch (Throwable unused) {
        }
    }

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

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

    private static void i() {
        Map<String, Integer> map;
        String str;
        Integer valueOf;
        try {
            Context context = c;
            if (context != null) {
                String t2 = o.t(context);
                if (!TextUtils.isEmpty(r) && !TextUtils.isEmpty(t2) && r.equals(t2) && System.currentTimeMillis() - s < 60000) {
                    return;
                }
                if (!TextUtils.isEmpty(t2)) {
                    r = t2;
                }
            } else if (System.currentTimeMillis() - s < 10000) {
                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(x.c("FMTkyLjE2OC40My4"))) {
                                i2 |= 1;
                            }
                        }
                    }
                    if (i2 != 0) {
                        if (displayName != null && displayName.startsWith("wlan")) {
                            map = q;
                            str = "WIFI";
                            valueOf = Integer.valueOf(i2);
                        } else if (displayName != null && displayName.startsWith("rmnet")) {
                            map = q;
                            str = "MOBILE";
                            valueOf = Integer.valueOf(i2);
                        }
                        map.put(str, valueOf);
                    }
                }
            }
        } catch (Throwable th) {
            ak.a(th, "at", "ipstack");
        }
    }
}