智慧考勤 v1.0.28版本的 MD5 值为:12729d810518c958a6eb8d5a86a946dd

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


package com.loc;

import android.content.Context;
import android.net.Proxy;
import android.os.Build;
import android.text.TextUtils;
import anet.channel.util.HttpConstant;
import com.xiaomi.mipush.sdk.Constants;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.concurrent.ExecutorService;
public final class cz {
    private static cz c;
    dc a;
    int b;
    private Object d;
    private Context e;
    private ExecutorService f;
    private boolean g;
    private boolean h;
    private final int i;
    private final String j;
    private String k;
    private String l;
    private String[] m;
    private final int n;
    private final int o;

    public class a implements Runnable {
        dc a;

        a(dc dcVar) {
            this.a = null;
            this.a = dcVar;
        }

        @Override
        public final void run() {
            cz.this.b++;
            cz.this.b(this.a);
            cz czVar = cz.this;
            czVar.b--;
        }
    }

    private cz() {
        this.d = null;
        this.e = null;
        this.f = null;
        this.g = false;
        this.h = true;
        this.a = null;
        this.i = 2;
        this.j = HttpConstant.HTTPS;
        this.k = "";
        this.l = "";
        this.m = null;
        this.b = 0;
        this.n = 5;
        this.o = 2;
    }

    private cz(Context context) {
        this.d = null;
        this.e = null;
        this.f = null;
        int i = 0;
        this.g = false;
        this.h = true;
        this.a = null;
        this.i = 2;
        this.j = HttpConstant.HTTPS;
        this.k = "";
        this.l = "";
        this.m = null;
        this.b = 0;
        this.n = 5;
        this.o = 2;
        this.e = context;
        try {
            if (df.v()) {
                u a2 = dg.a("HttpDNS", "1.0.0");
                if (dl.a(context, a2)) {
                    try {
                        this.d = av.a(context, a2, "com.autonavi.httpdns.HttpDnsManager", null, new Class[]{Context.class}, new Object[]{context});
                    } catch (Throwable unused) {
                    }
                    if (this.d != null) {
                        i = 1;
                    }
                    dl.a(context, "HttpDns", i);
                }
            }
        } catch (Throwable th) {
            dg.a(th, "DNSManager", "initHttpDns");
        }
    }

    public static cz a(Context context) {
        if (c == null) {
            c = new cz(context);
        }
        return c;
    }

    private String a(String str) {
        String str2;
        String str3 = null;
        if (e()) {
            int i = 1;
            try {
                String[] strArr = (String[]) dj.a(this.d, "getIpsByHostAsync", str);
                if (strArr != null && strArr.length > 0) {
                    String[] strArr2 = this.m;
                    if (strArr2 == null) {
                        this.m = strArr;
                        str2 = strArr[0];
                    } else if (a(strArr, strArr2)) {
                        str2 = this.m[0];
                    } else {
                        this.m = strArr;
                        str3 = strArr[0];
                    }
                    str3 = str2;
                }
            } catch (Throwable unused) {
                i = 0;
            }
            dl.b(this.e, "HttpDns", i);
        }
        return str3;
    }

    private static boolean a(String[] strArr, String[] strArr2) {
        if (strArr == null || strArr2 != null) {
            if (strArr != null || strArr2 == null) {
                if (strArr == null && strArr2 == null) {
                    return true;
                }
                try {
                    if (strArr.length != strArr2.length) {
                        return false;
                    }
                    ArrayList arrayList = new ArrayList(12);
                    ArrayList arrayList2 = new ArrayList(12);
                    arrayList.addAll(Arrays.asList(strArr));
                    arrayList2.addAll(Arrays.asList(strArr2));
                    Collections.sort(arrayList);
                    Collections.sort(arrayList2);
                    for (int i = 0; i < arrayList.size(); i++) {
                        if (!((String) arrayList.get(i)).equals(arrayList2.get(i))) {
                            return false;
                        }
                    }
                    return true;
                } catch (Throwable unused) {
                    return false;
                }
            }
            return false;
        }
        return false;
    }

