同程有借 v1.0.0版本的 MD5 值为:e33397cdbab33543d0c134ec96d77fb8

以下内容为反编译后的 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 androidx.core.app.NotificationCompat;
import com.bonree.sdk.agent.engine.external.Instrumented;
import com.bonree.sdk.agent.engine.external.JSONObjectInstrumentation;
import com.loc.br;
import com.loc.bt;
import com.moture.lib.core.utils.date.DateTimeUtils;
import com.moture.lib.core.utils.date.DateTools;
import com.plugin.location.request.MoLocationOption;
import com.taobao.accs.common.Constants;
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.Objects;
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;
@Instrumented
public final class m {
    private static volatile boolean D = false;
    public static int f10147a = -1;
    public static String f10148b = "";
    public static Context f10149c = null;
    private static String f10157k = "6";
    private static String f10158l = "4";
    private static String f10159m = "9";
    private static String f10160n = "8";
    private static volatile boolean f10161o = true;
    private static Vector<e> f10162p = new Vector<>();
    private static Map<String, Integer> f10163q = new HashMap();
    private static String f10164r = null;
    private static long f10165s = 0;
    public static volatile boolean f10150d = false;
    private static volatile ConcurrentHashMap<String, g> f10166t = new ConcurrentHashMap<>(8);
    private static volatile ConcurrentHashMap<String, Long> f10167u = new ConcurrentHashMap<>(8);
    private static volatile ConcurrentHashMap<String, d> f10168v = new ConcurrentHashMap<>(8);
    private static boolean f10169w = false;
    private static boolean f10170x = false;
    public static int f10151e = 5000;
    public static boolean f10152f = true;
    public static boolean f10153g = false;
    private static int f10171y = 3;
    public static boolean f10154h = true;
    public static boolean f10155i = false;
    private static int f10172z = 3;
    public static boolean f10156j = false;
    private static ConcurrentHashMap<String, Boolean> A = new ConcurrentHashMap<>();
    private static ConcurrentHashMap<String, Boolean> B = new ConcurrentHashMap<>();
    private static ArrayList<br.a> C = new ArrayList<>();
    private static Queue<br.c> E = new LinkedList();

    public interface a {
        void a(b bVar);
    }

    public static class b {
        @Deprecated
        public JSONObject f10177a;
        @Deprecated
        public JSONObject f10178b;
        public String f10179c;
        public int f10180d = -1;
        public long f10181e = 0;
        public JSONObject f10182f;
        public a f10183g;
        public C0097b f10184h;
        private boolean f10185i;

        public static class a {
            public boolean f10186a;
            public boolean f10187b;
            public JSONObject f10188c;
        }

        public static class C0097b {
            public boolean f10189a;
        }
    }

    public static class c extends bp {
        private String f10190d;
        private Map<String, String> f10191e;
        private String f10192f;
        private String f10193g;
        private String f10194h;

        c(Context context, w wVar, String str, String str2, String str3, String str4) {
            super(context, wVar);
            this.f10190d = str;
            this.f10191e = null;
            this.f10192f = str2;
            this.f10193g = str3;
            this.f10194h = str4;
            a(bt.c.HTTPS);
            a(bt.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
        public final Map<String, String> a() {
            if (TextUtils.isEmpty(this.f10194h)) {
                return null;
            }
            HashMap hashMap = new HashMap();
            hashMap.put(Constants.KEY_HOST, this.f10194h);
            return hashMap;
        }

        @Override
        public final byte[] a_() {
            return null;
        }

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

        @Override
        public final byte[] b_() {
            String t9 = o.t(((bp) this).f9245a);
            if (!TextUtils.isEmpty(t9)) {
                t9 = s.a(new StringBuilder(t9).reverse().toString());
            }
            HashMap hashMap = new HashMap();
            hashMap.put("authkey", TextUtils.isEmpty(this.f10190d) ? "" : this.f10190d);
            hashMap.put("plattype", "android");
            hashMap.put("ccver", "1");
            hashMap.put("product", ((bp) this).f9246b.a());
            hashMap.put("version", ((bp) this).f9246b.b());
            hashMap.put("output", "json");
            StringBuilder sb = new StringBuilder();
            sb.append(Build.VERSION.SDK_INT);
            hashMap.put("androidversion", sb.toString());
            hashMap.put("deviceId", t9);
            hashMap.put("manufacture", Build.MANUFACTURER);
            Map<String, String> map = this.f10191e;
            if (map != null && !map.isEmpty()) {
                hashMap.putAll(this.f10191e);
            }
            hashMap.put("abitype", x.a(((bp) this).f9245a));
            hashMap.put("ext", ((bp) this).f9246b.d());
            return x.a(x.a(hashMap));
        }

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

        @Override
        protected final String f() {
            return "3.0";
        }

        @Override
        public final String g() {
            return !TextUtils.isEmpty(this.f10194h) ? this.f10194h : super.g();
        }
    }

    public static class d {
        w f10195a;
        String f10196b;
        a f10197c;

        private d() {
        }

        d(byte b9) {
            this();
        }
    }

    @Instrumented
    public static class e {
        private String f10198a;
        private String f10199b;
        private AtomicInteger f10200c;

        public e(String str, String str2, int i9) {
            this.f10198a = str;
            this.f10199b = str2;
            this.f10200c = new AtomicInteger(i9);
        }

        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(at.f9146i), jSONObject.optInt("h"));
            } catch (Throwable unused) {
                return null;
            }
        }

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

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

