小源钱包 v1.0.0版本的 MD5 值为:2fddb51fa9867693f901004082511bea

以下内容为反编译后的 i1.java 源代码,内容仅作参考


package com.loc;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.loc.a0;
import java.net.URL;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import p6.g2;
import p6.h2;
import p6.p2;
public final class i1 {
    private static i1 f14274i = null;
    public static int f14275j = 1;
    public static int f14276k = 2;
    private Context f14282f;
    private String f14283g;
    private long f14277a = 0;
    private ArrayList<String> f14278b = new ArrayList<>();
    private p6.s1 f14279c = new p6.s1();
    private p6.s1 f14280d = new p6.s1();
    private long f14281e = 120000;
    private boolean f14284h = false;

    public final class a extends p6.g0 {
        final int f14285b;

        a(int i10) {
            this.f14285b = i10;
        }

        @Override
        public final void a() {
            int i10;
            StringBuilder sb = new StringBuilder("http://");
            sb.append(k1.I());
            sb.append("?host=dualstack-a.apilocate.amap.com&query=");
            sb.append(this.f14285b == i1.f14276k ? 6 : 4);
            String sb2 = sb.toString();
            g2 g2Var = new g2();
            g2Var.L(sb2);
            g2Var.M(sb2);
            g2Var.d(a0.a.SINGLE);
            g2Var.f(a0.c.HTTP);
            try {
                w.b();
                JSONObject jSONObject = new JSONObject(new String(w.c(g2Var).f22956a));
                String[] n6 = i1.n(jSONObject.optJSONArray("ips"), i1.f14275j);
                if (n6 != null && n6.length > 0 && !i1.m(n6, i1.this.j(i1.f14275j).d())) {
                    i1.this.j(i1.f14275j).c(n6);
                    i1.this.r(i1.f14275j);
                }
                String[] n10 = i1.n(jSONObject.optJSONArray("ipsv6"), i1.f14276k);
                if (n10 != null && n10.length > 0 && !i1.m(n10, i1.this.j(i1.f14276k).d())) {
                    i1.this.j(i1.f14276k).c(n10);
                    i1.this.r(i1.f14276k);
                }
                if ((jSONObject.has("ips") || jSONObject.has("ipsv6")) && jSONObject.has("ttl") && (i10 = jSONObject.getInt("ttl")) > 30) {
                    i1.this.f14281e = i10 * 1000;
                }
            } catch (Throwable th) {
                JSONObject jSONObject2 = new JSONObject();
                try {
                    jSONObject2.put("key", "dnsError");
                    jSONObject2.put("reason", th.getMessage());
                } catch (Throwable unused) {
                }
                n1.n(i1.this.f14282f, "O018", jSONObject2);
            }
        }
    }

    private i1(Context context) {
        this.f14282f = context;
    }

    public static synchronized i1 c(Context context) {
        i1 i1Var;
        synchronized (i1.class) {
            if (f14274i == null) {
                f14274i = new i1(context);
            }
            i1Var = f14274i;
        }
        return i1Var;
    }

    public p6.s1 j(int i10) {
        return i10 == f14276k ? this.f14280d : this.f14279c;
    }

    private synchronized void l(boolean z10, int i10) {
        if (!z10) {
            if (!k1.G() && this.f14284h) {
                return;
            }
        }
        if (this.f14277a != 0) {
            long currentTimeMillis = System.currentTimeMillis();
            long j10 = this.f14277a;
            if (currentTimeMillis - j10 < this.f14281e) {
                return;
            }
            if (currentTimeMillis - j10 < 60000) {
                return;
            }
        }
        this.f14277a = System.currentTimeMillis();
        this.f14284h = true;
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        StringBuffer stringBuffer = new StringBuffer();
        for (StackTraceElement stackTraceElement : stackTrace) {
            stringBuffer.append(stackTraceElement.getClassName() + "(" + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber() + "),");
        }
        p6.f0.f().d(new a(i10));
    }

