热汗舞蹈 v1.24.1.0版本的 MD5 值为:f1dc6ef07903515a73f51f41f372123e

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


package com.qiyukf.nimlib.net.a.b.a;

import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import com.qiyukf.nimlib.e.g;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicBoolean;
import org.json.JSONException;
import org.json.JSONObject;
public final class c {
    private static c f20212g = new c();
    private d f20213a;
    private long f20215c;
    private long f20216d;
    private boolean f20214b = true;
    private Handler f20217e = com.qiyukf.nimlib.d.b.a.c().a();
    private AtomicBoolean f20218f = new AtomicBoolean(false);

    private c() {
        a(true);
    }

    public static c a() {
        return f20212g;
    }

    private boolean e() {
        String c10;
        boolean a10;
        Context d10 = com.qiyukf.nimlib.c.d();
        b.b(d10);
        int i10 = 0;
        try {
            c10 = b.c(d10);
            a10 = !TextUtils.isEmpty(c10) ? a(c10) : false;
        } catch (Exception e10) {
            e = e10;
        }
        try {
            if (TextUtils.isEmpty(c10) || !a10) {
                String str = com.qiyukf.nimlib.c.i() == null ? null : com.qiyukf.nimlib.c.i().nosUploadLbs;
                if (TextUtils.isEmpty(str)) {
                    str = "https://wanproxy-hz.127.net/lbs";
                }
                if (TextUtils.isEmpty(str)) {
                    return a10;
                }
                String[] split = str.split(";");
                int length = split.length;
                while (i10 < length) {
                    a10 = a(split[i10]);
                    if (a10) {
                        return a10;
                    }
                    i10++;
                }
                return a10;
            }
            return a10;
        } catch (Exception e11) {
            e = e11;
            i10 = a10;
            com.qiyukf.nimlib.j.b.b.a.e("NOS_LBS", "fetch nos lbs error, e=" + e.getMessage());
            e.printStackTrace();
            return i10;
        }
    }

    public final synchronized void b() {
        Context d10 = com.qiyukf.nimlib.c.d();
        com.qiyukf.nimlib.j.b.b.a.c("NOS_LBS", "fetch NOS LBS on SDK init...");
        this.f20214b = true;
        b.d(d10);
        b(false);
        b.a(d10);
    }

    public final synchronized String[] c() {
        String[] a10 = this.f20213a.a();
        boolean z10 = (!com.qiyukf.nimlib.c.g().preLoadServers && this.f20213a.c() <= 0) || a10.length == 0;
        if (this.f20213a.c() == 0) {
            b(z10);
        }
        if (z10) {
            return this.f20213a.a();
        }
        return a10;
    }

    public final synchronized void d() {
        if (System.currentTimeMillis() - this.f20216d >= 300000) {
            this.f20214b = true;
            com.qiyukf.nimlib.j.b.b.a.c("NOS_LBS", "nos lbs reset all, should fetch nos lbs...");
            b(false);
            this.f20216d = System.currentTimeMillis();
        }
    }

    private void a(boolean z10) {
        String[] a10 = b.a(com.qiyukf.nimlib.c.d(), com.qiyukf.nimlib.net.a.b.d.a.f20277a);
        String e10 = g.e();
        this.f20213a = new d(a10, !TextUtils.isEmpty(e10) ? new String[]{e10} : null);
        StringBuilder sb2 = new StringBuilder();
        sb2.append(z10 ? "load cached nos upload server addresses from SP" : "update nos upload server addresses from lbs");
        sb2.append(", ip count=");
        sb2.append(this.f20213a.c());
        sb2.append(", default ip count=");
        sb2.append(this.f20213a.b());
        com.qiyukf.nimlib.j.b.b.a.c("NOS_LBS", sb2.toString());
    }

    public void c(boolean z10) {
        StringBuilder sb2 = new StringBuilder("fetch nos upload server addresses from lbs ");
        sb2.append(z10 ? "now" : "on background");
        com.qiyukf.nimlib.j.b.b.a.c("NOS_LBS", sb2.toString());
        e();
        if (!this.f20214b) {
            this.f20215c = System.currentTimeMillis();
        }
        if (z10) {
            return;
        }
        this.f20218f.set(false);
    }

