中建乐购 v3.2.2版本的 MD5 值为:0553721e6bc6ba8dd67004696a555b81
以下内容为反编译后的 d.java 源代码,内容仅作参考
package com.tencent.mid.a;
import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
import com.tencent.mid.api.MidCallback;
import com.tencent.mid.api.MidConstants;
import com.tencent.mid.api.MidEntity;
import com.tencent.mid.api.MidService;
import com.tencent.mid.util.Util;
import com.tencent.mid.util.j;
import java.util.HashMap;
import org.json.JSONObject;
public class d {
private static String f11034b = "iikVs3FGzEQ23RaD1JlHsSWSI5Z26m2hX3gO51mH3ag=";
private static d f11035c;
private static Context f11036d;
Handler f11037a;
private d(Context context) {
this.f11037a = null;
try {
HandlerThread handlerThread = new HandlerThread("HttpManager");
handlerThread.start();
this.f11037a = new Handler(handlerThread.getLooper());
f11036d = context.getApplicationContext();
} catch (Throwable th) {
Util.logWarn(th);
}
}
public static Context a() {
return f11036d;
}
public static synchronized d a(Context context) {
d dVar;
synchronized (d.class) {
if (f11035c == null) {
f11035c = new d(context);
}
dVar = f11035c;
}
return dVar;
}
private String a(f fVar, MidCallback midCallback) {
int i2;
int a2 = fVar.a();
String b2 = fVar.b();
String str = "0";
if (a2 == 200) {
boolean z2 = false;
int i3 = -1;
if (Util.isStringValid(b2)) {
JSONObject jSONObject = new JSONObject(b2);
if (!jSONObject.isNull(MidEntity.TAG_MID)) {
str = jSONObject.optString(MidEntity.TAG_MID);
if (Util.isMidValid(str)) {
MidEntity midEntity = new MidEntity();
midEntity.setMid(str);
midEntity.setMac(Util.getWifiMacAddress(f11036d));
midEntity.setImei(Util.getImei(f11036d));
long optLong = !jSONObject.isNull("ts") ? jSONObject.optLong("ts") : System.currentTimeMillis();
midEntity.setTimestamps(optLong);
Util.logInfo("new mid midEntity:" + midEntity.toString());
midCallback.onSuccess(midEntity.toString());
com.tencent.mid.b.g.a(f11036d).a(midEntity);
z2 = true;
}
}
i2 = !jSONObject.isNull(com.tencent.mid.b.a.f11061c) ? jSONObject.getInt(com.tencent.mid.b.a.f11061c) : -1;
if (!jSONObject.isNull(com.tencent.mid.b.a.f11062d)) {
i3 = jSONObject.getInt(com.tencent.mid.b.a.f11062d);
}
} else {
i2 = -1;
}
com.tencent.mid.b.g.a(f11036d).a(i2, i3);
if (!z2) {
midCallback.onSuccess(com.tencent.mid.b.g.a(f11036d).a());
return str;
}
} else {
String str2 = "Server response error code:" + a2 + ", error:" + b2;
Util.logInfo(str2);
midCallback.onFail(a2, str2);
}
return str;
}
private String b() {
return Util.decode(f11034b);
}
public void b(g gVar, MidCallback midCallback) {
String httpUrl;
f a2;
try {
httpUrl = Util.getHttpUrl();
a2 = b.a(httpUrl);
} catch (Throwable th) {
try {
if (MidService.isEnableDebug()) {
Log.w("MID", "request MID from MID server failed, try to connect MTA server", th);
}
JSONObject jSONObject = new JSONObject();
gVar.a(jSONObject);
jSONObject.put("ky", "A81AG9CN6AE8");
Util.jsonPut(jSONObject, "rip", Util.getRemoteUrlIp("http://pingma.qq.com:80"));
a(b.a("http://pingma.qq.com:80/mstat/report/", "[" + jSONObject.toString() + "]"), midCallback);
} finally {
b.b();
}
}
if (a2.a() != 200) {
String str = "response code invalid:" + a2.a();
Util.logInfo(str);
midCallback.onFail(a2.a(), str);
return;
}
int i2 = 0;
String str2 = null;
JSONObject jSONObject2 = new JSONObject(a2.b());
if (!jSONObject2.isNull("rand")) {
i2 = jSONObject2.getInt("rand");
str2 = j.a(Util.getHMAC(b(), String.valueOf(i2)));
}
if (str2 != null && i2 != 0) {
HashMap hashMap = new HashMap();
hashMap.put("k", str2);
hashMap.put("s", String.valueOf(i2));
String str3 = httpUrl + b.a(hashMap);
f a3 = b.a(str3);
if (a3.a() != 200) {
Util.logInfo("hmac invalid.");
midCallback.onFail(a3.a(), "hmac invalid.");
return;
}
JSONObject jSONObject3 = new JSONObject();
gVar.a(jSONObject3);
Util.jsonPut(jSONObject3, "rip", Util.getRemoteUrlIp(Util.getHttpUrl()));
String a4 = a(b.a(str3, "[" + jSONObject3.toString() + "]"), midCallback);
if (!Util.isMidValid(jSONObject3.optString(MidEntity.TAG_MID)) && !Util.isMidValid(a4)) {
throw new Exception("get Mid failed, something wrong");
}
return;
}
Util.logInfo("hmac == null");
}
public void a(g gVar, MidCallback midCallback) {
if (gVar == null || this.f11037a == null || midCallback == null) {
if (midCallback != null) {
midCallback.onFail(MidConstants.ERROR_ARGUMENT, "packet == null || handler == null");
}
} else if (Thread.currentThread().getId() == this.f11037a.getLooper().getThread().getId()) {
b(gVar, midCallback);
} else {
this.f11037a.post(new e(this, gVar, midCallback));
}
}
}