Report store alerts, reset account errors after verifying connection

This commit is contained in:
M66B 2018-11-29 10:31:54 +01:00
parent b5b0e56fea
commit d864b655c8
1 changed files with 6 additions and 4 deletions

View File

@ -740,10 +740,12 @@ public class ServiceSynchronize extends LifecycleService {
public void notification(StoreEvent e) {
try {
wl.acquire();
Log.i(Helper.TAG, account.name + " event: " + e.getMessage());
if (BuildConfig.DEBUG)
String type = (e.getMessageType() == StoreEvent.ALERT ? "alert" : "notice");
EntityLog.log(ServiceSynchronize.this, account.name + " " + type + ": " + e.getMessage());
if (e.getMessageType() == StoreEvent.ALERT) {
db.account().setAccountError(account.id, e.getMessage());
state.error();
state.error();
}
} finally {
wl.release();
}
@ -841,7 +843,6 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(Helper.TAG, account.name + " idle=" + capIdle);
db.account().setAccountState(account.id, "connected");
db.account().setAccountError(account.id, capIdle ? null : getString(R.string.title_no_idle));
NotificationManager nm = getSystemService(NotificationManager.class);
nm.cancel("receive", account.id.intValue());
@ -1199,6 +1200,7 @@ public class ServiceSynchronize extends LifecycleService {
// Record successful connection
db.account().setAccountConnected(account.id, new Date().getTime());
db.account().setAccountError(account.id, capIdle ? null : getString(R.string.title_no_idle));
// Schedule keep alive alarm
EntityLog.log(this, account.name + " wait=" + account.poll_interval);