同程有借 v1.0.0版本的 MD5 值为:e33397cdbab33543d0c134ec96d77fb8
以下内容为反编译后的 fk.java 源代码,内容仅作参考
package com.loc;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.huawei.hms.push.constant.RemoteMessageConst;
import com.loc.bt;
import com.moture.lib.core.utils.date.DateTimeUtils;
import com.xiaomi.mipush.sdk.Constants;
import java.net.URL;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public final class fk {
public static int f9899a = 1;
public static int f9900b = 2;
private static fk f9901e;
private Context f9908j;
private String f9909k;
private long f9902c = 0;
private boolean f9903d = false;
private ArrayList<String> f9904f = new ArrayList<>();
private et f9905g = new et();
private et f9906h = new et();
private long f9907i = 120000;
private boolean f9910l = false;
private fk(Context context) {
this.f9908j = context;
}
public static synchronized fk a(Context context) {
fk fkVar;
synchronized (fk.class) {
if (f9901e == null) {
f9901e = new fk(context);
}
fkVar = f9901e;
}
return fkVar;
}
public et b(int i9) {
return i9 == f9900b ? this.f9906h : this.f9905g;
}
private synchronized void b(boolean z8, final int i9) {
if (!z8) {
if (!fq.o() && this.f9910l) {
return;
}
}
if (this.f9902c != 0) {
long currentTimeMillis = System.currentTimeMillis();
long j9 = this.f9902c;
if (currentTimeMillis - j9 < this.f9907i) {
return;
}
if (currentTimeMillis - j9 < DateTimeUtils.MINUTE_UNIT) {
return;
}
}
this.f9902c = System.currentTimeMillis();
this.f9910l = true;
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
StringBuffer stringBuffer = new StringBuffer();
for (StackTraceElement stackTraceElement : stackTrace) {
stringBuffer.append(stackTraceElement.getClassName() + "(" + stackTraceElement.getMethodName() + Constants.COLON_SEPARATOR + stackTraceElement.getLineNumber() + "),");
}
cr.a().b(new cs() {
@Override
public final void a() {
int i10;
StringBuilder sb = new StringBuilder("http://");
sb.append(fq.q());
sb.append("?host=dualstack-a.apilocate.amap.com&query=");
sb.append(i9 == fk.f9900b ? 6 : 4);
String sb2 = sb.toString();
fl flVar = new fl();
flVar.b(sb2);
flVar.c(sb2);
flVar.a(bt.a.SINGLE);
flVar.a(bt.c.HTTP);
try {
bo.a();
JSONObject jSONObject = new JSONObject(new String(bo.a(flVar).f9355a));
String[] b9 = fk.b(jSONObject.optJSONArray("ips"), fk.f9899a);
if (b9 != null && b9.length > 0 && !fk.b(b9, fk.this.b(fk.f9899a).a())) {
fk.this.b(fk.f9899a).a(b9);
fk.this.f(fk.f9899a);
}
String[] b10 = fk.b(jSONObject.optJSONArray("ipsv6"), fk.f9900b);
if (b10 != null && b10.length > 0 && !fk.b(b10, fk.this.b(fk.f9900b).a())) {
fk.this.b(fk.f9900b).a(b10);
fk.this.f(fk.f9900b);
}
if ((jSONObject.has("ips") || jSONObject.has("ipsv6")) && jSONObject.has(RemoteMessageConst.TTL) && (i10 = jSONObject.getInt(RemoteMessageConst.TTL)) > 30) {
fk.this.f9907i = i10 * 1000;
}
} catch (Throwable th) {
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put("key", "dnsError");
jSONObject2.put("reason", th.getMessage());
} catch (Throwable unused) {
}
fw.a(fk.this.f9908j, "O018", jSONObject2);
}
}
});
}
public static boolean b(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 i9 = 0; i9 < length; i9++) {
if (!strArr[i9].equals(strArr2[i9])) {
return false;
}
}
return true;
}
public static String[] b(JSONArray jSONArray, int i9) throws JSONException {
if (jSONArray == null || jSONArray.length() == 0) {
return new String[0];
}
int length = jSONArray.length();
String[] strArr = new String[length];
for (int i10 = 0; i10 < length; i10++) {
String string = jSONArray.getString(i10);
if (!TextUtils.isEmpty(string)) {
if (i9 == f9900b) {
string = "[" + string + "]";
}
strArr[i10] = string;
}
}
return strArr;
}
private static String c(int i9) {
return i9 == f9900b ? "last_ip_6" : "last_ip_4";
}
private void d(int i9) {
if (b(i9).d()) {
SharedPreferences.Editor a9 = fx.a(this.f9908j, "cbG9jaXA");
fx.a(a9, c(i9));
fx.a(a9);
b(i9).a(false);
}
}
private String e(int i9) {
String str;
int i10 = 0;
b(false, i9);
String[] a9 = b(i9).a();
if (a9 == null || a9.length <= 0) {
g(i9);
return b(i9).b();
}
int length = a9.length;
while (true) {
if (i10 >= length) {
str = null;
break;
}
str = a9[i10];
if (!this.f9904f.contains(str)) {
break;
}
i10++;
}
if (TextUtils.isEmpty(str)) {
return null;
}
b(i9).a(str);
return str;
}
public void f(int i9) {
if (b(i9).a() == null || b(i9).a().length <= 0) {
return;
}
String str = b(i9).a()[0];
if (str.equals(this.f9909k) || this.f9904f.contains(str)) {
return;
}
this.f9909k = str;
SharedPreferences.Editor a9 = fx.a(this.f9908j, "cbG9jaXA");
fx.a(a9, c(i9), str);
fx.a(a9);
}
private void g(int i9) {
String a9 = fx.a(this.f9908j, "cbG9jaXA", c(i9), (String) null);
if (TextUtils.isEmpty(a9) || this.f9904f.contains(a9)) {
return;
}
b(i9).a(a9);
b(i9).b(a9);
b(i9).a(true);
}
public final String a(fn fnVar, int i9) {
try {
if (fq.p() && fnVar != null) {
String b9 = fnVar.b();
String host = new URL(b9).getHost();
if (!"http://abroad.apilocate.amap.com/mobile/binary".equals(b9) && !"abroad.apilocate.amap.com".equals(host)) {
String str = "apilocate.amap.com".equalsIgnoreCase(host) ? "httpdns.apilocate.amap.com" : host;
if (!m.g(str)) {
return null;
}
String e9 = e(i9);
if (!TextUtils.isEmpty(e9)) {
fnVar.d(b9.replace(host, e9));
fnVar.a().put(com.taobao.accs.common.Constants.KEY_HOST, str);
fnVar.e(str);
fnVar.a(i9 == f9900b);
return e9;
}
}
}
} catch (Throwable unused) {
}
return null;
}
public final void a(int i9) {
if (b(i9).e()) {
d(i9);
return;
}
this.f9904f.add(b(i9).b());
d(i9);
b(true, i9);
}
public final void a(boolean z8, int i9) {
b(i9).b(z8);
if (z8) {
String c9 = b(i9).c();
String b9 = b(i9).b();
if (TextUtils.isEmpty(b9) || b9.equals(c9)) {
return;
}
SharedPreferences.Editor a9 = fx.a(this.f9908j, "cbG9jaXA");
fx.a(a9, c(i9), b9);
fx.a(a9);
}
}
}