搜书大师 v23.2版本的 MD5 值为:5ee433f6456b6278bd6e80a5d44df55e
以下内容为反编译后的 CrashHandler2.java 源代码,内容仅作参考
package com.flyersoft.baseapplication;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Looper;
import android.text.ClipboardManager;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.core.app.NotificationCompat;
import java.lang.Thread;
public class CrashHandler2 {
private static CrashHandler2 INSTANCE = new CrashHandler2();
private Activity activity;
Thread.UncaughtExceptionHandler eh = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
CrashHandler2.this.doUncaughtException(t, e);
}
};
public Context getContext() {
Activity activity = this.activity;
if (activity != null && !activity.isFinishing()) {
return this.activity;
}
return z2.getContext();
}
public static CrashHandler2 getInstance() {
return INSTANCE;
}
public static void reportEmail(Context act, String title, String content, final boolean restart) {
try {
title = title + act.getPackageManager().getPackageInfo(act.getPackageName(), 0).versionName;
z2.log(content);
} catch (Throwable th) {
z2.error(th);
}
try {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("plain/text");
intent.putExtra("android.intent.extra.EMAIL", new String[]{"soushushenqi@163.com"});
intent.putExtra("android.intent.extra.SUBJECT", title);
intent.putExtra("android.intent.extra.TEXT", content);
act.startActivity(intent);
if (restart) {
System.exit(0);
}
} catch (Throwable th2) {
z2.error(th2);
reportQQ(act, content);
}
}
public static void reportQQ(final Context act, String content) {
try {
FrameLayout frameLayout = new FrameLayout(act);
EditText editText = new EditText(act);
editText.setTextSize(12.0f);
editText.setText(content);
frameLayout.setPadding(z2.d(26.0f), z2.d(20.0f), z2.d(26.0f), z2.d(20.0f));
frameLayout.addView(editText, -1, -2);
new AlertDialog.Builder(act).setTitle("客服Q群" + z2.qqNumber + ",请长按拷贝以下内容发给我们").setCancelable(false).setView(frameLayout).setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Context context = act;
if (context instanceof Activity) {
((Activity) context).finish();
}
}
}).show();
} catch (Throwable unused) {
}
}
private void restartApp() {
System.exit(0);
}
public void showErrDlg(String tip, final String err) {
try {
TextView textView = new TextView(getContext());
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setPadding(z2.d(26.0f), z2.d(20.0f), z2.d(26.0f), z2.d(20.0f));
textView.setText(Html.fromHtml(tip));
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("搜书大师发生错误").setCancelable(false).setView(textView).setPositiveButton("提交", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
CrashHandler2.reportEmail(CrashHandler2.this.getContext(), "#错误反馈#", err, false);
}
});
if (z2.isOldAppVersion()) {
builder.setNeutralButton("查看新版本", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
z2.openMarketPage(CrashHandler2.this.getContext());
}
});
} else {
builder.setNeutralButton("拷贝错误日志", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
((ClipboardManager) CrashHandler2.this.getContext().getSystemService("clipboard")).setText(err);
z2.showToastText(CrashHandler2.this.getContext(), "已复制到粘贴板", 0);
} catch (Throwable th) {
z2.error(th);
}
}
});
}
builder.show();
} catch (Throwable th) {
z2.error(th);
}
}
public void doUncaughtException(Thread thread, Throwable ex) {
String sb;
z2.log("******uncaughtException*******");
final StringBuilder sb2 = new StringBuilder();
try {
sb2.append("-----------");
String message = ex.getMessage();
String th = message == null ? ex.toString() : message + " | " + ex.toString();
if (th.length() > 0) {
sb2.append("\n" + th + "\n-----------");
}
for (StackTraceElement stackTraceElement : ex.getStackTrace()) {
sb2.append("\n" + stackTraceElement.toString());
}
sb = sb2.toString();
} catch (Throwable th2) {
z2.error(th2);
}
if (!sb.contains("Exception thrown on Scheduler.Worker thread. Add `onError` handling") && !sb.contains(".reactivex.exceptions.UndeliverableException") && !sb.contains("missing onError handler in the subscribe()")) {
z2.log("###CRASH ERROR###:\n" + sb2.toString());
if (z2.getFileSize(z2.errorSaveFile()) > 100000) {
z2.deleteFile(z2.errorSaveFile());
}
z2.appendFileText(z2.errorSaveFile(), "\n\n======CRASH======" + z2.dateTimeToStr(Long.valueOf(System.currentTimeMillis())) + Build.ID + "|" + Build.VERSION.RELEASE + "\n" + sb2.toString());
if (z2.signatureSubject != null) {
sb2.insert(0, z2.signatureSerial + "\n");
}
sb2.insert(0, z2.appDetailInfo);
sb2.insert(0, "请描述如何操作可以重现这个问题:\n\n-----------\n");
StringBuilder sb3 = new StringBuilder();
sb3.append("请点击提交按键, 选择邮件方式发送错误日志给我们检查; 或者用QQ联系我们(");
sb3.append(z2.qqNumber);
sb3.append("), 告知错误是如何发生的, 谢谢您的支持!");
sb3.append(z2.isOldAppVersion() ? "<br><br>(提示: 应用市场有搜书大师的新版本, 可能已经修复该错误, 建议先升级到新版)" : "");
final String sb4 = sb3.toString();
new Thread() {
@Override
public void run() {
Looper.prepare();
z2.log("******uncaughtException*******(2)" + z2.getROMInfo());
boolean z = false;
boolean z2 = CrashHandler2.this.activity == null || CrashHandler2.this.activity.isFinishing();
if (Build.VERSION.SDK_INT >= 29 && z2.getROMInfo().contains("huawei")) {
z = true;
}
if (!z && !z2) {
CrashHandler2.this.showErrDlg(sb4, sb2.toString());
} else {
Intent intent = new Intent(z2.getContext(), (Class<?>) CrashActivity.class);
intent.setFlags(268435456);
intent.putExtra("tip", sb4);
intent.putExtra(NotificationCompat.CATEGORY_ERROR, sb2.toString());
CrashHandler2.this.getContext().startActivity(intent);
}
Looper.loop();
}
}.start();
return;
}
z2.log("*************RxJava********CRASH*********");
z2.log(sb2.toString());
}
public void init() {
Thread.setDefaultUncaughtExceptionHandler(this.eh);
}
public void setCurActivity(Activity act) {
this.activity = act;
}
}