Allow to cancel ongoing installations

Change-Id: I46884b42b6e3f87fbee99a23f538cec990b3b873
This commit is contained in:
Gabriele M
2017-11-30 23:41:00 +01:00
parent f3d9b3f1b2
commit 8e369117bf
5 changed files with 71 additions and 1 deletions

View File

@@ -205,4 +205,25 @@ class ABUpdateInstaller {
.remove(PREF_INSTALLING_AB_ID)
.apply();
}
public boolean cancel() {
if (!isInstallingUpdate(mContext)) {
Log.e(TAG, "cancel: Not installing any update");
return false;
}
if (mUpdateEngine == null) {
Log.e(TAG, "Not connected to update engine");
return false;
}
mUpdateEngine.cancel();
installationDone();
mUpdaterController.getActualUpdate(mDownloadId)
.setStatus(UpdateStatus.INSTALLATION_CANCELLED);
mUpdaterController.notifyUpdateChange(mDownloadId);
return true;
}
}