        public final String b() {
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("a", this.f10198a);
                jSONObject.put(at.f9146i, this.f10199b);
                jSONObject.put("h", this.f10200c.get());
                return JSONObjectInstrumentation.toString(jSONObject);
            } catch (Throwable unused) {
                return "";
            }
        }
    }

    public static class f {
        public static boolean f10201a = true;
        public static boolean f10202b = false;
        public static boolean f10203c = true;
        public static int f10204d = 0;
        public static boolean f10205e = false;
        public static int f10206f;
    }

    public static class g {
        public long f10207a;
        public String f10208b;

        g(Long l9, String str) {
            this.f10207a = 0L;
            this.f10208b = "";
            this.f10207a = l9.longValue();
            this.f10208b = str;
        }
    }

    public static long a(List<String> list) {
        if (list != null) {
            try {
                if (list.size() > 0) {
                    String str = list.get(0);
                    if (TextUtils.isEmpty(str)) {
                        return 0L;
                    }
                    return Long.valueOf(str).longValue();
                }
                return 0L;
            } catch (Exception e9) {
                e9.printStackTrace();
                return 0L;
            }
        }
        return 0L;
    }

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

    private static synchronized e a(Context context, String str, String str2) {
        e eVar;
        synchronized (m.class) {
            if (!TextUtils.isEmpty(str)) {
                for (int i9 = 0; i9 < f10162p.size(); i9++) {
                    eVar = f10162p.get(i9);
                    if (eVar != null && str.equals(eVar.f10198a)) {
                        break;
                    }
                }
            }
            eVar = null;
            if (eVar != null) {
                return eVar;
            }
            if (context == null) {
                return null;
            }
            e b9 = e.b(bd.b(context, str2, str, ""));
            String a9 = x.a(System.currentTimeMillis(), DateTools.YYYYMMDD);
            if (b9 == null) {
                b9 = new e(str, a9, 0);
            }
            if (!a9.equals(b9.f10199b)) {
                b9.a(a9);
                b9.f10200c.set(0);
            }
            f10162p.add(b9);
            return b9;
        }
    }

    public static String a(String str) {
        d dVar;
        if (!f10168v.containsKey(str) || (dVar = f10168v.get(str)) == null) {
            return null;
        }
        return dVar.f10196b;
    }

    public static void a(Context context) {
        if (context != null) {
            f10149c = 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 jSONObjectInstrumentation = JSONObjectInstrumentation.toString(new JSONObject(hashMap));
        if (TextUtils.isEmpty(jSONObjectInstrumentation)) {
            return;
        }
        try {
            bz bzVar = new bz(context, "core", "2.0", "O001");
            bzVar.a(jSONObjectInstrumentation);
            ca.a(bzVar, 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) {
                return;
            }
            try {
                if (f10149c == null) {
                    f10149c = context.getApplicationContext();
                }
                String a9 = wVar.a();
                if (TextUtils.isEmpty(a9)) {
                    return;
                }
                a(wVar);
                if (f10168v == null) {
                    f10168v = new ConcurrentHashMap<>(8);
                }
                if (f10167u == null) {
                    f10167u = new ConcurrentHashMap<>(8);
                }
                if (f10166t == null) {
                    f10166t = new ConcurrentHashMap<>(8);
                }
                if (!f10168v.containsKey(a9)) {
                    d dVar = new d((byte) 0);
                    dVar.f10195a = wVar;
                    dVar.f10196b = str;
                    dVar.f10197c = aVar;
                    f10168v.put(a9, dVar);
                    long a10 = bd.a(f10149c, "open_common", a9, 0L);
                    Context context2 = f10149c;
                    f10166t.put(a9, new g(Long.valueOf(a10), bd.b(context2, "open_common", a9 + "lct-info", "")));
                    d(f10149c);
                    e(f10149c);
                }
            } catch (Throwable th) {
                as.a(th, "at", "rglc");
            }
        }
    }

    private static void a(Context context, w wVar, String str, b bVar, JSONObject jSONObject) throws JSONException {
        String str2;
        String str3;
        JSONObject jSONObject2;
        boolean a9;
        Context context2;
        JSONObject jSONObject3;
        b.a aVar = new b.a();
        aVar.f10186a = false;
        aVar.f10187b = false;
        bVar.f10183g = aVar;
        try {
            String[] split = str.split(";");
            if (split != null && split.length > 0) {
                for (String str4 : split) {
                    if (jSONObject.has(str4)) {
                        bVar.f10182f.putOpt(str4, jSONObject.get(str4));
                    }
                }
            }
        } catch (Throwable th) {
            as.a(th, "at", "co");
        }
        if (x.a(jSONObject, "16H")) {
            try {
                bVar.f10185i = a(jSONObject.getJSONObject("16H").optString("able"), false);
            } catch (Throwable th2) {
                as.a(th2, "AuthConfigManager", "load 16H");
            }
        }
        if (x.a(jSONObject, "11K")) {
            try {
                JSONObject jSONObject4 = jSONObject.getJSONObject("11K");
                aVar.f10186a = a(jSONObject4.getString("able"), false);
                if (jSONObject4.has("off")) {
                    aVar.f10188c = jSONObject4.getJSONObject("off");
                }
            } catch (Throwable th3) {
                as.a(th3, "AuthConfigManager", "load 11K");
            }
        }
        if (x.a(jSONObject, "145")) {
            try {
                bVar.f10177a = jSONObject.getJSONObject("145");
            } catch (Throwable th4) {
                as.a(th4, "AuthConfigManager", "load 145");
            }
        }
        if (x.a(jSONObject, "14D")) {
            try {
                bVar.f10178b = jSONObject.getJSONObject("14D");
            } catch (Throwable th5) {
                as.a(th5, "AuthConfigManager", "load 14D");
            }
        }
        if (x.a(jSONObject, "151")) {
            try {
                JSONObject jSONObject5 = jSONObject.getJSONObject("151");
                b.C0097b c0097b = new b.C0097b();
                if (jSONObject5 != null) {
                    c0097b.f10189a = a(jSONObject5.optString("able"), false);
                }
                bVar.f10184h = c0097b;
            } catch (Throwable th6) {
                as.a(th6, "AuthConfigManager", "load 151");
            }
        }
        if (x.a(jSONObject, "17S")) {
            try {
                jSONObject2 = jSONObject.getJSONObject("17S");
                if (jSONObject2 != null && (a9 = a(jSONObject2.optString("able"), false)) != f10161o) {
                    f10161o = a9;
                    if (context != null) {
                        SharedPreferences.Editor a10 = bd.a(context, "open_common");
                        bd.a(a10, "a2", a9);
                        bd.a(a10);
                    }
                }
            } catch (Throwable th7) {
                th = th7;
                str2 = "ust";
            }
            if (jSONObject2 != null) {
                boolean a11 = a(jSONObject2.optString("static_enable"), true);
                boolean a12 = a(jSONObject2.optString("static_ip_direct_enable"), false);
                int optInt = jSONObject2.optInt("static_timeout", 5) * 1000;
                int optInt2 = jSONObject2.optInt("static_retry", 3);
                boolean a13 = a(jSONObject2.optString("bgp_enable"), true);
                str2 = "ust";
                try {
                    boolean a14 = a(jSONObject2.optString("bgp_ip_direct_enable"), false);
                    str3 = "umv";
                    try {
                        int optInt3 = jSONObject2.optInt("bgp_retry", 3);
                        boolean a15 = a(jSONObject2.optString("perf_data_upload_enable"), false);
                        if (a11 != f10152f || a12 != f10153g || optInt != f10151e || optInt2 != f10171y || a13 != f10154h || a14 != f10155i || optInt3 != f10172z || a15 != f10156j) {
                            f10152f = a11;
                            f10153g = a12;
                            f10151e = optInt;
                            f10171y = optInt2;
                            f10154h = a13;
                            f10155i = a14;
                            f10172z = optInt3;
                            f10156j = a15;
                            if (context != null) {
                                SharedPreferences.Editor a16 = bd.a(context, "open_common");
                                bd.a(a16, "a13", a11);
                                bd.a(a16, "a6", a13);
                                bd.a(a16, "a7", a12);
                                bd.a(a16, "a8", optInt);
                                bd.a(a16, "a9", optInt2);
                                bd.a(a16, "a10", a14);
                                bd.a(a16, "a11", optInt3);
                                bd.a(a16, "a12", a15);
                                bd.a(a16);
                            }
                        }
                        br.a();
                        br.a();
                        br.a();
                        br.a();
                        br.a();
                    } catch (Throwable th8) {
                        th = th8;
                        as.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, "1A4")) {
                        }
                    }
                } catch (Throwable th9) {
                    th = th9;
                    str3 = "umv";
                    as.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, "1A4")) {
                    }
                }
                if (x.a(jSONObject, "15K")) {
                    try {
                        jSONObject3 = jSONObject.getJSONObject("15K");
                    } catch (Throwable th10) {
                        context2 = context;
                        as.a(th10, "AuthConfigManager", "load 15K");
                    }
                    if (jSONObject3 != null) {
                        boolean a17 = a(jSONObject3.optString("ucf"), f.f10201a);
                        boolean a18 = a(jSONObject3.optString("fsv2"), f.f10202b);
                        boolean a19 = a(jSONObject3.optString("usc"), f.f10203c);
                        String str5 = str3;
                        int optInt4 = jSONObject3.optInt(str5, f.f10204d);
                        String str6 = str2;
                        boolean a20 = a(jSONObject3.optString(str6), f.f10205e);
                        int optInt5 = jSONObject3.optInt("ustv", f.f10206f);
                        if (a17 != f.f10201a || a18 != f.f10202b || a19 != f.f10203c || optInt4 != f.f10204d || a20 != f.f10205e || optInt5 != f.f10204d) {
                            f.f10201a = a17;
                            f.f10202b = a18;
                            f.f10203c = a19;
                            f.f10204d = optInt4;
                            f.f10205e = a20;
                            f.f10206f = optInt5;
                            context2 = context;
                            try {
                                SharedPreferences.Editor a21 = bd.a(context2, "open_common");
                                bd.a(a21, "ucf", f.f10201a);
                                bd.a(a21, "fsv2", f.f10202b);
                                bd.a(a21, "usc", f.f10203c);
                                bd.a(a21, str5, f.f10204d);
                                bd.a(a21, str6, f.f10205e);
                                bd.a(a21, "ustv", f.f10206f);
                                bd.a(a21);
                            } catch (Throwable unused) {
                            }
                            if (x.a(jSONObject, "183")) {
                                try {
                                    bq.a(wVar, jSONObject.getJSONObject("183"));
                                } catch (Throwable th11) {
                                    as.a(th11, "AuthConfigManager", "load 183");
                                }
                            }
                            if (x.a(jSONObject, "17I")) {
                                try {
                                    JSONObject jSONObject6 = jSONObject.getJSONObject("17I");
                                    boolean a22 = a(jSONObject6.optString("na"), false);
                                    boolean a23 = a(jSONObject6.optString("aa"), false);
                                    ag.f9068d = a22;
                                    ag.f9069e = a23;
                                    SharedPreferences.Editor a24 = bd.a(context2, "open_common");
                                    bd.a(a24, "a4", a22);
                                    bd.a(a24, "a5", a23);
                                    bd.a(a24);
                                } catch (Throwable th12) {
                                    as.a(th12, "AuthConfigManager", "load 17I");
                                }
                            }
                            if (x.a(jSONObject, "1A4")) {
                                try {
                                    JSONObject jSONObject7 = jSONObject.getJSONObject("1A4");
                                    String optString = jSONObject7.optString("ada");
                                    boolean a25 = a(optString, z.f10367c);
                                    long optLong = jSONObject7.optLong("iv", z.f10365a);
                                    z.f10368d = a25;
                                    z.f10366b = optLong;
                                    SharedPreferences.Editor a26 = bd.a(context2, "open_common");
                                    bd.a(a26, "a16", optString);
                                    bd.a(a26, "a17", optLong);
                                    bd.a(a26);
                                    return;
                                } catch (Throwable th13) {
                                    as.a(th13, "AuthConfigManager", "load 1A4");
                                    return;
                                }
                            }
                            return;
                        }
                    }
                }
                context2 = context;
                if (x.a(jSONObject, "183")) {
                }
                if (x.a(jSONObject, "17I")) {
                }
                if (x.a(jSONObject, "1A4")) {
                }
            }
        }
        str2 = "ust";
        str3 = "umv";
        if (x.a(jSONObject, "15K")) {
        }
        context2 = context;
        if (x.a(jSONObject, "183")) {
        }
        if (x.a(jSONObject, "17I")) {
        }
        if (x.a(jSONObject, "1A4")) {
        }
    }

    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.f10198a)) {
            return;
        }
        String b9 = eVar.b();
        if (TextUtils.isEmpty(b9) || context == null) {
            return;
        }
        SharedPreferences.Editor a9 = bd.a(context, str2);
        a9.putString(str, b9);
        bd.a(a9);
    }

    public static void a(br.c cVar) {
        if (cVar == null || f10149c == null) {
            return;
        }
        HashMap hashMap = new HashMap();
        hashMap.put("serverip", cVar.f9296c);
        hashMap.put("hostname", cVar.f9298e);
        hashMap.put("path", cVar.f9297d);
        hashMap.put("csid", cVar.f9294a);
        hashMap.put("degrade", String.valueOf(cVar.f9295b.a()));
        hashMap.put("errorcode", String.valueOf(cVar.f9306m));
        hashMap.put("errorsubcode", String.valueOf(cVar.f9307n));
        hashMap.put("connecttime", String.valueOf(cVar.f9301h));
        hashMap.put("writetime", String.valueOf(cVar.f9302i));
        hashMap.put("readtime", String.valueOf(cVar.f9303j));
        hashMap.put("datasize", String.valueOf(cVar.f9305l));
        hashMap.put("totaltime", String.valueOf(cVar.f9299f));
        String jSONObjectInstrumentation = JSONObjectInstrumentation.toString(new JSONObject(hashMap));
        "--埋点--".concat(String.valueOf(jSONObjectInstrumentation));
        br.a();
        if (TextUtils.isEmpty(jSONObjectInstrumentation)) {
            return;
        }
        try {
            bz bzVar = new bz(f10149c, "core", "2.0", "O008");
            bzVar.a(jSONObjectInstrumentation);
            ca.a(bzVar, f10149c);
        } catch (k unused) {
        }
    }

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

    private static synchronized void a(String str, long j9, String str2) {
        synchronized (m.class) {
            try {
                if (f10168v != null && f10168v.containsKey(str)) {
                    if (f10166t == null) {
                        f10166t = new ConcurrentHashMap<>(8);
                    }
                    f10166t.put(str, new g(Long.valueOf(j9), str2));
                    Context context = f10149c;
                    if (context != null) {
                        SharedPreferences.Editor a9 = bd.a(context, "open_common");
                        bd.a(a9, str, j9);
                        bd.a(a9, str + "lct-info", str2);
                        bd.a(a9);
                    }
                }
            } catch (Throwable th) {
                as.a(th, "at", "ucut");
            }
        }
    }

    private static void a(String str, String str2) {
        e a9 = a(f10149c, str, str2);
        String a10 = x.a(System.currentTimeMillis(), DateTools.YYYYMMDD);
        if (!a10.equals(a9.f10199b)) {
            a9.a(a10);
            a9.f10200c.set(0);
        }
        a9.f10200c.incrementAndGet();
        a(f10149c, str, str2, a9);
    }

    public static synchronized void a(final String str, boolean z8, final String str2, final String str3, final String str4) {
        synchronized (m.class) {
            try {
                if (TextUtils.isEmpty(str)) {
                    return;
                }
                if (f10167u == null) {
                    f10167u = new ConcurrentHashMap<>(8);
                }
                f10167u.put(str, Long.valueOf(SystemClock.elapsedRealtime()));
                if (f10168v == null) {
                    return;
                }
                if (f10168v.containsKey(str)) {
                    if (TextUtils.isEmpty(str)) {
                        return;
                    }
                    if (z8) {
                        bq.a(true, str);
                    }
                    cr.a().b(new cs() {
                        @Override
                        public final void a() {
                            d dVar = (d) m.f10168v.get(str);
                            if (dVar == null) {
                                return;
                            }
                            a aVar = dVar.f10197c;
                            b a9 = m.a(m.f10149c, dVar.f10195a, dVar.f10196b, str2, str3, str4);
                            if (a9 == null || aVar == null) {
                                return;
                            }
                            aVar.a(a9);
                        }
                    });
                }
            } catch (Throwable th) {
                as.a(th, "at", "lca");
            }
        }
    }

    public static void a(String str, boolean z8, boolean z9, boolean z10) {
        if (TextUtils.isEmpty(str) || f10149c == null) {
            return;
        }
        HashMap hashMap = new HashMap();
        hashMap.put("url", str);
        hashMap.put("downLevel", String.valueOf(z8));
        hashMap.put("ant", o.n(f10149c) == 0 ? "0" : "1");
        hashMap.put("type", z10 ? z8 ? f10159m : f10160n : z8 ? f10157k : f10158l);
        hashMap.put(NotificationCompat.CATEGORY_STATUS, z9 ? "0" : "1");
        String jSONObjectInstrumentation = JSONObjectInstrumentation.toString(new JSONObject(hashMap));
        if (TextUtils.isEmpty(jSONObjectInstrumentation)) {
            return;
        }
        try {
            bz bzVar = new bz(f10149c, "core", "2.0", "O002");
            bzVar.a(jSONObjectInstrumentation);
            ca.a(bzVar, f10149c);
        } catch (k unused) {
        }
    }

    public static void a(boolean z8, br.a aVar) {
        if (!D || aVar == null) {
            return;
        }
        synchronized (C) {
            if (z8) {
                Iterator<br.a> it = C.iterator();
                while (it.hasNext()) {
                    br.a next = it.next();
                    if (next.f9283b.equals(aVar.f9283b) && next.f9286e.equals(aVar.f9286e) && next.f9287f == aVar.f9287f) {
                        if (next.f9291j == aVar.f9291j) {
                            it.remove();
                        } else {
                            next.f9291j.set(next.f9291j.get() - aVar.f9291j.get());
                        }
                        br.a();
                    }
                }
            }
            D = false;
            Iterator<br.a> it2 = C.iterator();
            while (true) {
                br.a();
                if (it2.hasNext()) {
                    br.a next2 = it2.next();
                    String str = next2.f9286e;
                    Objects.toString(next2.f9291j);
                } else {
                    br.a();
                }
            }
        }
    }

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

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

    public static synchronized boolean a(String str, long j9) {
        synchronized (m.class) {
            boolean z8 = false;
            if (TextUtils.isEmpty(str)) {
                return false;
            }
            g f9 = f(str);
            long j10 = 0;
            if (j9 != (f9 != null ? f9.f10207a : 0L)) {
                if (f10167u != null && f10167u.containsKey(str)) {
                    j10 = f10167u.get(str).longValue();
                }
                if (SystemClock.elapsedRealtime() - j10 > MoLocationOption.LOC_DELAY_TIME) {
                    z8 = true;
                }
            }
            return z8;
        }
    }

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

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

    private static b b(Context context, w wVar, String str, String str2, String str3, String str4) {
        String str5;
        String str6;
        String str7;
        String str8;
        bu buVar;
        byte[] bArr;
        b bVar;
        String str9;
        String str10;
        boolean isEmpty;
        String str11 = "infocode";
        b bVar2 = "result";
        String str12 = "ver";
        b bVar3 = new b();
        bVar3.f10182f = new JSONObject();
        if (context != null) {
            f10149c = context.getApplicationContext();
        }
        e();
        String str13 = null;
        try {
            a(wVar);
            new bo();
            isEmpty = TextUtils.isEmpty(str);
            try {
                if (isEmpty) {
                    str8 = str;
                } else {
                    try {
                        str8 = c(str);
                    } catch (k e9) {
                        e = e9;
                        throw e;
                    } catch (Throwable unused) {
                        throw new k("未知的错误");
                    }
                }
                try {
                    d(context);
                    e(context);
                    str6 = "result";
                    bVar2 = bVar3;
                    str7 = "ver";
                    str12 = "at";
                    str5 = "infocode";
                    str11 = "lc";
                    try {
                        buVar = bo.a(new c(context, wVar, str8, str2, str3, str4));
                    } catch (k e10) {
                        throw e10;
                    } catch (Throwable unused2) {
                        throw new k("未知的错误");
                    }
                } catch (k e11) {
                    e = e11;
                    throw e;
                } catch (Throwable unused3) {
                    throw new k("未知的错误");
                }
            } catch (k e12) {
                e = e12;
                buVar = null;
                bArr = null;
                bVar2.f10179c = e.a();
                a(context, wVar, e.a());
                av.a(wVar, "/v3/iasdkauth", e);
                bVar = bVar2;
                String str14 = str8;
                if (bArr != null) {
                }
            } catch (IllegalBlockSizeException e13) {
                e = e13;
                buVar = null;
                bArr = null;
                a(context, wVar, e);
                bVar = bVar2;
                String str142 = str8;
                if (bArr != null) {
                }
            } catch (Throwable th) {
                e = th;
                buVar = null;
                bArr = null;
                av.b(e, str12, str11);
                a(context, wVar, e);
                bVar = bVar2;
                String str1422 = str8;
                if (bArr != null) {
                }
            }
        } catch (k e14) {
            e = e14;
            str5 = "infocode";
            str6 = "result";
            str7 = "ver";
            bVar2 = bVar3;
            str12 = "at";
            str11 = "lc";
            str8 = str;
        } catch (IllegalBlockSizeException e15) {
            e = e15;
            str5 = "infocode";
            str6 = "result";
            str7 = "ver";
            bVar2 = bVar3;
            str12 = "at";
            str11 = "lc";
            str8 = str;
        } catch (Throwable th2) {
            e = th2;
            str5 = "infocode";
            str6 = "result";
            str7 = "ver";
            bVar2 = bVar3;
            str12 = "at";
            str11 = "lc";
            str8 = str;
        }
        if (isEmpty) {
            return bVar2;
        }
        if (buVar != null) {
            try {
                bArr = buVar.f9355a;
                try {
                    Map<String, List<String>> map = buVar.f9356b;
                    if (map != null && map.containsKey("lct")) {
                        bVar2.f10181e = a(map.get("lct"));
                        String b9 = b(map.get("lct-info"));
                        if (bVar2.f10181e != 0 && wVar != null) {
                            String a9 = wVar.a();
                            if (!TextUtils.isEmpty(a9)) {
                                a(a9, bVar2.f10181e, b9);
                            }
                        }
                    }
                } catch (Throwable th3) {
                    try {
                        th3.printStackTrace();
                        av.b(th3, str12, "lct");
                    } catch (k e16) {
                        e = e16;
                        bVar2.f10179c = e.a();
                        a(context, wVar, e.a());
                        av.a(wVar, "/v3/iasdkauth", e);
                        bVar = bVar2;
                        String str14222 = str8;
                        if (bArr != null) {
                        }
                    } catch (IllegalBlockSizeException e17) {
                        e = e17;
                        a(context, wVar, e);
                        bVar = bVar2;
                        String str142222 = str8;
                        if (bArr != null) {
                        }
                    } catch (Throwable th4) {
                        e = th4;
                        av.b(e, str12, str11);
                        a(context, wVar, e);
                        bVar = bVar2;
                        String str1422222 = str8;
                        if (bArr != null) {
                        }
                    }
                }
            } catch (k e18) {
                e = e18;
                bArr = null;
                bVar2.f10179c = e.a();
                a(context, wVar, e.a());
                av.a(wVar, "/v3/iasdkauth", e);
                bVar = bVar2;
                String str14222222 = str8;
                if (bArr != null) {
                }
            } catch (IllegalBlockSizeException e19) {
                e = e19;
                bArr = null;
                a(context, wVar, e);
                bVar = bVar2;
                String str142222222 = str8;
                if (bArr != null) {
                }
            } catch (Throwable th5) {
                e = th5;
                bArr = null;
                av.b(e, str12, str11);
                a(context, wVar, e);
                bVar = bVar2;
                String str1422222222 = str8;
                if (bArr != null) {
                }
            }
        } else {
            bArr = null;
        }
        byte[] bArr2 = new byte[16];
        byte[] bArr3 = new byte[bArr.length - 16];
        System.arraycopy(bArr, 0, bArr2, 0, 16);
        System.arraycopy(bArr, 16, bArr3, 0, bArr.length - 16);
        SecretKeySpec secretKeySpec = new SecretKeySpec(bArr2, x.c("EQUVT"));
        Cipher cipher = Cipher.getInstance(x.c("CQUVTL0NCQy9QS0NTNVBhZGRpbmc"));
        cipher.init(2, secretKeySpec, new IvParameterSpec(x.c()));
        str13 = x.a(cipher.doFinal(bArr3));
        bVar = bVar2;
        String str14222222222 = str8;
        if (bArr != null) {
            return bVar;
        }
        if (TextUtils.isEmpty(str13)) {
            str13 = x.a(bArr);
        }
        String str15 = str13;
        if (TextUtils.isEmpty(str15)) {
            a(context, wVar, "result is null");
        }
        try {
            JSONObject jSONObject = new JSONObject(str15);
            if (jSONObject.has(NotificationCompat.CATEGORY_STATUS)) {
                int i9 = jSONObject.getInt(NotificationCompat.CATEGORY_STATUS);
                if (i9 == 1) {
                    f10147a = 1;
                } else if (i9 == 0) {
                    if (buVar != null) {
                        str9 = buVar.f9357c;
                        str10 = buVar.f9358d;
                    } else {
                        str9 = "authcsid";
                        str10 = "authgsid";
                    }
                    x.a(context, str9, str10, jSONObject);
                    f10147a = 0;
                    if (jSONObject.has("info")) {
                        f10148b = jSONObject.getString("info");
                    }
                    String str16 = str5;
                    av.a(wVar, "/v3/iasdkauth", f10148b, str10, str9, jSONObject.has(str16) ? jSONObject.getString(str16) : "");
                    if (f10147a == 0) {
                        bVar.f10179c = f10148b;
                        return bVar;
                    }
                }
                String str17 = str7;
                if (jSONObject.has(str17)) {
                    bVar.f10180d = jSONObject.getInt(str17);
                }
                String str18 = str6;
                if (x.a(jSONObject, str18)) {
                    JSONObject jSONObject2 = jSONObject.getJSONObject(str18);
                    a(context, wVar, str14222222222, bVar, jSONObject2);
                    try {
                        JSONObject jSONObject3 = jSONObject2.getJSONObject("15K");
                        boolean a10 = a(jSONObject3.optString("isTargetAble"), false);
                        if (a(jSONObject3.optString("able"), false)) {
                            q.a().a(context, a10);
                        } else {
                            q.a();
                            q.b(context);
                        }
                    } catch (Throwable unused4) {
                    }
                }
            }
        } catch (Throwable th6) {
            as.a(th6, str12, str11);
        }
        return bVar;
    }

    public static w b(String str) {
        d dVar = f10168v.get(str);
        if (dVar != null) {
            return dVar.f10195a;
        }
        return null;
    }

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

    private static String b(List<String> list) {
        if (list != null) {
            try {
                if (list.size() > 0) {
                    String str = list.get(0);
                    return !TextUtils.isEmpty(str) ? str : "";
                }
                return "";
            } catch (Exception unused) {
                return "";
            }
        }
        return "";
    }

    public static void b(Context context) {
        if (context == null) {
            return;
        }
        f10161o = bd.a(context, "open_common", "a2", true);
    }

    public static void b(br.c cVar) {
        synchronized (C) {
            boolean z8 = false;
            for (int i9 = 0; i9 < C.size(); i9++) {
                br.a aVar = C.get(i9);
                if (cVar.f9296c.equals(aVar.f9283b) && cVar.f9297d.equals(aVar.f9286e)) {
                    int i10 = cVar.f9306m;
                    int i11 = aVar.f9287f;
                    if (i10 == i11) {
                        if (i11 == 1) {
                            aVar.f9290i = ((aVar.f9291j.get() * aVar.f9290i) + cVar.f9299f) / (aVar.f9291j.get() + 1);
                        }
                        aVar.f9291j.getAndIncrement();
                        z8 = true;
                    }
                }
            }
            if (!z8) {
                C.add(new br.a(cVar));
            }
            br.a();
        }
    }

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

    public static boolean b() {
        Integer num;
        Context context = f10149c;
        if (context == null) {
            return false;
        }
        String s9 = o.s(context);
        return (TextUtils.isEmpty(s9) || (num = f10163q.get(s9.toUpperCase())) == null || num.intValue() != 2) ? false : true;
    }

    public static String c(String str) {
        if (TextUtils.isEmpty(str)) {
            return str;
        }
        return str + ";15K;16H;17I;1A4;17S;183";
    }

    private static void c(Context context) {
        if (context == null) {
            return;
        }
        f10152f = bd.a(context, "open_common", "a13", true);
        f10154h = bd.a(context, "open_common", "a6", true);
        f10153g = bd.a(context, "open_common", "a7", false);
        f10151e = bd.a(context, "open_common", "a8", 5000);
        f10171y = bd.a(context, "open_common", "a9", 3);
        f10155i = bd.a(context, "open_common", "a10", false);
        f10172z = bd.a(context, "open_common", "a11", 3);
        f10156j = bd.a(context, "open_common", "a12", false);
    }

    public static void c(br.c cVar) {
        if (cVar != null && f10156j) {
            synchronized (E) {
                E.offer(cVar);
                br.a();
            }
        }
    }

    public static boolean c() {
        Integer num;
        Context context = f10149c;
        if (context == null) {
            return false;
        }
        String s9 = o.s(context);
        return (TextUtils.isEmpty(s9) || (num = f10163q.get(s9.toUpperCase())) == null || num.intValue() < 2) ? false : true;
    }

    public static void d() {
        try {
            e a9 = a(f10149c, "IPV6_CONFIG_NAME", "open_common");
            String a10 = x.a(System.currentTimeMillis(), DateTools.YYYYMMDD);
            if (!a10.equals(a9.f10199b)) {
                a9.a(a10);
                a9.f10200c.set(0);
            }
            a9.f10200c.incrementAndGet();
            a(f10149c, "IPV6_CONFIG_NAME", "open_common", a9);
        } catch (Throwable unused) {
        }
    }

    private static void d(Context context) {
        try {
            if (f10169w) {
                return;
            }
            ag.f9068d = bd.a(context, "open_common", "a4", true);
            ag.f9069e = bd.a(context, "open_common", "a5", true);
            f10169w = true;
        } catch (Throwable unused) {
        }
    }

    public static synchronized boolean d(String str) {
        synchronized (m.class) {
            try {
            } finally {
                return false;
            }
            if (TextUtils.isEmpty(str)) {
                return false;
            }
            if (f10168v == null) {
                return false;
            }
            if (f10167u == null) {
                f10167u = new ConcurrentHashMap<>(8);
            }
            if (f10168v.containsKey(str) && !f10167u.containsKey(str)) {
                f10167u.put(str, Long.valueOf(SystemClock.elapsedRealtime()));
                return true;
            }
            return false;
        }
    }

    public static void e() {
        if (f10150d) {
            return;
        }
        try {
            Context context = f10149c;
            if (context == null) {
                return;
            }
            f10150d = true;
            q.a().a(context);
            b(context);
            c(context);
            f.f10201a = bd.a(context, "open_common", "ucf", f.f10201a);
            f.f10202b = bd.a(context, "open_common", "fsv2", f.f10202b);
            f.f10203c = bd.a(context, "open_common", "usc", f.f10203c);
            f.f10204d = bd.a(context, "open_common", "umv", f.f10204d);
            f.f10205e = bd.a(context, "open_common", "ust", f.f10205e);
            f.f10206f = bd.a(context, "open_common", "ustv", f.f10206f);
        } catch (Throwable unused) {
        }
    }

    private static void e(Context context) {
        try {
            if (f10170x) {
                return;
            }
            z.f10368d = a(bd.b(context, "open_common", "a16", ""), true);
            z.f10366b = bd.a(context, "open_common", "a17", z.f10365a);
            f10170x = true;
        } catch (Throwable unused) {
        }
    }

    public static synchronized void e(String str) {
        synchronized (m.class) {
            if (f10167u == null) {
                return;
            }
            if (f10167u.containsKey(str)) {
                f10167u.remove(str);
            }
        }
    }

    public static br.a f() {
        if (D) {
            return null;
        }
        synchronized (C) {
            if (D) {
                return null;
            }
            Collections.sort(C);
            if (C.size() > 0) {
                br.a clone = C.get(0).clone();
                D = true;
                return clone;
            }
            return null;
        }
    }

    public static synchronized g f(String str) {
        synchronized (m.class) {
            try {
                if (f10166t == null) {
                    f10166t = new ConcurrentHashMap<>(8);
                }
                if (f10166t.containsKey(str)) {
                    return f10166t.get(str);
                }
                return new g(0L, "");
            }
        }
    }

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

    public static boolean g(String str) {
        e a9;
        try {
            if (TextUtils.isEmpty(str)) {
                return true;
            }
            if (f10152f) {
                if (A.get(str) == null) {
                    Context context = f10149c;
                    if (context == null || (a9 = a(context, b(str, "a14"), "open_common")) == null) {
                        return true;
                    }
                    return a9.a() < f10171y;
                }
                return false;
            }
            return false;
        } catch (Throwable unused) {
            return true;
        }
    }

    public static boolean h(String str) {
        e a9;
        if (!TextUtils.isEmpty(str) && f10155i) {
            if (B.get(str) == null) {
                Context context = f10149c;
                if (context == null || (a9 = a(context, b(str, "a15"), "open_common")) == null) {
                    return true;
                }
                return a9.a() < f10172z;
            }
            return false;
        }
        return false;
    }

    private static void i() {
        Map<String, Integer> map;
        String str;
        Integer valueOf;
        try {
            Context context = f10149c;
            if (context != null) {
                String s9 = o.s(context);
                if (!TextUtils.isEmpty(f10164r) && !TextUtils.isEmpty(s9) && f10164r.equals(s9) && System.currentTimeMillis() - f10165s < DateTimeUtils.MINUTE_UNIT) {
                    return;
                }
                if (!TextUtils.isEmpty(s9)) {
                    f10164r = s9;
                }
            } else if (System.currentTimeMillis() - f10165s < 10000) {
                return;
            }
            f10165s = System.currentTimeMillis();
            f10163q.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 i9 = 0;
                    for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses()) {
                        InetAddress address = interfaceAddress.getAddress();
                        if (address instanceof Inet6Address) {
                            if (!a((Inet6Address) address)) {
                                i9 |= 2;
                            }
                        } else if (address instanceof Inet4Address) {
                            Inet4Address inet4Address = (Inet4Address) address;
                            if (!a(inet4Address) && !inet4Address.getHostAddress().startsWith(x.c("FMTkyLjE2OC40My4"))) {
                                i9 |= 1;
                            }
                        }
                    }
                    if (i9 != 0) {
                        if (displayName != null && displayName.startsWith("wlan")) {
                            map = f10163q;
                            str = "WIFI";
                            valueOf = Integer.valueOf(i9);
                        } else if (displayName != null && displayName.startsWith("rmnet")) {
                            map = f10163q;
                            str = "MOBILE";
                            valueOf = Integer.valueOf(i9);
                        }
                        map.put(str, valueOf);
                    }
                }
            }
        } catch (Throwable th) {
            as.a(th, "at", "ipstack");
        }
    }
}