From 116cb88b81e2d4ad146ef21ada3fe020981da9c4 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Mon, 5 Jun 2017 16:03:30 +1000 Subject: [PATCH] Fix incorrect persistent + annoying notification to update F-Droid. There is a persistent shared preference which dictates whether apps have been successfully downloaded and are ready to install. When the `InstallManagerService` used to receive an `ACTION_INSTALL_COMPLETE` broadcast, it would update this preference to no longer be installing. However, this never got received in the case of F-Droid updating itself. In that case, we need to instead wait for the system to broadcast an `Intent.ACTION_PACKAGE_ADDED` intent. This change waits until that point before removing the preference. Fixes #1027. --- .../data/InstalledAppProviderService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/src/main/java/org/fdroid/fdroid/data/InstalledAppProviderService.java b/app/src/main/java/org/fdroid/fdroid/data/InstalledAppProviderService.java index 7a1d404c1..35602ba1e 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/InstalledAppProviderService.java +++ b/app/src/main/java/org/fdroid/fdroid/data/InstalledAppProviderService.java @@ -13,6 +13,7 @@ import android.support.annotation.Nullable; import android.util.Log; import org.acra.ACRA; +import org.fdroid.fdroid.AppUpdateStatusManager; import org.fdroid.fdroid.Hasher; import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.data.Schema.InstalledAppTable; @@ -219,6 +220,22 @@ public class InstalledAppProviderService extends IntentService { try { String hashType = "sha256"; String hash = Utils.getBinaryHash(apk, hashType); + + // Ensure that we no longer notify the user that this apk successfully + // downloaded and is now ready to be installed. Used to be handled only + // by InstallManagerService after receiving ACTION_INSTALL_COMPLETE, but + // that doesn't work for F-Droid itself, which never receives that action. + for (Apk apkInRepo : ApkProvider.Helper.findApksByHash(this, hash)) { + + Utils.debugLog(TAG, "Noticed that " + apkInRepo.apkName + + " version " + apkInRepo.versionName + " was installed," + + " so marking as no longer pending install"); + + AppUpdateStatusManager.getInstance(this) + .markAsNoLongerPendingInstall(apkInRepo.getUrl()); + + } + insertAppIntoDb(this, packageInfo, hashType, hash); } catch (IllegalArgumentException e) { Utils.debugLog(TAG, e.getMessage());