mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-27 10:17:18 +00:00
Extended debug info
This commit is contained in:
parent
7a320be76a
commit
f64b66179c
1 changed files with 95 additions and 22 deletions
|
@ -29,6 +29,10 @@ import android.content.IntentFilter;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -77,6 +81,7 @@ import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.mail.Address;
|
import javax.mail.Address;
|
||||||
|
@ -870,11 +875,82 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
draft.id = db.message().insertMessage(draft);
|
draft.id = db.message().insertMessage(draft);
|
||||||
draft.write(context, body);
|
draft.write(context, body);
|
||||||
|
|
||||||
|
// Attach settings
|
||||||
|
{
|
||||||
|
EntityAttachment ops = new EntityAttachment();
|
||||||
|
ops.message = draft.id;
|
||||||
|
ops.sequence = 1;
|
||||||
|
ops.name = "settings.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;
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
|
Map<String, ?> settings = prefs.getAll();
|
||||||
|
for (String key : settings.keySet())
|
||||||
|
size += write(os, key + "=" + settings.get(key) + "\r\n");
|
||||||
|
|
||||||
|
ops.size = size;
|
||||||
|
ops.progress = null;
|
||||||
|
ops.available = true;
|
||||||
|
db.attachment().updateAttachment(ops);
|
||||||
|
} finally {
|
||||||
|
if (os != null)
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach network info
|
||||||
|
{
|
||||||
|
EntityAttachment ops = new EntityAttachment();
|
||||||
|
ops.message = draft.id;
|
||||||
|
ops.sequence = 2;
|
||||||
|
ops.name = "network.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;
|
||||||
|
ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
|
||||||
|
|
||||||
|
NetworkInfo ani = cm.getActiveNetworkInfo();
|
||||||
|
size += write(os, "active=" + ani + "\r\n\r\n");
|
||||||
|
|
||||||
|
for (Network network : cm.getAllNetworks()) {
|
||||||
|
NetworkInfo ni = cm.getNetworkInfo(network);
|
||||||
|
NetworkCapabilities caps = cm.getNetworkCapabilities(network);
|
||||||
|
size += write(os, "network=" + ni + " capabilities=" + caps + "\r\n\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
ops.size = size;
|
||||||
|
ops.progress = null;
|
||||||
|
ops.available = true;
|
||||||
|
db.attachment().updateAttachment(ops);
|
||||||
|
} finally {
|
||||||
|
if (os != null)
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Attach recent log
|
// Attach recent log
|
||||||
{
|
{
|
||||||
EntityAttachment log = new EntityAttachment();
|
EntityAttachment log = new EntityAttachment();
|
||||||
log.message = draft.id;
|
log.message = draft.id;
|
||||||
log.sequence = 1;
|
log.sequence = 3;
|
||||||
log.name = "log.txt";
|
log.name = "log.txt";
|
||||||
log.type = "text/plain";
|
log.type = "text/plain";
|
||||||
log.size = null;
|
log.size = null;
|
||||||
|
@ -889,12 +965,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
int size = 0;
|
int size = 0;
|
||||||
long from = new Date().getTime() - 24 * 3600 * 1000L;
|
long from = new Date().getTime() - 24 * 3600 * 1000L;
|
||||||
DateFormat DF = SimpleDateFormat.getTimeInstance();
|
DateFormat DF = SimpleDateFormat.getTimeInstance();
|
||||||
for (EntityLog entry : db.log().getLogs(from)) {
|
|
||||||
String line = String.format("%s %s\r\n", DF.format(entry.time), entry.data);
|
for (EntityLog entry : db.log().getLogs(from))
|
||||||
byte[] bytes = line.getBytes();
|
size += write(os, String.format("%s %s\r\n", DF.format(entry.time), entry.data));
|
||||||
os.write(bytes);
|
|
||||||
size += bytes.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.size = size;
|
log.size = size;
|
||||||
log.progress = null;
|
log.progress = null;
|
||||||
|
@ -910,7 +983,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
{
|
{
|
||||||
EntityAttachment ops = new EntityAttachment();
|
EntityAttachment ops = new EntityAttachment();
|
||||||
ops.message = draft.id;
|
ops.message = draft.id;
|
||||||
ops.sequence = 2;
|
ops.sequence = 4;
|
||||||
ops.name = "operations.txt";
|
ops.name = "operations.txt";
|
||||||
ops.type = "text/plain";
|
ops.type = "text/plain";
|
||||||
ops.size = null;
|
ops.size = null;
|
||||||
|
@ -924,17 +997,14 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
|
|
||||||
int size = 0;
|
int size = 0;
|
||||||
DateFormat DF = SimpleDateFormat.getTimeInstance();
|
DateFormat DF = SimpleDateFormat.getTimeInstance();
|
||||||
for (EntityOperation op : db.operation().getOperations()) {
|
|
||||||
String line = String.format("%s %d %s %s %s\r\n",
|
for (EntityOperation op : db.operation().getOperations())
|
||||||
|
size += write(os, String.format("%s %d %s %s %s\r\n",
|
||||||
DF.format(op.created),
|
DF.format(op.created),
|
||||||
op.message == null ? -1 : op.message,
|
op.message == null ? -1 : op.message,
|
||||||
op.name,
|
op.name,
|
||||||
op.args,
|
op.args,
|
||||||
op.error);
|
op.error));
|
||||||
byte[] bytes = line.getBytes();
|
|
||||||
os.write(bytes);
|
|
||||||
size += bytes.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
ops.size = size;
|
ops.size = size;
|
||||||
ops.progress = null;
|
ops.progress = null;
|
||||||
|
@ -950,7 +1020,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
{
|
{
|
||||||
EntityAttachment logcat = new EntityAttachment();
|
EntityAttachment logcat = new EntityAttachment();
|
||||||
logcat.message = draft.id;
|
logcat.message = draft.id;
|
||||||
logcat.sequence = 3;
|
logcat.sequence = 5;
|
||||||
logcat.name = "logcat.txt";
|
logcat.name = "logcat.txt";
|
||||||
logcat.type = "text/plain";
|
logcat.type = "text/plain";
|
||||||
logcat.size = null;
|
logcat.size = null;
|
||||||
|
@ -973,13 +1043,10 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
||||||
|
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null)
|
||||||
line += "\r\n";
|
size += write(os, line + "\r\n");
|
||||||
byte[] bytes = line.getBytes();
|
|
||||||
os.write(bytes);
|
|
||||||
size += bytes.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
logcat.size = size;
|
logcat.size = size;
|
||||||
logcat.progress = null;
|
logcat.progress = null;
|
||||||
|
@ -1020,6 +1087,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
|
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int write(OutputStream os, String text) throws IOException {
|
||||||
|
byte[] bytes = text.getBytes();
|
||||||
|
os.write(bytes);
|
||||||
|
return bytes.length;
|
||||||
|
}
|
||||||
}.load(this, new Bundle());
|
}.load(this, new Bundle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue