Added task monitoring

This commit is contained in:
M66B
2021-06-18 08:37:11 +02:00
parent fbfa16eb73
commit 68be0cb204
2 changed files with 78 additions and 4 deletions

View File

@@ -1542,11 +1542,12 @@ public class Log {
attachNetworkInfo(context, draft.id, 3);
attachLog(context, draft.id, 4);
attachOperations(context, draft.id, 5);
attachLogcat(context, draft.id, 6);
attachTasks(context, draft.id, 6);
attachLogcat(context, draft.id, 7);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
attachNotificationInfo(context, draft.id, 7);
attachNotificationInfo(context, draft.id, 8);
//if (MessageClassifier.isEnabled(context))
// attachClassifierData(context, draft.id, 8);
// attachClassifierData(context, draft.id, 9);
EntityOperation.queue(context, draft, EntityOperation.ADD);
@@ -2062,6 +2063,30 @@ public class Log {
db.attachment().setDownloaded(attachment.id, size);
}
private static void attachTasks(Context context, long id, int sequence) throws IOException {
DB db = DB.getInstance(context);
EntityAttachment attachment = new EntityAttachment();
attachment.message = id;
attachment.sequence = sequence;
attachment.name = "tasks.txt";
attachment.type = "text/plain";
attachment.disposition = Part.ATTACHMENT;
attachment.size = null;
attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment);
long size = 0;
File file = attachment.getFile(context);
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
for (SimpleTask task : SimpleTask.getList()) {
size += write(os, String.format("%s\r\n", task.toString()));
}
}
db.attachment().setDownloaded(attachment.id, size);
}
private static void attachLogcat(Context context, long id, int sequence) throws IOException {
DB db = DB.getInstance(context);