派享便利 v1.0.3版本的 MD5 值为:1fc1776275e6607636a3a1f946b1f976
以下内容为反编译后的 ey.java 源代码,内容仅作参考
package com.loc;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;
import com.loc.bh;
import com.taobao.weex.el.parse.Operators;
import io.dcloud.common.DHInterface.IApp;
import io.dcloud.common.adapter.util.DeviceInfo;
import java.net.URL;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public final class ey {
public static int a = 1;
public static int b = 2;
private static ey e;
private Context j;
private String k;
private long c = 0;
private boolean d = false;
private ArrayList<String> f = new ArrayList<>();
private eh g = new eh();
private eh h = new eh();
private long i = 120000;
private boolean l = false;
private ey(Context context) {
this.j = context;
}
public static synchronized ey a(Context context) {
ey eyVar;
synchronized (ey.class) {
if (e == null) {
e = new ey(context);
}
eyVar = e;
}
return eyVar;
}
public eh b(int i) {
return i == b ? this.h : this.g;
}
private synchronized void b(boolean z, final int i) {
if (!z) {
if (!fe.o() && this.l) {
return;
}
}
if (this.c != 0) {
long currentTimeMillis = System.currentTimeMillis();
long j = this.c;
if (currentTimeMillis - j < this.i) {
return;
}
if (currentTimeMillis - j < 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() + Operators.BRACKET_START_STR + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber() + "),");
}
cf.a().b(new cg() {
@Override
public final void a() {
int i2;
StringBuilder sb = new StringBuilder(DeviceInfo.HTTP_PROTOCOL);
sb.append(fe.q());
sb.append("?host=dualstack-a.apilocate.amap.com&query=");
sb.append(i == ey.b ? 6 : 4);
String sb2 = sb.toString();
Log.i("yiyi.qi", "-------ipv6 request is ".concat(String.valueOf(sb2)));
ez ezVar = new ez();
ezVar.b(sb2);
ezVar.c(sb2);
ezVar.a(bh.a.SINGLE);
ezVar.a(bh.c.HTTP);
try {
bc.a();
JSONObject jSONObject = new JSONObject(new String(bc.a(ezVar).a));
String[] b2 = ey.b(jSONObject.optJSONArray("ips"), ey.a);
if (b2 != null && b2.length > 0 && !ey.b(b2, ey.this.b(ey.a).a())) {
ey.this.b(ey.a).a(b2);
ey.this.f(ey.a);
}
String[] b3 = ey.b(jSONObject.optJSONArray("ipsv6"), ey.b);
if (b3 != null && b3.length > 0 && !ey.b(b3, ey.this.b(ey.b).a())) {
ey.this.b(ey.b).a(b3);
ey.this.f(ey.b);
}
if ((jSONObject.has("ips") || jSONObject.has("ipsv6")) && jSONObject.has("ttl") && (i2 = jSONObject.getInt("ttl")) > 30) {
ey.this.i = i2 * 1000;
}
} catch (Throwable th) {
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put(IApp.ConfigProperty.CONFIG_KEY, "dnsError");
jSONObject2.put("reason", th.getMessage());
} catch (Throwable unused) {
}
fk.a(ey.this.j, "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 i = 0; i < length; i++) {
if (!strArr[i].equals(strArr2[i])) {
return false;
}
}
return true;
}
public static String[] b(JSONArray jSONArray, int i) throws JSONException {
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 = Operators.ARRAY_START_STR + string + Operators.ARRAY_END_STR;
}
strArr[i2] = string;
}
}
return strArr;
}
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 = fl.a(this.j, "cbG9jaXA");
fl.a(a2, c(i));
fl.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) {
g(i);
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 void f(int i) {
if (b(i).a() == null || b(i).a().length <= 0) {
return;
}
String str = b(i).a()[0];
if (str.equals(this.k) || this.f.contains(str)) {
return;
}
this.k = str;
SharedPreferences.Editor a2 = fl.a(this.j, "cbG9jaXA");
fl.a(a2, c(i), str);
fl.a(a2);
}
private void g(int i) {
String a2 = fl.a(this.j, "cbG9jaXA", c(i), (String) null);
if (TextUtils.isEmpty(a2) || this.f.contains(a2)) {
return;
}
b(i).a(a2);
b(i).b(a2);
b(i).a(true);
}
public final String a(fb fbVar, int i) {
try {
if (fe.p() && fbVar != null) {
String b2 = fbVar.b();
String host = new URL(b2).getHost();
if (!"http://abroad.apilocate.amap.com/mobile/binary".equals(b2) && !"abroad.apilocate.amap.com".equals(host)) {
String str = "apilocate.amap.com".equalsIgnoreCase(host) ? "httpdns.apilocate.amap.com" : host;
if (!l.d(str)) {
return null;
}
String e2 = e(i);
if (!TextUtils.isEmpty(e2)) {
fbVar.d(b2.replace(host, e2));
fbVar.a().put("host", str);
fbVar.e(str);
fbVar.a(i == b);
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 = fl.a(this.j, "cbG9jaXA");
fl.a(a2, c(i), b2);
fl.a(a2);
}
}
}