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

@@ -55,6 +55,7 @@ public class UpdaterService extends Service {
public static final String EXTRA_DOWNLOAD_ID = "extra_download_id";
public static final String EXTRA_DOWNLOAD_CONTROL = "extra_download_control";
public static final String ACTION_INSTALL_UPDATE = "action_install_update";
public static final String ACTION_INSTALL_STOP = "action_install_stop";
public static final int DOWNLOAD_RESUME = 0;
public static final int DOWNLOAD_PAUSE = 1;
@@ -213,6 +214,12 @@ public class UpdaterService extends Service {
Log.e(TAG, "Could not install update", e);
// TODO: user facing message
}
} else if (ACTION_INSTALL_STOP.equals(intent.getAction())) {
if (ABUpdateInstaller.isInstallingUpdate(this)) {
ABUpdateInstaller installer = new ABUpdateInstaller(this, mUpdaterController);
installer.reconnect();
installer.cancel();
}
}
return START_NOT_STICKY;
}