From 2ec8fc6cec3f02c802b20283586a76b6bf15e506 Mon Sep 17 00:00:00 2001 From: Gabriele M Date: Sat, 24 Mar 2018 16:17:20 +0100 Subject: [PATCH] Prevent NPE on A/B devices The NPE shouldn't happen as we get a null intent only when the service is sticky (i.e., isInstallingUpdate() is true), so this is currently not a problem. Change-Id: I8647498d9a1022f5c7207a2da3e42cf57d9ee030 --- .../updater/controller/UpdaterService.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index 41f3c55c..380ad84f 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -162,12 +162,14 @@ public class UpdaterService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "Starting service"); - if ((intent == null || intent.getAction() == null) && - ABUpdateInstaller.isInstallingUpdate(this)) { - // The service is being restarted. - ABUpdateInstaller installer = ABUpdateInstaller.getInstance(this, mUpdaterController); - if (installer.reconnect()) { - return START_STICKY; + if (intent == null || intent.getAction() == null) { + if (ABUpdateInstaller.isInstallingUpdate(this)) { + // The service is being restarted. + ABUpdateInstaller installer = ABUpdateInstaller.getInstance(this, + mUpdaterController); + if (installer.reconnect()) { + return START_STICKY; + } } } else if (ACTION_DOWNLOAD_CONTROL.equals(intent.getAction())) { String downloadId = intent.getStringExtra(EXTRA_DOWNLOAD_ID);