From abd7fecb700d8dffe2e0d04247130e7f5e5199aa Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 1 Dec 2018 15:38:02 +0100 Subject: [PATCH] Added operations to debug info --- .../java/eu/faircode/email/ActivityView.java | 42 ++++++++++++++++++- .../java/eu/faircode/email/DaoOperation.java | 3 ++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index b458a42fc6..80705e3904 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -898,11 +898,51 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB } } + // Attach operations + { + EntityAttachment ops = new EntityAttachment(); + ops.message = draft.id; + ops.sequence = 2; + ops.name = "operations.txt"; + ops.type = "text/plain"; + ops.size = null; + ops.progress = 0; + ops.id = db.attachment().insertAttachment(ops); + + OutputStream os = null; + File file = EntityAttachment.getFile(context, ops.id); + try { + os = new BufferedOutputStream(new FileOutputStream(file)); + + int size = 0; + DateFormat DF = SimpleDateFormat.getTimeInstance(); + for (EntityOperation op : db.operation().getOperations()) { + String line = String.format("%s %d %s %s %s\r\n", + DF.format(op.created), + op.message, + op.name, + op.args, + op.error); + byte[] bytes = line.getBytes(); + os.write(bytes); + size += bytes.length; + } + + ops.size = size; + ops.progress = null; + ops.available = true; + db.attachment().updateAttachment(ops); + } finally { + if (os != null) + os.close(); + } + } + // Attach logcat { EntityAttachment logcat = new EntityAttachment(); logcat.message = draft.id; - logcat.sequence = 2; + logcat.sequence = 3; logcat.name = "logcat.txt"; logcat.type = "text/plain"; logcat.size = null; diff --git a/app/src/main/java/eu/faircode/email/DaoOperation.java b/app/src/main/java/eu/faircode/email/DaoOperation.java index 9e0770dde1..74709de65a 100644 --- a/app/src/main/java/eu/faircode/email/DaoOperation.java +++ b/app/src/main/java/eu/faircode/email/DaoOperation.java @@ -37,6 +37,9 @@ public interface DaoOperation { @Query("SELECT * FROM operation ORDER BY id") LiveData> liveOperations(); + @Query("SELECT * FROM operation ORDER BY id") + List getOperations(); + @Query("SELECT COUNT(id) FROM operation WHERE folder = :folder") int getOperationCount(long folder);