    public static boolean m(String[] strArr, String[] strArr2) {
        if (strArr == null || strArr.length == 0 || strArr2 == null || strArr2.length == 0 || strArr.length != strArr2.length) {
            return false;
        }
        int length = strArr.length;
        for (int i10 = 0; i10 < length; i10++) {
            if (!strArr[i10].equals(strArr2[i10])) {
                return false;
            }
        }
        return true;
    }

    public static String[] n(JSONArray jSONArray, int i10) throws JSONException {
        if (jSONArray == null || jSONArray.length() == 0) {
            return new String[0];
        }
        int length = jSONArray.length();
        String[] strArr = new String[length];
        for (int i11 = 0; i11 < length; i11++) {
            String string = jSONArray.getString(i11);
            if (!TextUtils.isEmpty(string)) {
                if (i10 == f14276k) {
                    string = "[" + string + "]";
                }
                strArr[i11] = string;
            }
        }
        return strArr;
    }

    private static String o(int i10) {
        return i10 == f14276k ? "last_ip_6" : "last_ip_4";
    }

    private void p(int i10) {
        if (j(i10).i()) {
            SharedPreferences.Editor c10 = p2.c(this.f14282f, "cbG9jaXA");
            p2.g(c10, o(i10));
            p2.f(c10);
            j(i10).b(false);
        }
    }

    private String q(int i10) {
        String str;
        int i11 = 0;
        l(false, i10);
        String[] d10 = j(i10).d();
        if (d10 == null || d10.length <= 0) {
            s(i10);
            return j(i10).e();
        }
        int length = d10.length;
        while (true) {
            if (i11 >= length) {
                str = null;
                break;
            }
            str = d10[i11];
            if (!this.f14278b.contains(str)) {
                break;
            }
            i11++;
        }
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        j(i10).a(str);
        return str;
    }

    public void r(int i10) {
        if (j(i10).d() == null || j(i10).d().length <= 0) {
            return;
        }
        String str = j(i10).d()[0];
        if (str.equals(this.f14283g) || this.f14278b.contains(str)) {
            return;
        }
        this.f14283g = str;
        SharedPreferences.Editor c10 = p2.c(this.f14282f, "cbG9jaXA");
        p2.j(c10, o(i10), str);
        p2.f(c10);
    }

    private void s(int i10) {
        String e10 = p2.e(this.f14282f, "cbG9jaXA", o(i10), null);
        if (TextUtils.isEmpty(e10) || this.f14278b.contains(e10)) {
            return;
        }
        j(i10).a(e10);
        j(i10).f(e10);
        j(i10).b(true);
    }

    public final String d(h2 h2Var, int i10) {
        try {
            if (k1.H() && h2Var != null) {
                String j10 = h2Var.j();
                String host = new URL(j10).getHost();
                if (!"http://abroad.apilocate.amap.com/mobile/binary".equals(j10) && !"abroad.apilocate.amap.com".equals(host)) {
                    String str = "apilocate.amap.com".equalsIgnoreCase(host) ? "httpdns.apilocate.amap.com" : host;
                    if (!q1.S(str)) {
                        return null;
                    }
                    String q10 = q(i10);
                    if (!TextUtils.isEmpty(q10)) {
                        h2Var.c0(j10.replace(host, q10));
                        h2Var.b().put("host", str);
                        h2Var.d0(str);
                        h2Var.i(i10 == f14276k);
                        return q10;
                    }
                }
            }
        } catch (Throwable unused) {
        }
        return null;
    }

    public final void f(int i10) {
        if (j(i10).j()) {
            p(i10);
            return;
        }
        this.f14278b.add(j(i10).e());
        p(i10);
        l(true, i10);
    }

    public final void g(boolean z10, int i10) {
        j(i10).g(z10);
        if (z10) {
            String h10 = j(i10).h();
            String e10 = j(i10).e();
            if (TextUtils.isEmpty(e10) || e10.equals(h10)) {
                return;
            }
            SharedPreferences.Editor c10 = p2.c(this.f14282f, "cbG9jaXA");
            p2.j(c10, o(i10), e10);
            p2.f(c10);
        }
    }
}