Keep track of the number of updates being verified

This commit is contained in:
Gabriele M
2017-07-04 19:05:04 +02:00
parent e7923a3d56
commit 653b577d61
2 changed files with 10 additions and 0 deletions

View File

@@ -55,6 +55,7 @@ public class UpdaterController implements UpdaterControllerInt {
private final File mDownloadRoot; private final File mDownloadRoot;
private int mActiveDownloads = 0; private int mActiveDownloads = 0;
private int mVerifyingUpdates = 0;
public static synchronized UpdaterController getInstance() { public static synchronized UpdaterController getInstance() {
return sUpdaterController; return sUpdaterController;
@@ -209,6 +210,7 @@ public class UpdaterController implements UpdaterControllerInt {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
mVerifyingUpdates++;
UpdateDownload update = mDownloads.get(downloadId).mUpdate; UpdateDownload update = mDownloads.get(downloadId).mUpdate;
File file = update.getFile(); File file = update.getFile();
if (file.exists() && verifyPackage(file)) { if (file.exists() && verifyPackage(file)) {
@@ -221,6 +223,7 @@ public class UpdaterController implements UpdaterControllerInt {
update.setProgress(0); update.setProgress(0);
update.setStatus(UpdateStatus.VERIFICATION_FAILED); update.setStatus(UpdateStatus.VERIFICATION_FAILED);
} }
mVerifyingUpdates--;
notifyUpdateChange(downloadId); notifyUpdateChange(downloadId);
} }
}).start(); }).start();
@@ -411,4 +414,9 @@ public class UpdaterController implements UpdaterControllerInt {
public boolean hasActiveDownloads() { public boolean hasActiveDownloads() {
return mActiveDownloads > 0; return mActiveDownloads > 0;
} }
@Override
public boolean isVerifyingUpdate() {
return mVerifyingUpdates > 0;
}
} }

View File

@@ -41,4 +41,6 @@ public interface UpdaterControllerInt {
boolean isDownloading(String downloadId); boolean isDownloading(String downloadId);
boolean hasActiveDownloads(); boolean hasActiveDownloads();
boolean isVerifyingUpdate();
} }