Allow service restarts while installing AB updates

The update engine service is independent and once started doesn't need
our service to install updates. Therefore we can't assume that our
service will stay up as long as the installation is being performed.
If the service gets terminated while an update is being installed, we
simply lose our connection to the update engine service and stop
receiving notifications, the installation itself won't stop. Keep
track of ongoing installations using a shared preference and use a
sticky service when installing updates. The service will try to
re-connect to the update engine service and determine if the
installation is still ongoing.

Change-Id: Id2fc11cab51610d04bf41a0927824bb8c0c94d71
This commit is contained in:
Gabriele M
2017-11-30 23:41:00 +01:00
parent 6088f26f53
commit f3d9b3f1b2
4 changed files with 99 additions and 36 deletions

View File

@@ -53,6 +53,7 @@ public class UpdaterController implements Controller {
private static final int MAX_REPORT_INTERVAL_MS = 1000;
private final Context mContext;
private final LocalBroadcastManager mBroadcastManager;
private final UpdatesDbHelper mUpdatesDbHelper;
@@ -81,6 +82,7 @@ public class UpdaterController implements Controller {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Updater");
mWakeLock.setReferenceCounted(false);
mContext = context.getApplicationContext();
Utils.cleanupDownloadsDir(context);
@@ -532,11 +534,11 @@ public class UpdaterController implements Controller {
@Override
public boolean isInstallingUpdate() {
return ABUpdateInstaller.isInstallingUpdate();
return ABUpdateInstaller.isInstallingUpdate(mContext);
}
@Override
public boolean isInstallingUpdate(String downloadId) {
return ABUpdateInstaller.isInstallingUpdate(downloadId);
return ABUpdateInstaller.isInstallingUpdate(mContext, downloadId);
}
}