Track "online updates" rather than "local updates"

This is a preparation commit with no actual changes.
This commit is contained in:
Gabriele M
2017-07-07 22:05:22 +02:00
parent ab9ac395f0
commit 08a7dfade9

View File

@@ -79,7 +79,7 @@ public class UpdaterController implements UpdaterControllerInt {
mWakeLock.setReferenceCounted(false); mWakeLock.setReferenceCounted(false);
for (UpdateDownload update : mUpdatesDbHelper.getUpdates()) { for (UpdateDownload update : mUpdatesDbHelper.getUpdates()) {
addUpdate(update, true); addUpdate(update, false);
} }
} }
@@ -285,19 +285,19 @@ public class UpdaterController implements UpdaterControllerInt {
@Override @Override
public boolean addUpdate(UpdateDownload update) { public boolean addUpdate(UpdateDownload update) {
return addUpdate(update, false); return addUpdate(update, true);
} }
private boolean addUpdate(final UpdateDownload update, boolean local) { private boolean addUpdate(final UpdateDownload update, boolean availableOnline) {
Log.d(TAG, "Adding download: " + update.getDownloadId()); Log.d(TAG, "Adding download: " + update.getDownloadId());
if (mDownloads.containsKey(update.getDownloadId())) { if (mDownloads.containsKey(update.getDownloadId())) {
Log.e(TAG, "Download (" + update.getDownloadId() + ") already added"); Log.e(TAG, "Download (" + update.getDownloadId() + ") already added");
return false; return false;
} }
if (!fixUpdateStatus(update) && local) { if (!fixUpdateStatus(update) && !availableOnline) {
update.setPersistentStatus(UpdateStatus.Persistent.UNKNOWN); update.setPersistentStatus(UpdateStatus.Persistent.UNKNOWN);
deleteUpdateAsync(update); deleteUpdateAsync(update);
Log.d(TAG, update.getDownloadId() + " had an invalid status and is local"); Log.d(TAG, update.getDownloadId() + " had an invalid status and is not online");
return false; return false;
} }
mDownloads.put(update.getDownloadId(), new DownloadEntry(update)); mDownloads.put(update.getDownloadId(), new DownloadEntry(update));