Initial commit
This commit is contained in:
304
sources/com/tencent/bugly/proguard/y.java
Normal file
304
sources/com/tencent/bugly/proguard/y.java
Normal file
@@ -0,0 +1,304 @@
|
||||
package com.tencent.bugly.proguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Process;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/* compiled from: BUGLY */
|
||||
/* loaded from: classes.dex */
|
||||
public final class y {
|
||||
public static boolean a = true;
|
||||
private static SimpleDateFormat b = null;
|
||||
private static int c = 5120;
|
||||
private static StringBuilder d = null;
|
||||
private static StringBuilder e = null;
|
||||
private static boolean f = false;
|
||||
private static a g = null;
|
||||
private static String h = null;
|
||||
private static String i = null;
|
||||
private static Context j = null;
|
||||
private static String k = null;
|
||||
private static boolean l = false;
|
||||
private static boolean m = false;
|
||||
private static ExecutorService n;
|
||||
private static int o;
|
||||
private static final Object p = new Object();
|
||||
|
||||
/* compiled from: BUGLY */
|
||||
public static class a {
|
||||
private boolean a;
|
||||
private File b;
|
||||
private String c;
|
||||
private long d;
|
||||
private long e = 30720;
|
||||
|
||||
public a(String str) {
|
||||
if (str == null || str.equals("")) {
|
||||
return;
|
||||
}
|
||||
this.c = str;
|
||||
this.a = a();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean a() {
|
||||
try {
|
||||
this.b = new File(this.c);
|
||||
if (this.b.exists() && !this.b.delete()) {
|
||||
this.a = false;
|
||||
return false;
|
||||
}
|
||||
if (this.b.createNewFile()) {
|
||||
return true;
|
||||
}
|
||||
this.a = false;
|
||||
return false;
|
||||
} catch (Throwable th) {
|
||||
x.a(th);
|
||||
this.a = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean a(String str) {
|
||||
FileOutputStream fileOutputStream;
|
||||
if (!this.a) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
fileOutputStream = new FileOutputStream(this.b, true);
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
fileOutputStream = null;
|
||||
}
|
||||
try {
|
||||
fileOutputStream.write(str.getBytes("UTF-8"));
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
this.d += r10.length;
|
||||
this.a = true;
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
try {
|
||||
x.a(th);
|
||||
this.a = false;
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException unused2) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable th3) {
|
||||
if (fileOutputStream != null) {
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException unused3) {
|
||||
}
|
||||
}
|
||||
throw th3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
b = new SimpleDateFormat("MM-dd HH:mm:ss");
|
||||
} catch (Throwable unused) {
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void a(Context context) {
|
||||
synchronized (y.class) {
|
||||
if (l || context == null || !a) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
n = Executors.newSingleThreadExecutor();
|
||||
e = new StringBuilder(0);
|
||||
d = new StringBuilder(0);
|
||||
j = context;
|
||||
com.tencent.bugly.crashreport.common.info.a a2 = com.tencent.bugly.crashreport.common.info.a.a(context);
|
||||
h = a2.d;
|
||||
a2.getClass();
|
||||
i = "";
|
||||
k = j.getFilesDir().getPath() + "/buglylog_" + h + "_" + i + ".txt";
|
||||
o = Process.myPid();
|
||||
} catch (Throwable unused) {
|
||||
}
|
||||
l = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static boolean d(String str, String str2, String str3) {
|
||||
try {
|
||||
com.tencent.bugly.crashreport.common.info.a b2 = com.tencent.bugly.crashreport.common.info.a.b();
|
||||
if (b2 == null || b2.D == null) {
|
||||
return false;
|
||||
}
|
||||
return b2.D.appendLogToNative(str, str2, str3);
|
||||
} catch (Throwable th) {
|
||||
if (x.a(th)) {
|
||||
return false;
|
||||
}
|
||||
th.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static synchronized void e(String str, String str2, String str3) {
|
||||
synchronized (y.class) {
|
||||
long myTid = Process.myTid();
|
||||
d.setLength(0);
|
||||
if (str3.length() > 30720) {
|
||||
str3 = str3.substring(str3.length() - 30720, str3.length() - 1);
|
||||
}
|
||||
Date date = new Date();
|
||||
String format = b != null ? b.format(date) : date.toString();
|
||||
StringBuilder sb = d;
|
||||
sb.append(format);
|
||||
sb.append(" ");
|
||||
sb.append(o);
|
||||
sb.append(" ");
|
||||
sb.append(myTid);
|
||||
sb.append(" ");
|
||||
sb.append(str);
|
||||
sb.append(" ");
|
||||
sb.append(str2);
|
||||
sb.append(": ");
|
||||
sb.append(str3);
|
||||
sb.append("\u0001\r\n");
|
||||
String sb2 = d.toString();
|
||||
synchronized (p) {
|
||||
try {
|
||||
e.append(sb2);
|
||||
} catch (Throwable unused) {
|
||||
}
|
||||
if (e.length() <= c) {
|
||||
return;
|
||||
}
|
||||
if (f) {
|
||||
return;
|
||||
}
|
||||
f = true;
|
||||
if (g == null) {
|
||||
g = new a(k);
|
||||
} else if (g.b == null || g.b.length() + e.length() > g.e) {
|
||||
g.a();
|
||||
}
|
||||
if (g.a(e.toString())) {
|
||||
e.setLength(0);
|
||||
f = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String b() {
|
||||
try {
|
||||
com.tencent.bugly.crashreport.common.info.a b2 = com.tencent.bugly.crashreport.common.info.a.b();
|
||||
if (b2 == null || b2.D == null) {
|
||||
return null;
|
||||
}
|
||||
return b2.D.getLogFromNative();
|
||||
} catch (Throwable th) {
|
||||
if (x.a(th)) {
|
||||
return null;
|
||||
}
|
||||
th.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(int i2) {
|
||||
synchronized (p) {
|
||||
c = i2;
|
||||
if (i2 < 0) {
|
||||
c = 0;
|
||||
} else if (i2 > 10240) {
|
||||
c = 10240;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(boolean z) {
|
||||
x.a("[LogUtil] Whether can record user log into native: " + z, new Object[0]);
|
||||
m = z;
|
||||
}
|
||||
|
||||
public static void a(String str, String str2, Throwable th) {
|
||||
if (th == null) {
|
||||
return;
|
||||
}
|
||||
String message = th.getMessage();
|
||||
if (message == null) {
|
||||
message = "";
|
||||
}
|
||||
a(str, str2, message + '\n' + z.b(th));
|
||||
}
|
||||
|
||||
public static synchronized void a(final String str, final String str2, final String str3) {
|
||||
synchronized (y.class) {
|
||||
if (l && a) {
|
||||
try {
|
||||
} catch (Exception e2) {
|
||||
x.b(e2);
|
||||
}
|
||||
if (m) {
|
||||
n.execute(new Runnable() { // from class: com.tencent.bugly.proguard.y.1
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
if (y.d(str, str2, str3)) {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
n.execute(new Runnable() { // from class: com.tencent.bugly.proguard.y.2
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
y.e(str, str2, str3);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] a() {
|
||||
if (!a) {
|
||||
return null;
|
||||
}
|
||||
if (m) {
|
||||
x.a("[LogUtil] Get user log from native.", new Object[0]);
|
||||
String b2 = b();
|
||||
if (b2 != null) {
|
||||
x.a("[LogUtil] Got user log from native: %d bytes", Integer.valueOf(b2.length()));
|
||||
return z.a((File) null, b2, "BuglyNativeLog.txt");
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
synchronized (p) {
|
||||
if (g != null && g.a && g.b != null && g.b.length() > 0) {
|
||||
sb.append(z.a(g.b, 30720, true));
|
||||
}
|
||||
if (e != null && e.length() > 0) {
|
||||
sb.append(e.toString());
|
||||
}
|
||||
}
|
||||
return z.a((File) null, sb.toString(), "BuglyLog.txt");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user