diff --git a/app/src/main/java/com/termux/app/TermuxInstaller.java b/app/src/main/java/com/termux/app/TermuxInstaller.java index 19ade92079..60c5dc00de 100644 --- a/app/src/main/java/com/termux/app/TermuxInstaller.java +++ b/app/src/main/java/com/termux/app/TermuxInstaller.java @@ -196,7 +196,7 @@ public static void showBootstrapErrorDialog(Activity activity, String PREFIX_FIL Logger.logErrorExtended(LOG_TAG, "Bootstrap Error:\n" + message); // Send a notification with the exception so that the user knows why bootstrap setup failed - CrashUtils.sendCrashReportNotification(activity, LOG_TAG, "## Bootstrap Error\n\n" + message, true); + CrashUtils.sendCrashReportNotification(activity, LOG_TAG, "## Bootstrap Error\n\n" + message, true, true); activity.runOnUiThread(() -> { try { @@ -231,7 +231,7 @@ public void run() { if (error != null) { Logger.logErrorAndShowToast(context, LOG_TAG, error.getMessage()); Logger.logErrorExtended(LOG_TAG, "Setup Storage Error\n" + error.toString()); - CrashUtils.sendCrashReportNotification(context, LOG_TAG, "## Setup Storage Error\n\n" + Error.getErrorMarkdownString(error), true); + CrashUtils.sendCrashReportNotification(context, LOG_TAG, "## Setup Storage Error\n\n" + Error.getErrorMarkdownString(error), true, true); return; } @@ -270,7 +270,7 @@ public void run() { } catch (Exception e) { Logger.logErrorAndShowToast(context, LOG_TAG, e.getMessage()); Logger.logStackTraceWithMessage(LOG_TAG, "Setup Storage Error: Error setting up link", e); - CrashUtils.sendCrashReportNotification(context, LOG_TAG, "## Setup Storage Error\n\n" + Logger.getStackTracesMarkdownString(null, Logger.getStackTracesStringArray(e)), true); + CrashUtils.sendCrashReportNotification(context, LOG_TAG, "## Setup Storage Error\n\n" + Logger.getStackTracesMarkdownString(null, Logger.getStackTracesStringArray(e)), true, true); } } }.start(); diff --git a/app/src/main/java/com/termux/app/utils/CrashUtils.java b/app/src/main/java/com/termux/app/utils/CrashUtils.java index 1437e234ca..f9ebe779b3 100644 --- a/app/src/main/java/com/termux/app/utils/CrashUtils.java +++ b/app/src/main/java/com/termux/app/utils/CrashUtils.java @@ -20,6 +20,7 @@ import com.termux.shared.settings.preferences.TermuxPreferenceConstants; import com.termux.shared.data.DataUtils; import com.termux.shared.logger.Logger; +import com.termux.shared.termux.AndroidUtils; import com.termux.shared.termux.TermuxUtils; import com.termux.shared.termux.TermuxConstants; @@ -86,7 +87,7 @@ public void run() { Logger.logDebug(logTag, "A crash log file found at \"" + TermuxConstants.TERMUX_CRASH_LOG_FILE_PATH + "\"."); - sendCrashReportNotification(context, logTag, reportString, false); + sendCrashReportNotification(context, logTag, reportString, false, false); } }.start(); } @@ -97,13 +98,15 @@ public void run() { * * @param context The {@link Context} for operations. * @param logTag The log tag to use for logging. - * @param reportString The text for the crash report. + * @param message The message for the crash report. * @param forceNotification If set to {@code true}, then a notification will be shown * regardless of if pending intent is {@code null} or * {@link TermuxPreferenceConstants.TERMUX_APP#KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED} * is {@code false}. + * @param addAppAndDeviceInfo If set to {@code true}, then app and device info will be appended + * to the message. */ - public static void sendCrashReportNotification(final Context context, String logTag, String reportString, boolean forceNotification) { + public static void sendCrashReportNotification(final Context context, String logTag, String message, boolean forceNotification, boolean addAppAndDeviceInfo) { if (context == null) return; TermuxAppSharedPreferences preferences = TermuxAppSharedPreferences.build(context); @@ -121,7 +124,14 @@ public static void sendCrashReportNotification(final Context context, String log Logger.logDebug(logTag, "Sending \"" + title + "\" notification."); - Intent notificationIntent = ReportActivity.newInstance(context, new ReportInfo(UserAction.CRASH_REPORT.getName(), logTag, title, null, reportString, "\n\n" + TermuxUtils.getReportIssueMarkdownString(context), true)); + StringBuilder reportString = new StringBuilder(message); + + if (addAppAndDeviceInfo) { + reportString.append("\n\n").append(TermuxUtils.getAppInfoMarkdownString(context, true)); + reportString.append("\n\n").append(AndroidUtils.getDeviceInfoMarkdownString(context)); + } + + Intent notificationIntent = ReportActivity.newInstance(context, new ReportInfo(UserAction.CRASH_REPORT.getName(), logTag, title, null, reportString.toString(), "\n\n" + TermuxUtils.getReportIssueMarkdownString(context), true)); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Setup the notification channel if not already set up