    public static void d() {
        c = null;
    }

    private boolean e() {
        return df.v() && this.d != null && !f() && dn.b(this.e, "pref", "dns_faile_count_total", 0L) < 2;
    }

    private boolean f() {
        int i;
        String str = null;
        try {
            if (Build.VERSION.SDK_INT >= 14) {
                str = System.getProperty("http.proxyHost");
                String property = System.getProperty("http.proxyPort");
                if (property == null) {
                    property = "-1";
                }
                i = Integer.parseInt(property);
            } else {
                str = Proxy.getHost(this.e);
                i = Proxy.getPort(this.e);
            }
        } catch (Throwable th) {
            th.printStackTrace();
            i = -1;
        }
        return (str == null || i == -1) ? false : true;
    }

    public final void a() {
        if (TextUtils.isEmpty(this.l)) {
            return;
        }
        if (TextUtils.isEmpty(this.k) || !this.l.equals(this.k)) {
            String str = this.l;
            this.k = str;
            dn.a(this.e, "ip", "last_ip", str);
        }
    }

    public final void a(dc dcVar) {
        String str;
        String host;
        try {
            this.g = false;
            if (e() && dcVar != null) {
                this.a = dcVar;
                String c2 = dcVar.c();
                if (!c2.substring(0, c2.indexOf(Constants.COLON_SEPARATOR)).equalsIgnoreCase(HttpConstant.HTTPS) && !"http://abroad.apilocate.amap.com/mobile/binary".equals(c2)) {
                    if (c2.contains("http://apilocate.amap.com/mobile/binary")) {
                        host = "apilocatesrc.amap.com";
                        str = "http://apilocatesrc.amap.com/mobile/binary";
                    } else {
                        str = c2;
                        host = new URL(c2).getHost();
                    }
                    String a2 = a(host);
                    if (this.h && TextUtils.isEmpty(a2)) {
                        this.h = false;
                        a2 = dn.b(this.e, "ip", "last_ip", "");
                        if (!TextUtils.isEmpty(a2)) {
                            this.k = a2;
                        }
                    }
                    if (TextUtils.isEmpty(a2)) {
                        return;
                    }
                    this.l = a2;
                    dcVar.g = str.replace(host, a2);
                    dcVar.b().put(com.taobao.accs.common.Constants.KEY_HOST, host);
                    this.g = true;
                }
            }
        } catch (Throwable unused) {
        }
    }

    public final void b() {
        if (this.g) {
            dn.a(this.e, "pref", "dns_faile_count_total", 0L);
        }
    }

    final synchronized void b(dc dcVar) {
        try {
            dcVar.g = dg.a();
            long b = dn.b(this.e, "pref", "dns_faile_count_total", 0L);
            if (b >= 2) {
                return;
            }
            bk.a();
            bk.a(dcVar, false);
            long j = b + 1;
            if (j >= 2) {
                dm.a(this.e, "HttpDNS", "dns failed too much");
            }
            dn.a(this.e, "pref", "dns_faile_count_total", j);
        } catch (Throwable unused) {
            dn.a(this.e, "pref", "dns_faile_count_total", 0L);
        }
    }

    public final void c() {
        String[] strArr;
        try {
            if (e()) {
                if (this.g && (strArr = this.m) != null && strArr != null) {
                    try {
                        if (strArr.length > 1) {
                            ArrayList arrayList = new ArrayList(12);
                            arrayList.addAll(Arrays.asList(strArr));
                            Iterator it = arrayList.iterator();
                            it.remove();
                            arrayList.add((String) it.next());
                            arrayList.toArray(strArr);
                        }
                    } catch (Throwable unused) {
                    }
                }
                if (this.b > 5 || !this.g) {
                    return;
                }
                if (this.f == null) {
                    this.f = ai.d();
                }
                if (this.f.isShutdown()) {
                    return;
                }
                this.f.submit(new a(this.a));
            }
        } catch (Throwable unused2) {
        }
    }
}