|
|
@ -41,6 +41,9 @@ import com.sun.mail.imap.IMAPFolder;
|
|
|
|
import com.sun.mail.imap.IMAPMessage;
|
|
|
|
import com.sun.mail.imap.IMAPMessage;
|
|
|
|
import com.sun.mail.imap.IMAPStore;
|
|
|
|
import com.sun.mail.imap.IMAPStore;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@ -1065,6 +1068,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
DB db = DB.getInstance(ServiceSynchronize.this);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
wl.acquire();
|
|
|
|
wl.acquire();
|
|
|
|
|
|
|
|
|
|
|
@ -1074,9 +1079,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
if (doStop)
|
|
|
|
if (doStop)
|
|
|
|
stop();
|
|
|
|
stop();
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(ServiceSynchronize.this);
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
|
|
|
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
|
|
|
|
|
|
|
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
for (EntityAccount account : db.account().getAccountsTbd())
|
|
|
|
for (EntityAccount account : db.account().getAccountsTbd())
|
|
|
|
nm.deleteNotificationChannel(EntityAccount.getNotificationChannelName(account.id));
|
|
|
|
nm.deleteNotificationChannel(EntityAccount.getNotificationChannelName(account.id));
|
|
|
@ -1103,6 +1106,17 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (queued == 0 && !isEnabled()) {
|
|
|
|
if (queued == 0 && !isEnabled()) {
|
|
|
|
EntityLog.log(ServiceSynchronize.this, "Service stop");
|
|
|
|
EntityLog.log(ServiceSynchronize.this, "Service stop");
|
|
|
|
|
|
|
|
List<EntityOperation> ops = db.operation().getOperations(EntityOperation.SYNC);
|
|
|
|
|
|
|
|
for (EntityOperation op : ops)
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
JSONArray jargs = new JSONArray(op.args);
|
|
|
|
|
|
|
|
if (!jargs.getBoolean(3) /* foreground */) {
|
|
|
|
|
|
|
|
Log.i("Deleting bacground SYNC args=" + jargs);
|
|
|
|
|
|
|
|
db.operation().deleteOperation(op.id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (JSONException ex) {
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
stopSelf();
|
|
|
|
stopSelf();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|