    private void b(final boolean z10) {
        if (z10 || this.f20214b || System.currentTimeMillis() - this.f20215c >= 3600000) {
            Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    c.this.c(z10);
                }
            };
            if (z10) {
                runnable.run();
            } else if (this.f20218f.get()) {
            } else {
                this.f20217e.post(runnable);
                this.f20218f.set(true);
            }
        }
    }

    private boolean a(String str) throws JSONException {
        String c10 = c(str);
        com.qiyukf.nimlib.j.b.b.a.c("NOS_LBS", "fetch nos lbs, url=".concat(String.valueOf(c10)));
        com.qiyukf.nimlib.net.a.b.c.c b10 = b(c10);
        if (b10.a() == 200) {
            JSONObject b11 = b10.b();
            com.qiyukf.nimlib.j.b.b.a.c("NOS_LBS", "fetch nos lbs result: " + b11.toString());
            b.a(com.qiyukf.nimlib.c.d(), b11);
            a(false);
            this.f20214b = false;
            return true;
        }
        com.qiyukf.nimlib.j.b.b.a.e("NOS_LBS", "fetch nos lbs failed, code=" + b10.a());
        return false;
    }

    private static String c(String str) {
        return str + "?version=1.0";
    }

    private static com.qiyukf.nimlib.net.a.b.c.c b(String str) {
        InputStream inputStream;
        Exception e10;
        InputStream inputStream2;
        InputStream inputStream3 = null;
        int i10 = 799;
        try {
            try {
                str = com.qiyukf.nimlib.net.a.c.b.a((String) str, "GET");
            } catch (Throwable th) {
                th = th;
                inputStream3 = inputStream2;
            }
        } catch (Exception e11) {
            inputStream = null;
            e10 = e11;
            str = 0;
        } catch (Throwable th2) {
            th = th2;
            str = 0;
        }
        try {
            com.qiyukf.nimlib.net.a.c.b.a(str, "NIM-Android-NOS-LBS-V1.0.0", com.qiyukf.nimlib.net.a.b.a.c().a(), com.qiyukf.nimlib.net.a.b.a.c().b());
            i10 = str.getResponseCode();
            inputStream = str.getInputStream();
            try {
                if (inputStream != null) {
                    com.qiyukf.nimlib.net.a.b.c.c cVar = new com.qiyukf.nimlib.net.a.b.c.c(i10, new JSONObject(com.qiyukf.nimlib.net.a.c.b.a(inputStream)), null);
                    com.qiyukf.nimlib.net.a.c.b.b(inputStream);
                    str.disconnect();
                    return cVar;
                }
                com.qiyukf.nimlib.j.b.b.a.e("NOS_LBS", "fetch nos lbs error, as http no response");
                com.qiyukf.nimlib.net.a.b.c.c cVar2 = new com.qiyukf.nimlib.net.a.b.c.c(899, new JSONObject(), null);
                com.qiyukf.nimlib.net.a.c.b.b(inputStream);
                str.disconnect();
                return cVar2;
            } catch (Exception e12) {
                e10 = e12;
                com.qiyukf.nimlib.j.b.b.a.d("NOS_LBS", "fetch nos lbs error, error code=".concat(String.valueOf(i10)), e10);
                com.qiyukf.nimlib.net.a.b.c.c cVar3 = new com.qiyukf.nimlib.net.a.b.c.c(i10, new JSONObject(), e10);
                com.qiyukf.nimlib.net.a.c.b.b(inputStream);
                if (str != 0) {
                    str.disconnect();
                }
                return cVar3;
            }
        } catch (Exception e13) {
            inputStream = null;
            e10 = e13;
        } catch (Throwable th3) {
            th = th3;
            com.qiyukf.nimlib.net.a.c.b.b(inputStream3);
            if (str != 0) {
                str.disconnect();
            }
            throw th;
        }
    }
}