RbChat v4.56630229版本的 MD5 值为:d137f4b55d6b64b50641a810905f5957
以下内容为反编译后的 cz.java 源代码,内容仅作参考
package com.loc;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import io.netty.handler.codec.rtsp.RtspHeaders;
import java.net.URL;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
public final class cz {
private static cz d;
private String[] e;
private String g;
private String h;
private Context k;
private long a = 0;
private boolean b = false;
private boolean c = false;
private ArrayList<String> f = new ArrayList<>();
private int i = 0;
private long j = 120000;
private boolean l = false;
private boolean m = false;
private cz(Context context) {
this.k = context;
}
public static synchronized cz a(Context context) {
cz czVar;
synchronized (cz.class) {
if (d == null) {
d = new cz(context);
}
czVar = d;
}
return czVar;
}
static boolean a(String[] strArr, String[] strArr2) {
if (strArr.length == 0 || strArr2 == null || strArr2.length == 0 || strArr.length != strArr2.length) {
return false;
}
int length = strArr.length;
for (int i = 0; i < length; i++) {
if (!strArr[i].equals(strArr2[i])) {
return false;
}
}
return true;
}
private void b() {
if (this.l) {
try {
SharedPreferences.Editor edit = this.k.getSharedPreferences("cbG9jaXA", 0).edit();
edit.remove("last_ip");
dm.a(edit);
} catch (Throwable th) {
dg.a(th, "SpUtil", "setPrefsLong");
}
this.l = false;
}
}
static void b(cz czVar) {
String str = czVar.e[0];
if (str.equals(czVar.g) || czVar.f.contains(str)) {
return;
}
czVar.g = str;
dm.a(czVar.k, "cbG9jaXA", "last_ip", str);
}
private synchronized void b(boolean z) {
if (!z) {
if (!df.A() && this.m) {
return;
}
}
if (this.a != 0) {
long currentTimeMillis = System.currentTimeMillis();
long j = this.a;
if (currentTimeMillis - j < this.j) {
return;
}
if (currentTimeMillis - j < 60000) {
return;
}
}
this.a = System.currentTimeMillis();
this.m = true;
aj.d().submit(new Runnable() {
@Override
public final void run() {
JSONArray jSONArray;
int length;
int i;
da daVar = new da();
daVar.f = "http://" + df.D() + "?host=apilocatesrc.amap.com";
try {
bj.a();
JSONObject jSONObject = new JSONObject(new String(bj.b(daVar)));
if (!jSONObject.has("ips") || (length = (jSONArray = jSONObject.getJSONArray("ips")).length()) == 0) {
return;
}
String[] strArr = new String[length];
for (int i2 = 0; i2 < length; i2++) {
strArr[i2] = jSONArray.getString(i2);
}
if (!cz.a(strArr, cz.this.e)) {
cz.this.e = strArr;
cz.b(cz.this);
}
if (!jSONObject.has(RtspHeaders.Values.TTL) || (i = jSONObject.getInt(RtspHeaders.Values.TTL)) <= 30) {
return;
}
cz.this.j = i * 1000;
} catch (Throwable th) {
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put("key", "dnsError");
jSONObject2.put("reason", th.getMessage());
} catch (Throwable unused) {
}
dk.a(cz.this.k, "O018", jSONObject2);
}
}
});
}
private String c() {
String str;
int i = 0;
b(false);
String[] strArr = this.e;
if (strArr == null || strArr.length <= 0) {
String b = dm.b(this.k, "cbG9jaXA", "last_ip", (String) null);
if (!TextUtils.isEmpty(b) && !this.f.contains(b)) {
this.g = b;
this.h = b;
this.l = true;
}
return this.g;
}
int length = strArr.length;
while (true) {
if (i >= length) {
str = null;
break;
}
str = strArr[i];
if (!this.f.contains(str)) {
break;
}
i++;
}
if (TextUtils.isEmpty(str)) {
return null;
}
this.g = str;
return str;
}
public final String a(dc dcVar) {
if (dcVar != null) {
try {
String c = dcVar.c();
String host = new URL(c).getHost();
if (!"http://abroad.apilocate.amap.com/mobile/binary".equals(c) && !"abroad.apilocate.amap.com".equals(host)) {
String str = "apilocate.amap.com".equalsIgnoreCase(host) ? "httpdns.apilocate.amap.com" : host;
String c2 = c();
if (!TextUtils.isEmpty(c2)) {
dcVar.g = c.replace(host, c2);
dcVar.b().put("host", str);
dcVar.b(str);
return c2;
}
}
} catch (Throwable unused) {
}
}
return null;
}
public final void a() {
if (this.c) {
b();
return;
}
this.f.add(this.g);
b();
b(true);
}
public final void a(boolean z) {
this.c = z;
if (!z || TextUtils.isEmpty(this.g) || this.g.equals(this.h)) {
return;
}
String str = this.g;
this.h = str;
dm.a(this.k, "cbG9jaXA", "last_ip", str);
this.l = true;
}
}