Cloud sync: enabled worker

pull/212/head
M66B 2 years ago
parent 3e49722d86
commit 559baf7baf

@ -71,7 +71,7 @@ public class WorkerSync extends Worker {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String user = prefs.getString("cloud_user", null); String user = prefs.getString("cloud_user", null);
String password = prefs.getString("cloud_password", null); String password = prefs.getString("cloud_password", null);
boolean enabled = false && !(TextUtils.isEmpty(user) || TextUtils.isEmpty(password)); boolean enabled = !(TextUtils.isEmpty(user) || TextUtils.isEmpty(password));
try { try {
if (enabled) { if (enabled) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
@ -83,7 +83,8 @@ public class WorkerSync extends Worker {
cal.add(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, 1);
delay = cal.getTimeInMillis() - delay; delay = cal.getTimeInMillis() - delay;
Log.i("Queuing " + getName() + " delay=" + (delay / (60 * 1000L)) + "m"); EntityLog.log(context, EntityLog.Type.Cloud,
"Queuing " + getName() + " delay=" + (delay / (60 * 1000L)) + "m");
PeriodicWorkRequest.Builder builder = PeriodicWorkRequest.Builder builder =
new PeriodicWorkRequest.Builder(WorkerSync.class, 1, TimeUnit.DAYS) new PeriodicWorkRequest.Builder(WorkerSync.class, 1, TimeUnit.DAYS)
.setInitialDelay(delay, TimeUnit.MILLISECONDS); .setInitialDelay(delay, TimeUnit.MILLISECONDS);
@ -91,7 +92,8 @@ public class WorkerSync extends Worker {
.enqueueUniquePeriodicWork(getName(), ExistingPeriodicWorkPolicy.KEEP, builder.build()); .enqueueUniquePeriodicWork(getName(), ExistingPeriodicWorkPolicy.KEEP, builder.build());
Log.i("Queued " + getName()); Log.i("Queued " + getName());
} else { } else {
Log.i("Cancelling " + getName()); EntityLog.log(context, EntityLog.Type.Cloud,
"Cancelling " + getName());
WorkManager.getInstance(context).cancelUniqueWork(getName()); WorkManager.getInstance(context).cancelUniqueWork(getName());
Log.i("Cancelled " + getName()); Log.i("Cancelled " + getName());
} }

Loading…
Cancel
Save