Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 e.java 源代码,内容仅作参考
package k.g0.a.a.b.x;
import android.text.TextUtils;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.ximalaya.ting.android.opensdk.model.xdcs.CdnConfigModel;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import k.g0.a.a.b.o;
import k.u.c.g0.c.j.d.k.i;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class e {
public static final String a = "http://xdcs-collector.test.ximalaya.com/api/v1/cdnAndroid";
public static final String b = "http://xdcs-collector.ximalaya.com/api/v1/cdnAndroid";
public static CdnConfigModel c;
public static HttpURLConnection d;
public static OutputStream f17262e;
public static InputStream f17263f;
public static void a(CdnConfigModel cdnConfigModel) {
c = cdnConfigModel;
}
public static String b(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
try {
return InetAddress.getByName(a(str)).getHostAddress();
} catch (UnknownHostException unused) {
return null;
}
}
public static CdnConfigModel a() {
return c;
}
public static void a(a aVar, CdnConfigModel cdnConfigModel) {
HttpURLConnection httpURLConnection;
if (aVar == null || cdnConfigModel == null) {
return;
}
try {
try {
d dVar = new d();
dVar.d("CDN");
dVar.a(aVar);
dVar.a(System.currentTimeMillis());
ArrayList arrayList = new ArrayList();
arrayList.add(dVar);
String a2 = a(arrayList);
d = o.e(TextUtils.isEmpty(cdnConfigModel.getCdnUrl()) ? b : cdnConfigModel.getCdnUrl());
String doMain = cdnConfigModel.getDoMain();
String path = cdnConfigModel.getPath();
StringBuffer stringBuffer = new StringBuffer();
HashMap<String, String> map = cdnConfigModel.getMap();
if (map != null) {
for (String str : map.keySet()) {
stringBuffer.append(str);
stringBuffer.append("=");
stringBuffer.append(map.get(str));
stringBuffer.append(";");
}
}
HttpURLConnection httpURLConnection2 = d;
httpURLConnection2.setRequestProperty("Cookie", stringBuffer.toString() + "domain=" + doMain + ";path=" + path);
d.setRequestProperty("User-Agent", cdnConfigModel.getUserAgent());
d.setRequestProperty("Content-Length", String.valueOf(a2.length()));
d.setRequestProperty("Content-Type", "application/json");
d.setRequestMethod("POST");
d.setConnectTimeout(5000);
d.setReadTimeout(5000);
d.connect();
OutputStream outputStream = d.getOutputStream();
f17262e = outputStream;
outputStream.write(a2.getBytes("utf-8"));
f17262e.flush();
f17262e.close();
f17263f = d.getInputStream();
OutputStream outputStream2 = f17262e;
if (outputStream2 != null) {
try {
outputStream2.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
InputStream inputStream = f17263f;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
httpURLConnection = d;
if (httpURLConnection == null) {
return;
}
} catch (Exception e4) {
e4.printStackTrace();
OutputStream outputStream3 = f17262e;
if (outputStream3 != null) {
try {
outputStream3.close();
} catch (IOException e5) {
e5.printStackTrace();
}
}
InputStream inputStream2 = f17263f;
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
httpURLConnection = d;
if (httpURLConnection == null) {
return;
}
}
httpURLConnection.disconnect();
d = null;
} catch (Throwable th) {
OutputStream outputStream4 = f17262e;
if (outputStream4 != null) {
try {
outputStream4.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
InputStream inputStream3 = f17263f;
if (inputStream3 != null) {
try {
inputStream3.close();
} catch (IOException e8) {
e8.printStackTrace();
}
}
HttpURLConnection httpURLConnection3 = d;
if (httpURLConnection3 != null) {
httpURLConnection3.disconnect();
d = null;
}
throw th;
}
}
public static String a(List<d> list) throws JSONException {
JSONObject jSONObject = new JSONObject();
JSONArray jSONArray = new JSONArray();
for (d dVar : list) {
if (dVar != null) {
JSONObject jSONObject2 = new JSONObject();
if (!TextUtils.isEmpty(dVar.h())) {
jSONObject2.put("viewId", dVar.h());
}
if (!TextUtils.isEmpty(dVar.a())) {
jSONObject2.put("parentSpanId", dVar.a());
}
if (!TextUtils.isEmpty(dVar.d())) {
jSONObject2.put("viewId", dVar.d());
}
if (!TextUtils.isEmpty(dVar.e())) {
jSONObject2.put("viewId", dVar.e());
}
if (dVar.f() >= 0) {
jSONObject2.put("ts", dVar.f());
}
if (dVar.c() >= 0) {
jSONObject2.put("seqId", dVar.c());
}
if (!TextUtils.isEmpty(dVar.g())) {
jSONObject2.put("type", dVar.g());
}
if (dVar.b() != null) {
a b2 = dVar.b();
JSONObject jSONObject3 = new JSONObject();
if (!TextUtils.isEmpty(b2.b())) {
jSONObject3.put("audioUrl", b2.b());
}
if (!TextUtils.isEmpty(b2.c())) {
jSONObject3.put("cdnIP", b2.c());
}
if (TextUtils.isEmpty(b2.f())) {
jSONObject3.put("downloadSpeed", "0.0");
} else {
jSONObject3.put("downloadSpeed", b2.f() + "");
}
if (!TextUtils.isEmpty(b2.i())) {
jSONObject3.put("errorType", b2.i());
}
if (!TextUtils.isEmpty(b2.j())) {
jSONObject3.put("exceptionReason", b2.j());
}
if (!TextUtils.isEmpty(b2.m())) {
jSONObject3.put(HiAnalyticsConstant.HaKey.BI_KEY_RESULT, b2.m());
}
if (!TextUtils.isEmpty(b2.o())) {
jSONObject3.put("type", b2.o());
}
if (!TextUtils.isEmpty(b2.p())) {
jSONObject3.put("viaInfo", b2.p());
}
if (b2.a() > 0) {
jSONObject3.put("audioBytes", b2.a() + "");
} else {
jSONObject3.put("audioBytes", 0);
}
if (b2.d() >= 0.0f) {
jSONObject3.put("connectedTime", b2.d() + "");
}
if (b2.n() >= 0) {
jSONObject3.put("timestamp", b2.n());
}
if (b2.l() != null) {
jSONObject3.put("range", b2.l());
}
if (b2.k() != null) {
jSONObject3.put("fileSize", b2.k());
}
if (!TextUtils.isEmpty(b2.h())) {
jSONObject3.put("downloaded", b2.h());
} else {
jSONObject3.put("downloaded", "");
}
if (!TextUtils.isEmpty(b2.g())) {
jSONObject3.put("downloadTime", b2.g());
} else {
jSONObject3.put("downloadTime", "");
}
if (!TextUtils.isEmpty(b2.e())) {
jSONObject3.put(i.B, b2.e());
} else {
jSONObject3.put(i.B, b.f17256n);
}
jSONObject3.put("timeout", b2.q());
jSONObject2.put("props", jSONObject3);
}
jSONArray.put(jSONObject2);
}
}
jSONObject.put("events", jSONArray);
return jSONObject.toString();
}
public static String a(Throwable th) {
StackTraceElement stackTraceElement = th.getStackTrace()[0];
if (stackTraceElement != null) {
if (TextUtils.isEmpty(th.getMessage())) {
return "null located at:" + stackTraceElement.toString();
}
return th.getMessage();
}
return th.getMessage();
}
public static String a(String str) {
if (str == null || str.trim().equals("")) {
return "";
}
Matcher matcher = Pattern.compile("(?<=//|)((\\w)+\\.)+\\w+").matcher(str);
return matcher.find() ? matcher.group() : "";
}
public static float a(float f2, boolean z2) {
String format;
if (f2 <= 0.0f) {
return 0.0f;
}
if (z2) {
format = new DecimalFormat(".0").format(f2);
} else if (f2 < 0.1d) {
return 0.001f;
} else {
format = new DecimalFormat(".000").format(f2 / 1000.0f);
}
try {
return Float.valueOf(format).floatValue();
} catch (Exception unused) {
return f2;
}
}
public static void a(String str, String str2) {
Method declaredMethod;
try {
Class<?> cls = Class.forName("com.ximalaya.ting.android.framework.manager.XDCSCollectUtil");
if (cls == null || (declaredMethod = cls.getDeclaredMethod("statErrorToXDCS", String.class, String.class)) == null) {
return;
}
declaredMethod.invoke(null, str, str2);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}