MCPcopy Create free account
hub / github.com/M66B/NetGuard / sendCrashReport

Method sendCrashReport

app/src/main/java/eu/faircode/netguard/Util.java:693–730  ·  view source on GitHub ↗
(Throwable ex, final Context context)

Source from the content-addressed store, hash-verified

691 }
692
693 public static void sendCrashReport(Throwable ex, final Context context) {
694 if (!isPlayStoreInstall(context) || Util.isDebuggable(context))
695 return;
696
697 try {
698 ApplicationErrorReport report = new ApplicationErrorReport();
699 report.packageName = report.processName = context.getPackageName();
700 report.time = System.currentTimeMillis();
701 report.type = ApplicationErrorReport.TYPE_CRASH;
702 report.systemApp = false;
703
704 ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo();
705 crash.exceptionClassName = ex.getClass().getSimpleName();
706 crash.exceptionMessage = ex.getMessage();
707
708 StringWriter writer = new StringWriter();
709 PrintWriter printer = new PrintWriter(writer);
710 ex.printStackTrace(printer);
711
712 crash.stackTrace = writer.toString();
713
714 StackTraceElement stack = ex.getStackTrace()[0];
715 crash.throwClassName = stack.getClassName();
716 crash.throwFileName = stack.getFileName();
717 crash.throwLineNumber = stack.getLineNumber();
718 crash.throwMethodName = stack.getMethodName();
719
720 report.crashInfo = crash;
721
722 final Intent bug = new Intent(Intent.ACTION_APP_ERROR);
723 bug.putExtra(Intent.EXTRA_BUG_REPORT, report);
724 bug.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
725 if (bug.resolveActivity(context.getPackageManager()) != null)
726 context.startActivity(bug);
727 } catch (Throwable exex) {
728 Log.e(TAG, exex.toString() + "\n" + Log.getStackTraceString(exex));
729 }
730 }
731
732 public static String getGeneralInfo(Context context) {
733 StringBuilder sb = new StringBuilder();

Callers

nothing calls this directly

Calls 3

isPlayStoreInstallMethod · 0.95
isDebuggableMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected