湘游汇 v1.0版本的 MD5 值为:85338391d88b5d57da66e240ece801c7
以下内容为反编译后的 de.java 源代码,内容仅作参考
package com.b;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import java.net.URL;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONObject;
public final class de {
public static int f561a = 1;
public static int b = 2;
private static de e;
private Context j;
private String k;
private long c = 0;
private boolean d = false;
private ArrayList<String> f = new ArrayList<>();
private cr g = new cr();
private cr h = new cr();
private long i = 120000;
private boolean l = false;
private de(Context context) {
this.j = context;
}
public static synchronized de a(Context context) {
de deVar;
synchronized (de.class) {
if (e == null) {
e = new de(context);
}
deVar = e;
}
return deVar;
}
static boolean a(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 i = 0; i < length; i++) {
if (!strArr[i].equals(strArr2[i])) {
return false;
}
}
return true;
}
static String[] a(JSONArray jSONArray, int i) {
if (jSONArray == null || jSONArray.length() == 0) {
return new String[0];
}
int length = jSONArray.length();
String[] strArr = new String[length];
for (int i2 = 0; i2 < length; i2++) {
String string = jSONArray.getString(i2);
if (!TextUtils.isEmpty(string)) {
if (i == b) {
string = "[" + string + "]";
}
strArr[i2] = string;
}
}
return strArr;
}
public cr b(int i) {
return i == b ? this.h : this.g;
}
static void b(de deVar, int i) {
if (deVar.b(i).a() == null || deVar.b(i).a().length <= 0) {
return;
}
String str = deVar.b(i).a()[0];
if (str.equals(deVar.k) || deVar.f.contains(str)) {
return;
}
deVar.k = str;
SharedPreferences.Editor a2 = dq.a(deVar.j, "cbG9jaXA");
dq.a(a2, c(i), str);
dq.a(a2);
}
private synchronized void b(boolean z, final int i) {
if (!z) {
if (!dk.o() && this.l) {
return;
}
}
if (this.c != 0) {
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - this.c < this.i) {
return;
}
if (currentTimeMillis - this.c < 60000) {
return;
}
}
this.c = System.currentTimeMillis();
this.l = true;
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
StringBuffer stringBuffer = new StringBuffer();
for (StackTraceElement stackTraceElement : stackTrace) {
stringBuffer.append(stackTraceElement.getClassName() + "(" + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber() + "),");
}
b.d().submit(new Runnable() {
@Override
public final void run() {
int i2;
StringBuilder sb = new StringBuilder("http://");
sb.append(dk.r());
sb.append("?host=dualstack.apilocate.amap.com&query=");
sb.append(i == de.b ? 6 : 4);
String sb2 = sb.toString();
df dfVar = new df();
dfVar.f = sb2;
dfVar.b(sb2);
try {
q.a();
JSONObject jSONObject = new JSONObject(new String(q.b(dfVar)));
String[] a2 = de.a(jSONObject.optJSONArray("ips"), de.f561a);
if (a2.length > 0 && !de.a(a2, de.this.b(de.f561a).a())) {
de.this.b(de.f561a).a(a2);
de.b(de.this, de.f561a);
}
String[] a3 = de.a(jSONObject.optJSONArray("ipsv6"), de.b);
if (a3.length > 0 && !de.a(a3, de.this.b(de.b).a())) {
de.this.b(de.b).a(a3);
de.b(de.this, de.b);
}
if ((jSONObject.has("ips") || jSONObject.has("ipsv6")) && jSONObject.has("ttl") && (i2 = jSONObject.getInt("ttl")) > 30) {
de.this.i = i2 * 1000;
}
} catch (Throwable th) {
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put("key", "dnsError");
jSONObject2.put("reason", th.getMessage());
} catch (Throwable unused) {
}
dp.a(de.this.j, "O018", jSONObject2);
}
}
});
}
private static String c(int i) {
return i == b ? "last_ip_6" : "last_ip_4";
}
private void d(int i) {
if (b(i).d()) {
SharedPreferences.Editor a2 = dq.a(this.j, "cbG9jaXA");
dq.a(a2, c(i));
dq.a(a2);
b(i).a(false);
}
}
private String e(int i) {
String str;
int i2 = 0;
b(false, i);
String[] a2 = b(i).a();
if (a2 == null || a2.length <= 0) {
String a3 = dq.a(this.j, "cbG9jaXA", c(i), (String) null);
if (!TextUtils.isEmpty(a3) && !this.f.contains(a3)) {
b(i).a(a3);
b(i).b(a3);
b(i).a(true);
}
return b(i).b();
}
int length = a2.length;
while (true) {
if (i2 >= length) {
str = null;
break;
}
str = a2[i2];
if (!this.f.contains(str)) {
break;
}
i2++;
}
if (TextUtils.isEmpty(str)) {
return null;
}
b(i).a(str);
return str;
}
public final String a(dh dhVar, int i) {
try {
if (dk.p() && dhVar != null) {
String c = dhVar.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 e2 = e(i);
if (!TextUtils.isEmpty(e2)) {
if (i == b) {
dhVar.h = c.replace(host, e2);
} else {
dhVar.g = c.replace(host, e2);
}
dhVar.a().put("host", str);
dhVar.c(str);
return e2;
}
}
}
} catch (Throwable unused) {
}
return null;
}
public final void a(int i) {
if (b(i).e()) {
d(i);
return;
}
this.f.add(b(i).b());
d(i);
b(true, i);
}
public final void a(boolean z, int i) {
b(i).b(z);
if (z) {
String c = b(i).c();
String b2 = b(i).b();
if (TextUtils.isEmpty(b2) || b2.equals(c)) {
return;
}
SharedPreferences.Editor a2 = dq.a(this.j, "cbG9jaXA");
dq.a(a2, c(i), b2);
dq.a(a2);
}
}
}