20
20
import com .termux .shared .settings .preferences .TermuxPreferenceConstants ;
21
21
import com .termux .shared .data .DataUtils ;
22
22
import com .termux .shared .logger .Logger ;
23
+ import com .termux .shared .termux .AndroidUtils ;
23
24
import com .termux .shared .termux .TermuxUtils ;
24
25
25
26
import com .termux .shared .termux .TermuxConstants ;
@@ -86,7 +87,7 @@ public void run() {
86
87
87
88
Logger .logDebug (logTag , "A crash log file found at \" " + TermuxConstants .TERMUX_CRASH_LOG_FILE_PATH + "\" ." );
88
89
89
- sendCrashReportNotification (context , logTag , reportString , false );
90
+ sendCrashReportNotification (context , logTag , reportString , false , false );
90
91
}
91
92
}.start ();
92
93
}
@@ -97,13 +98,15 @@ public void run() {
97
98
*
98
99
* @param context The {@link Context} for operations.
99
100
* @param logTag The log tag to use for logging.
100
- * @param reportString The text for the crash report.
101
+ * @param message The message for the crash report.
101
102
* @param forceNotification If set to {@code true}, then a notification will be shown
102
103
* regardless of if pending intent is {@code null} or
103
104
* {@link TermuxPreferenceConstants.TERMUX_APP#KEY_CRASH_REPORT_NOTIFICATIONS_ENABLED}
104
105
* is {@code false}.
106
+ * @param addAppAndDeviceInfo If set to {@code true}, then app and device info will be appended
107
+ * to the message.
105
108
*/
106
- public static void sendCrashReportNotification (final Context context , String logTag , String reportString , boolean forceNotification ) {
109
+ public static void sendCrashReportNotification (final Context context , String logTag , String message , boolean forceNotification , boolean addAppAndDeviceInfo ) {
107
110
if (context == null ) return ;
108
111
109
112
TermuxAppSharedPreferences preferences = TermuxAppSharedPreferences .build (context );
@@ -121,7 +124,14 @@ public static void sendCrashReportNotification(final Context context, String log
121
124
122
125
Logger .logDebug (logTag , "Sending \" " + title + "\" notification." );
123
126
124
- Intent notificationIntent = ReportActivity .newInstance (context , new ReportInfo (UserAction .CRASH_REPORT .getName (), logTag , title , null , reportString , "\n \n " + TermuxUtils .getReportIssueMarkdownString (context ), true ));
127
+ StringBuilder reportString = new StringBuilder (message );
128
+
129
+ if (addAppAndDeviceInfo ) {
130
+ reportString .append ("\n \n " ).append (TermuxUtils .getAppInfoMarkdownString (context , true ));
131
+ reportString .append ("\n \n " ).append (AndroidUtils .getDeviceInfoMarkdownString (context ));
132
+ }
133
+
134
+ Intent notificationIntent = ReportActivity .newInstance (context , new ReportInfo (UserAction .CRASH_REPORT .getName (), logTag , title , null , reportString .toString (), "\n \n " + TermuxUtils .getReportIssueMarkdownString (context ), true ));
125
135
PendingIntent pendingIntent = PendingIntent .getActivity (context , 0 , notificationIntent , PendingIntent .FLAG_UPDATE_CURRENT );
126
136
127
137
// Setup the notification channel if not already set up
0 commit comments