mirror of https://github.com/M66B/FairEmail.git
Added log filtering
This commit is contained in:
parent
40ea1c3cb9
commit
acee2a5014
|
@ -51,7 +51,9 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
private int colorAccent;
|
||||
private int colorWarning;
|
||||
|
||||
private List<EntityLog> items = new ArrayList<>();
|
||||
List<EntityLog.Type> types = new ArrayList<>();
|
||||
private List<EntityLog> all = new ArrayList<>();
|
||||
private List<EntityLog> selected = new ArrayList<>();
|
||||
|
||||
private DateFormat TF;
|
||||
|
||||
|
@ -70,21 +72,21 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
tvTime.setText(TF.format(log.time));
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder(log.data);
|
||||
switch (log.type) {
|
||||
case EntityLog.LOG_GENERAL:
|
||||
case General:
|
||||
break;
|
||||
case EntityLog.LOG_STATS:
|
||||
case Statistics:
|
||||
ssb.setSpan(new ForegroundColorSpan(colorAccent), 0, ssb.length(), 0);
|
||||
break;
|
||||
case EntityLog.LOG_SCHEDULE:
|
||||
case Scheduling:
|
||||
ssb.setSpan(new ForegroundColorSpan(colorWarning), 0, ssb.length(), 0);
|
||||
break;
|
||||
case EntityLog.LOG_NETWORK:
|
||||
case Network:
|
||||
ssb.setSpan(new ForegroundColorSpan(colorWarning), 0, ssb.length(), 0);
|
||||
break;
|
||||
case EntityLog.LOG_ACCOUNT:
|
||||
case Account:
|
||||
ssb.setSpan(new ForegroundColorSpan(colorAccent), 0, ssb.length(), 0);
|
||||
break;
|
||||
case EntityLog.LOG_PROTOCOL:
|
||||
case Protocol:
|
||||
ssb.setSpan(new ForegroundColorSpan(textColorSecondary), 0, ssb.length(), 0);
|
||||
break;
|
||||
}
|
||||
|
@ -115,12 +117,20 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
});
|
||||
}
|
||||
|
||||
public void set(@NonNull List<EntityLog> logs) {
|
||||
public void set(@NonNull List<EntityLog> logs, @NonNull List<EntityLog.Type> types) {
|
||||
Log.i("Set logs=" + logs.size());
|
||||
|
||||
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, logs), false);
|
||||
this.all = logs;
|
||||
this.types = types;
|
||||
|
||||
items = logs;
|
||||
List<EntityLog> items = new ArrayList<>();
|
||||
for (EntityLog log : all)
|
||||
if (types.contains(log.type))
|
||||
items.add(log);
|
||||
|
||||
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(selected, items), false);
|
||||
|
||||
this.selected = items;
|
||||
|
||||
diff.dispatchUpdatesTo(new ListUpdateCallback() {
|
||||
@Override
|
||||
|
@ -146,6 +156,10 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
diff.dispatchUpdatesTo(this);
|
||||
}
|
||||
|
||||
public void setTypes(@NonNull List<EntityLog.Type> types) {
|
||||
set(all, types);
|
||||
}
|
||||
|
||||
private static class DiffCallback extends DiffUtil.Callback {
|
||||
private List<EntityLog> prev = new ArrayList<>();
|
||||
private List<EntityLog> next = new ArrayList<>();
|
||||
|
@ -182,12 +196,12 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return items.get(position).id;
|
||||
return selected.get(position).id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
return selected.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -198,7 +212,7 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
EntityLog log = items.get(position);
|
||||
EntityLog log = selected.get(position);
|
||||
holder.bindTo(log);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@ import static androidx.core.app.NotificationCompat.DEFAULT_LIGHTS;
|
|||
import static androidx.core.app.NotificationCompat.DEFAULT_SOUND;
|
||||
import static javax.mail.Folder.READ_WRITE;
|
||||
|
||||
import static eu.faircode.email.EntityLog.LOG_STATS;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
|
@ -1482,7 +1480,7 @@ class Core {
|
|||
}
|
||||
|
||||
if (!stats.isEmpty())
|
||||
EntityLog.log(context, LOG_STATS,
|
||||
EntityLog.log(context, EntityLog.Type.Statistics,
|
||||
account.name + "/" + folder.name + " fetch stats " + stats);
|
||||
} catch (MessageRemovedException | MessageRemovedIOException ex) {
|
||||
Log.i(ex);
|
||||
|
@ -3209,7 +3207,7 @@ class Core {
|
|||
|
||||
stats.total = (SystemClock.elapsedRealtime() - search);
|
||||
|
||||
EntityLog.log(context, LOG_STATS,
|
||||
EntityLog.log(context, EntityLog.Type.Statistics,
|
||||
account.name + "/" + folder.name + " sync stats " + stats);
|
||||
} finally {
|
||||
Log.i(folder.name + " end sync state=" + state);
|
||||
|
|
|
@ -2104,7 +2104,7 @@ public abstract class DB extends RoomDatabase {
|
|||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `log` ADD COLUMN `type` INTEGER NOT NULL DEFAULT " + EntityLog.LOG_GENERAL);
|
||||
db.execSQL("ALTER TABLE `log` ADD COLUMN `type` INTEGER NOT NULL DEFAULT " + EntityLog.Type.General.ordinal());
|
||||
}
|
||||
}).addMigrations(new Migration(998, 999) {
|
||||
@Override
|
||||
|
@ -2234,6 +2234,15 @@ public abstract class DB extends RoomDatabase {
|
|||
}
|
||||
return result.toArray(new Address[0]);
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
public static EntityLog.Type toLogType(int ordinal) {
|
||||
return EntityLog.Type.values()[ordinal];
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
public static int fromLogType(EntityLog.Type type) {
|
||||
return type.ordinal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ package eu.faircode.email;
|
|||
Copyright 2018-2021 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import static eu.faircode.email.EntityLog.LOG_PROTOCOL;
|
||||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL;
|
||||
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_OAUTH;
|
||||
|
||||
|
@ -577,7 +576,7 @@ public class EmailService implements AutoCloseable {
|
|||
String line = bos.toString();
|
||||
if (!line.endsWith("ignoring socket timeout"))
|
||||
if (log)
|
||||
EntityLog.log(context, LOG_PROTOCOL, user + " " + line);
|
||||
EntityLog.log(context, EntityLog.Type.Protocol, user + " " + line);
|
||||
else {
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.i("javamail", user + " " + line);
|
||||
|
|
|
@ -55,25 +55,20 @@ public class EntityLog {
|
|||
@NonNull
|
||||
public Long time;
|
||||
@NonNull
|
||||
public Integer type = LOG_GENERAL;
|
||||
public Type type = Type.General;
|
||||
@NonNull
|
||||
public String data;
|
||||
|
||||
static final int LOG_GENERAL = 0;
|
||||
static final int LOG_STATS = 1;
|
||||
static final int LOG_SCHEDULE = 2;
|
||||
static final int LOG_NETWORK = 3;
|
||||
static final int LOG_ACCOUNT = 4;
|
||||
static final int LOG_PROTOCOL = 5;
|
||||
enum Type {General, Statistics, Scheduling, Network, Account, Protocol}
|
||||
|
||||
private static final ExecutorService executor =
|
||||
Helper.getBackgroundExecutor(1, "log");
|
||||
|
||||
static void log(final Context context, String data) {
|
||||
log(context, LOG_GENERAL, data);
|
||||
log(context, Type.General, data);
|
||||
}
|
||||
|
||||
static void log(final Context context, int type, String data) {
|
||||
static void log(final Context context, Type type, String data) {
|
||||
Log.i(data);
|
||||
|
||||
if (context == null)
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
@ -39,6 +40,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FragmentLogs extends FragmentBase {
|
||||
private RecyclerView rvLog;
|
||||
|
@ -46,8 +48,16 @@ public class FragmentLogs extends FragmentBase {
|
|||
private Group grpReady;
|
||||
|
||||
private boolean autoScroll = true;
|
||||
|
||||
private AdapterLog adapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null)
|
||||
autoScroll = savedInstanceState.getBoolean("fair:scroll");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
@ -90,7 +100,7 @@ public class FragmentLogs extends FragmentBase {
|
|||
if (logs == null)
|
||||
logs = new ArrayList<>();
|
||||
|
||||
adapter.set(logs);
|
||||
adapter.set(logs, getTypes());
|
||||
if (autoScroll)
|
||||
rvLog.scrollToPosition(0);
|
||||
|
||||
|
@ -100,6 +110,12 @@ public class FragmentLogs extends FragmentBase {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putBoolean("fair:scroll", autoScroll);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.menu_logs, menu);
|
||||
|
@ -113,6 +129,14 @@ public class FragmentLogs extends FragmentBase {
|
|||
|
||||
menu.findItem(R.id.menu_enabled).setChecked(main_log);
|
||||
menu.findItem(R.id.menu_auto_scroll).setChecked(autoScroll);
|
||||
|
||||
List<EntityLog.Type> types = getTypes();
|
||||
SubMenu smenu = menu.findItem(R.id.menu_show).getSubMenu();
|
||||
smenu.clear();
|
||||
for (EntityLog.Type type : EntityLog.Type.values())
|
||||
smenu.add(1, type.ordinal(), type.ordinal(), type.toString())
|
||||
.setCheckable(true).setChecked(types.contains(type));
|
||||
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -121,14 +145,18 @@ public class FragmentLogs extends FragmentBase {
|
|||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.menu_enabled) {
|
||||
boolean enabled = !item.isChecked();
|
||||
onMenuEnable(enabled);
|
||||
item.setChecked(enabled);
|
||||
onMenuEnable(enabled);
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_auto_scroll) {
|
||||
boolean enabled = !item.isChecked();
|
||||
onMenuAutoScoll(enabled);
|
||||
item.setChecked(enabled);
|
||||
onMenuAutoScoll(enabled);
|
||||
return true;
|
||||
} else if (item.getGroupId() == 1 && item.isCheckable()) {
|
||||
boolean enabled = !item.isChecked();
|
||||
item.setChecked(enabled);
|
||||
onMenuShowTypes(item.getOrder(), enabled);
|
||||
} else if (itemId == R.id.menu_clear) {
|
||||
onMenuClear();
|
||||
return true;
|
||||
|
@ -145,6 +173,26 @@ public class FragmentLogs extends FragmentBase {
|
|||
autoScroll = enabled;
|
||||
}
|
||||
|
||||
private void onMenuShowTypes(int ordinal, boolean enabled) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
String name = EntityLog.Type.values()[ordinal].toString().toLowerCase(Locale.ROOT);
|
||||
prefs.edit().putBoolean("show_log_" + name, enabled).apply();
|
||||
adapter.setTypes(getTypes());
|
||||
}
|
||||
|
||||
private List<EntityLog.Type> getTypes() {
|
||||
List<EntityLog.Type> types = new ArrayList<>();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
for (EntityLog.Type type : EntityLog.Type.values()) {
|
||||
String name = type.toString().toLowerCase(Locale.ROOT);
|
||||
if (prefs.getBoolean("show_log_" + name, true))
|
||||
types.add(type);
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
private void onMenuClear() {
|
||||
EntityLog.clear(getContext());
|
||||
}
|
||||
|
|
|
@ -21,10 +21,6 @@ package eu.faircode.email;
|
|||
|
||||
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
||||
|
||||
import static eu.faircode.email.EntityLog.LOG_ACCOUNT;
|
||||
import static eu.faircode.email.EntityLog.LOG_NETWORK;
|
||||
import static eu.faircode.email.EntityLog.LOG_SCHEDULE;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
|
@ -277,7 +273,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
int index = accountStates.indexOf(current);
|
||||
if (index < 0) {
|
||||
if (current.canRun()) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### new " + current +
|
||||
" force=" + force +
|
||||
" start=" + current.canRun() +
|
||||
|
@ -313,7 +309,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
prev.canRun() != current.canRun() ||
|
||||
!prev.accountState.equals(current.accountState)) {
|
||||
if (prev.canRun() || current.canRun())
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### changed " + current +
|
||||
" reload=" + reload +
|
||||
" force=" + force +
|
||||
|
@ -342,7 +338,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
if (state != null) {
|
||||
Network p = prev.networkState.getActive();
|
||||
if (p != null && !p.equals(current.networkState.getActive())) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### changed " + current +
|
||||
" active=" + prev.networkState.getActive() + "/" + current.networkState.getActive());
|
||||
state.error(new OperationCanceledException("Active network changed"));
|
||||
|
@ -361,7 +357,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
if (event) {
|
||||
lastEventId++;
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### eventId=" + lastEventId);
|
||||
}
|
||||
|
||||
|
@ -402,7 +398,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
|
||||
if (!runService && lastQuitId != lastEventId) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### quitting" +
|
||||
" run=" + runService +
|
||||
" startId=" + lastQuitId + "/" + lastEventId);
|
||||
|
@ -416,7 +412,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
queue.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### init " + accountNetworkState);
|
||||
|
||||
DB db = DB.getInstance(ServiceSynchronize.this);
|
||||
|
@ -445,7 +441,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
|
||||
private void start(final TupleAccountNetworkState accountNetworkState, boolean sync, boolean force) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"Service start=" + accountNetworkState + " sync=" + sync + " force=" + force);
|
||||
|
||||
final Core.State astate = new Core.State(accountNetworkState.networkState);
|
||||
|
@ -476,7 +472,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
Log.i("### start=" + accountNetworkState + " sync=" + sync);
|
||||
astate.start();
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### started=" + accountNetworkState);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
|
@ -491,7 +487,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
return;
|
||||
coreStates.remove(accountNetworkState.accountState.id);
|
||||
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"Service stop=" + accountNetworkState);
|
||||
|
||||
queue.submit(new Runnable() {
|
||||
|
@ -511,7 +507,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
db.account().setAccountThread(accountNetworkState.accountState.id, null);
|
||||
state.stop();
|
||||
state.join();
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### stopped=" + accountNetworkState);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
|
@ -521,7 +517,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
|
||||
private void delete(final TupleAccountNetworkState accountNetworkState) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"Service delete=" + accountNetworkState);
|
||||
|
||||
queue.submit(new Runnable() {
|
||||
|
@ -547,7 +543,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### quit eventId=" + eventId);
|
||||
|
||||
if (eventId == null) {
|
||||
|
@ -569,7 +565,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
|
||||
if (!eventId.equals(lastEventId)) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### quit cancelled eventId=" + eventId + "/" + lastEventId);
|
||||
return;
|
||||
}
|
||||
|
@ -577,7 +573,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
// Stop service
|
||||
stopSelf();
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### stop self eventId=" + eventId);
|
||||
|
||||
WorkerCleanup.cleanupConditionally(ServiceSynchronize.this);
|
||||
|
@ -816,7 +812,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
String action = (intent == null ? null : intent.getAction());
|
||||
String reason = (intent == null ? null : intent.getStringExtra("reason"));
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
"### Service command " + intent +
|
||||
" action=" + action + " reason=" + reason);
|
||||
Log.logExtras(intent);
|
||||
|
@ -917,13 +913,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
Core.State state = coreStates.get(account);
|
||||
|
||||
if (state == null)
|
||||
EntityLog.log(this, LOG_SCHEDULE,
|
||||
EntityLog.log(this, EntityLog.Type.Scheduling,
|
||||
"### wakeup missing account=" + account);
|
||||
else {
|
||||
EntityLog.log(this, LOG_SCHEDULE,
|
||||
EntityLog.log(this, EntityLog.Type.Scheduling,
|
||||
"### waking up account=" + account);
|
||||
if (!state.release())
|
||||
EntityLog.log(this, LOG_SCHEDULE,
|
||||
EntityLog.log(this, EntityLog.Type.Scheduling,
|
||||
"### waking up failed account=" + account);
|
||||
}
|
||||
}
|
||||
|
@ -961,7 +957,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
EntityOperation.queue(ServiceSynchronize.this, message, EntityOperation.SEND);
|
||||
}
|
||||
} else {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling,
|
||||
folder.name + " Unsnooze" +
|
||||
" id=" + message.id +
|
||||
" ui_seen=" + message.ui_seen + "" +
|
||||
|
@ -1131,7 +1127,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
|
||||
private void onWatchdog(Intent intent) {
|
||||
EntityLog.log(this, LOG_SCHEDULE, "Watchdog");
|
||||
EntityLog.log(this, EntityLog.Type.Scheduling, "Watchdog");
|
||||
schedule(this, false);
|
||||
|
||||
if (lastNetworkState == null || !lastNetworkState.isSuitable())
|
||||
|
@ -1281,7 +1277,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
if (TextUtils.isEmpty(message))
|
||||
message = "?";
|
||||
if (e.getMessageType() == StoreEvent.NOTICE) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_ACCOUNT,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Account,
|
||||
account.name + " notice: " + message);
|
||||
|
||||
if ("Still here".equals(message) &&
|
||||
|
@ -1300,7 +1296,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
try {
|
||||
wlFolder.acquire();
|
||||
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_ACCOUNT,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Account,
|
||||
account.name + " alert: " + message);
|
||||
|
||||
if (!ConnectionHelper.isMaxConnections(message))
|
||||
|
@ -1322,7 +1318,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
List<Thread> idlers = new ArrayList<>();
|
||||
try {
|
||||
// Initiate connection
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " connecting");
|
||||
db.folder().setFolderStates(account.id, null);
|
||||
db.account().setAccountState(account.id, "connecting");
|
||||
|
@ -1378,11 +1374,11 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
Store istore = iservice.getStore();
|
||||
if (istore instanceof IMAPStore) {
|
||||
Map<String, String> caps = ((IMAPStore) istore).getCapabilities();
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " connected" +
|
||||
" caps=" + (caps == null ? null : TextUtils.join(" ", caps.keySet())));
|
||||
} else
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " connected");
|
||||
|
||||
db.account().setAccountMaxSize(account.id, iservice.getMaxSize());
|
||||
|
@ -1627,7 +1623,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
} catch (Throwable ex) {
|
||||
Log.e(folder.name, ex);
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_ACCOUNT,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Account,
|
||||
folder.name + " idle " + Log.formatThrowable(ex, false));
|
||||
state.error(new FolderClosedException(ifolder, "IDLE", new Exception(ex)));
|
||||
} finally {
|
||||
|
@ -1870,7 +1866,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
} catch (Throwable ex) {
|
||||
Log.e(folder.name, ex);
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_ACCOUNT,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Account,
|
||||
folder.name + " process " + Log.formatThrowable(ex, false));
|
||||
db.folder().setFolderError(folder.id, Log.formatThrowable(ex));
|
||||
if (!(ex instanceof FolderNotFoundException))
|
||||
|
@ -1909,7 +1905,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
!account.keep_alive_ok && account.poll_interval > 9 &&
|
||||
Math.abs(idleTime - account.poll_interval * 60 * 1000L) < 60 * 1000L);
|
||||
if (tune_keep_alive && !first && !account.keep_alive_ok)
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name +
|
||||
" Tune interval=" + account.poll_interval +
|
||||
" idle=" + idleTime + "/" + tune);
|
||||
|
@ -1925,7 +1921,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
// Sends store NOOP
|
||||
if (EmailService.SEPARATE_STORE_CONNECTION) {
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " checking store" +
|
||||
" memory=" + Log.getFreeMemMb() +
|
||||
" battery=" + Helper.getBatteryLevel(this));
|
||||
|
@ -1941,7 +1937,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
|
||||
if (sync) {
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " checking folders");
|
||||
for (EntityFolder folder : mapFolders.keySet())
|
||||
if (folder.selectable && folder.synchronize)
|
||||
|
@ -2006,7 +2002,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
// Record successful connection
|
||||
account.last_connected = new Date().getTime();
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " set last_connected=" + new Date(account.last_connected));
|
||||
db.account().setAccountConnected(account.id, account.last_connected);
|
||||
db.account().setAccountWarning(account.id, capIdle ? null : getString(R.string.title_no_idle));
|
||||
|
@ -2026,7 +2022,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
try {
|
||||
long duration = account.poll_interval * 60 * 1000L;
|
||||
long trigger = System.currentTimeMillis() + duration;
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
"### " + account.name + " keep alive" +
|
||||
" wait=" + account.poll_interval + " until=" + new Date(trigger));
|
||||
AlarmManagerCompatEx.setAndAllowWhileIdle(ServiceSynchronize.this, am, AlarmManager.RTC_WAKEUP, trigger, pi);
|
||||
|
@ -2051,13 +2047,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
} catch (Throwable ex) {
|
||||
last_fail = ex;
|
||||
Log.e(account.name, ex);
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " connect " + Log.formatThrowable(ex, false));
|
||||
db.account().setAccountError(account.id, Log.formatThrowable(ex));
|
||||
|
||||
// Report account connection error
|
||||
if (account.last_connected != null && !ConnectionHelper.airplaneMode(this)) {
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " last connected: " + new Date(account.last_connected));
|
||||
|
||||
int pollInterval = getPollInterval(this);
|
||||
|
@ -2085,7 +2081,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
}
|
||||
} finally {
|
||||
// Update state
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " closing");
|
||||
|
||||
// Stop watching operations
|
||||
|
@ -2113,15 +2109,15 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
for (EntityFolder folder : mapFolders.keySet())
|
||||
if (folder.selectable && folder.synchronize && !folder.poll && mapFolders.get(folder) != null)
|
||||
db.folder().setFolderState(folder.id, "closing");
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " store closing");
|
||||
iservice.close();
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " store closed");
|
||||
} catch (Throwable ex) {
|
||||
Log.w(account.name, ex);
|
||||
} finally {
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " closed");
|
||||
db.account().setAccountState(account.id, null);
|
||||
for (EntityFolder folder : mapFolders.keySet())
|
||||
|
@ -2172,7 +2168,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
" ex=" + Log.formatThrowable(last_fail, false);
|
||||
if (compensate > 2)
|
||||
Log.e(msg);
|
||||
EntityLog.log(this, LOG_ACCOUNT, msg);
|
||||
EntityLog.log(this, EntityLog.Type.Account, msg);
|
||||
|
||||
state.setBackoff(backoff * 60);
|
||||
}
|
||||
|
@ -2186,7 +2182,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
int backoff = state.getBackoff();
|
||||
int recently = (lastLost + LOST_RECENTLY < now ? 1 : 2);
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " backoff=" + backoff + " recently=" + recently + "x");
|
||||
|
||||
if (backoff < CONNECT_BACKOFF_MAX)
|
||||
|
@ -2238,7 +2234,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
try {
|
||||
long trigger = System.currentTimeMillis() + backoff * 1000L;
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
"### " + account.name + " backoff until=" + new Date(trigger));
|
||||
AlarmManagerCompatEx.setAndAllowWhileIdle(ServiceSynchronize.this, am, AlarmManager.RTC_WAKEUP, trigger, pi);
|
||||
|
||||
|
@ -2265,7 +2261,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
if (!currentThread.equals(accountThread) && accountThread != null)
|
||||
Log.w(account.name + " orphan thread id=" + currentThread + "/" + accountThread);
|
||||
} finally {
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " stopped");
|
||||
wlAccount.release();
|
||||
}
|
||||
|
@ -2311,7 +2307,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
DB db = DB.getInstance(this);
|
||||
|
||||
int pollInterval = getPollInterval(this);
|
||||
EntityLog.log(this, LOG_ACCOUNT,
|
||||
EntityLog.log(this, EntityLog.Type.Account,
|
||||
account.name + " auto optimize" +
|
||||
" reason=" + reason +
|
||||
" poll interval=" + pollInterval);
|
||||
|
@ -2351,7 +2347,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
@Override
|
||||
public void onBlockedStatusChanged(@NonNull Network network, boolean blocked) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_NETWORK,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Account,
|
||||
"Network " + network + " blocked=" + blocked);
|
||||
}
|
||||
|
||||
|
@ -2369,7 +2365,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) {
|
||||
boolean on = intent.getBooleanExtra("state", false);
|
||||
EntityLog.log(context, LOG_NETWORK,
|
||||
EntityLog.log(context, EntityLog.Type.Network,
|
||||
"Airplane mode on=" + on);
|
||||
if (!on)
|
||||
lastLost = 0;
|
||||
|
@ -2413,13 +2409,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
|
||||
if (active != null && !active.equals(lastActive)) {
|
||||
if (ConnectionHelper.isConnected(ServiceSynchronize.this, active)) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_NETWORK,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Network,
|
||||
reason + ": new active network=" + active + "/" + lastActive);
|
||||
lastActive = active;
|
||||
}
|
||||
} else if (lastActive != null) {
|
||||
if (!ConnectionHelper.isConnected(ServiceSynchronize.this, lastActive)) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_NETWORK,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Network,
|
||||
reason + ": lost active network=" + lastActive);
|
||||
lastActive = null;
|
||||
lastLost = new Date().getTime();
|
||||
|
@ -2429,7 +2425,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
if (network == null || Objects.equals(network, active)) {
|
||||
ConnectionHelper.NetworkState ns = ConnectionHelper.getNetworkState(ServiceSynchronize.this);
|
||||
if (!Objects.equals(lastNetworkState, ns)) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_NETWORK,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Network,
|
||||
reason + ": updating state network=" + active +
|
||||
" info=" + ConnectionHelper.getNetworkInfo(ServiceSynchronize.this, active) + " " + ns);
|
||||
lastNetworkState = ns;
|
||||
|
@ -2440,7 +2436,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
boolean isSuitable = (lastNetworkState != null && lastNetworkState.isSuitable());
|
||||
if (lastSuitable == null || lastSuitable != isSuitable) {
|
||||
lastSuitable = isSuitable;
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_NETWORK,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Network,
|
||||
reason + ": updated suitable=" + lastSuitable);
|
||||
|
||||
if (!isBackgroundService(ServiceSynchronize.this))
|
||||
|
@ -2467,7 +2463,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
private List<TupleAccountState> lastAccountStates = null;
|
||||
|
||||
private void post(Bundle command) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE,
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Network,
|
||||
"### command " + TextUtils.join(" ", Log.getExtras(command)));
|
||||
|
||||
if (command.getBoolean("sync") || command.getBoolean("force"))
|
||||
|
@ -2503,7 +2499,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
networkState = ConnectionHelper.getNetworkState(ServiceSynchronize.this);
|
||||
|
||||
if (accountStates == null) {
|
||||
EntityLog.log(ServiceSynchronize.this, LOG_SCHEDULE, "### no accounts");
|
||||
EntityLog.log(ServiceSynchronize.this, EntityLog.Type.Scheduling, "### no accounts");
|
||||
lastCommand = command;
|
||||
return;
|
||||
}
|
||||
|
@ -2628,7 +2624,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
if (polled && next < now + interval / 5)
|
||||
next += interval;
|
||||
|
||||
EntityLog.log(context, LOG_SCHEDULE,
|
||||
EntityLog.log(context, EntityLog.Type.Scheduling,
|
||||
"Poll next=" + new Date(next) + " polled=" + polled);
|
||||
|
||||
AlarmManagerCompatEx.setAndAllowWhileIdle(context, am, AlarmManager.RTC_WAKEUP, next, piSync);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginHorizontal="3dp"
|
||||
tools:context="eu.faircode.email.ActivityView">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
android:text="12:34:56"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="12dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
@ -23,6 +24,7 @@
|
|||
android:textAppearance="@android:style/TextAppearance.Small"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="12dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tvTime"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
|
|
@ -13,6 +13,13 @@
|
|||
android:checked="true"
|
||||
android:title="@string/title_auto_scroll"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/menu_show"
|
||||
android:title="@string/title_unhide"
|
||||
app:showAsAction="never">
|
||||
<menu />
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_clear"
|
||||
android:title="@string/title_log_clear"
|
||||
|
|
Loading…
Reference in New Issue