正在查看: Aptoide v9.22.5.3 应用的 e.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Aptoide v9.22.5.3 应用的 e.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package io.rakam.api;
import android.util.Log;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class e {
private static final h a = h.d();
protected static e b;
private volatile String d;
private volatile OkHttpClient f6275e;
private volatile String f6276f;
k f6279i = new k("diagnosticThread");
volatile boolean c = false;
int f6277g = 50;
String f6278h = "https://diagnostics.rakam.io/event/batch";
List<String> j = new ArrayList(this.f6277g);
Map<String, JSONObject> k = new HashMap(this.f6277g);
class a implements Runnable {
final String f6280f;
final Throwable f6281g;
a(String str, Throwable th) {
this.f6280f = str;
this.f6281g = th;
}
@Override
public void run() {
JSONObject jSONObject = e.this.k.get(this.f6280f);
try {
if (jSONObject != null) {
jSONObject.put("count", jSONObject.optInt("count", 0) + 1);
return;
}
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("error", g.i0(this.f6280f));
jSONObject2.put("timestamp", System.currentTimeMillis());
jSONObject2.put("device_id", e.this.f6276f);
jSONObject2.put("count", 1);
Throwable th = this.f6281g;
if (th != null) {
String stackTraceString = Log.getStackTraceString(th);
if (!j.d(stackTraceString)) {
jSONObject2.put("stack_trace", g.i0(stackTraceString));
}
}
if (e.this.j.size() >= e.this.f6277g) {
for (int i2 = 0; i2 < 5; i2++) {
e.this.k.remove(e.this.j.remove(0));
}
}
e.this.k.put(this.f6280f, jSONObject2);
e.this.j.add(this.f6280f);
} catch (JSONException unused) {
}
}
}
class b implements Runnable {
b() {
}
@Override
public void run() {
if (e.this.j.isEmpty()) {
return;
}
ArrayList arrayList = new ArrayList(e.this.j.size());
Iterator<String> it = e.this.j.iterator();
while (it.hasNext()) {
try {
arrayList.add(new JSONObject().put("properties", e.this.k.get(it.next())).put("collection", "android_sdk_error"));
} catch (JSONException e2) {
e.a.b("RakamDiagnostics", "Unable to serialize events: " + e2.getMessage());
}
}
if (new JSONArray((Collection) arrayList).length() > 0) {
e.this.h(new JSONArray((Collection) arrayList));
}
}
}
private e() {
this.f6279i.start();
}
static synchronized e e() {
e eVar;
synchronized (e.class) {
if (b == null) {
b = new e();
}
eVar = b;
}
return eVar;
}
e c(OkHttpClient okHttpClient, String str, String str2) {
this.c = true;
this.d = str;
this.f6275e = okHttpClient;
this.f6276f = str2;
return this;
}
e d() {
if (this.c && !j.d(this.d) && this.f6275e != null && !j.d(this.f6276f)) {
i(new b());
}
return this;
}
e f(String str) {
return g(str, null);
}
e g(String str, Throwable th) {
if (this.c && !j.d(str) && !j.d(this.f6276f)) {
i(new a(str, th));
}
return this;
}
protected void h(JSONArray jSONArray) {
try {
try {
if (this.f6275e.newCall(new Request.Builder().url(this.f6278h).post(RequestBody.create(g.a, new JSONObject().put("api", new JSONObject().put("api_key", this.d).put("library", new JSONObject().put("name", "rakam-android").put("version", "2.7.14")).put("upload_time", System.currentTimeMillis())).put("events", jSONArray).toString())).build()).execute().body().string().equals("1")) {
this.k.clear();
this.j.clear();
}
} catch (IOException | AssertionError | Exception unused) {
}
} catch (JSONException e2) {
a.b("RakamDiagnostics", String.format("Failed to convert revenue object to JSON: %s", e2.toString()));
}
}
protected void i(Runnable runnable) {
Thread currentThread = Thread.currentThread();
k kVar = this.f6279i;
if (currentThread != kVar) {
kVar.a(runnable);
} else {
runnable.run();
}
}
}