From 3aabbc7ed5972b468f268050a5a2cc6b23a8ed05 Mon Sep 17 00:00:00 2001 From: Gabriele M Date: Sat, 24 Mar 2018 16:17:20 +0100 Subject: [PATCH] Use single return statement in onStartCommand() This should prevent future changes from accidentally turning a sticky service into a not sticky one. Change-Id: I89f172626a98635149441a63536e0aa5a27f8280 --- .../lineageos/updater/controller/UpdaterService.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index 380ad84..ad496ff 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -167,9 +167,7 @@ public class UpdaterService extends Service { // The service is being restarted. ABUpdateInstaller installer = ABUpdateInstaller.getInstance(this, mUpdaterController); - if (installer.reconnect()) { - return START_STICKY; - } + installer.reconnect(); } } else if (ACTION_DOWNLOAD_CONTROL.equals(intent.getAction())) { String downloadId = intent.getStringExtra(EXTRA_DOWNLOAD_ID); @@ -191,9 +189,7 @@ public class UpdaterService extends Service { if (Utils.isABUpdate(update.getFile())) { ABUpdateInstaller installer = ABUpdateInstaller.getInstance(this, mUpdaterController); - if (installer.install(downloadId)) { - return START_STICKY; - } + installer.install(downloadId); } else { UpdateInstaller installer = new UpdateInstaller(this, mUpdaterController); installer.install(downloadId); @@ -215,7 +211,7 @@ public class UpdaterService extends Service { installer.cancel(); } } - return START_NOT_STICKY; + return ABUpdateInstaller.isInstallingUpdate(this) ? START_STICKY : START_NOT_STICKY; } public Controller getUpdaterController() {