Bug 1280184 - Disable system download manager integration on Android 6+. r?sebastian draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 17 Aug 2017 21:51:45 +0200
changeset 658024 7c975d34dad291b308532b30ed1ed8068f27cdcb
parent 657993 c229a840f5f70b848764cc67f6993f7f18a47699
child 658025 fa17091260deb4d02f0424cf51d841b4ea3573ab
push id77678
push usermozilla@buttercookie.de
push dateSat, 02 Sep 2017 20:45:50 +0000
reviewerssebastian
bugs1280184, 1392768, 37115671
milestone57.0a1
Bug 1280184 - Disable system download manager integration on Android 6+. r?sebastian This is also a mandatory prerequisite for doing something about bug 1392768 - with download integration enabled, clearing download history items also attempts to remove the corresponding system download manager entry again, which on Android 6+ triggers a mandatory delete of the file and obviates the goal of that bug. The corresponding Android issue is https://issuetracker.google.com/issues/37115671. MozReview-Commit-ID: HvOktsgXmb1
mobile/android/base/java/org/mozilla/gecko/DownloadsIntegration.java
--- a/mobile/android/base/java/org/mozilla/gecko/DownloadsIntegration.java
+++ b/mobile/android/base/java/org/mozilla/gecko/DownloadsIntegration.java
@@ -97,16 +97,29 @@ public class DownloadsIntegration implem
         }
     }
 
     private static boolean useSystemDownloadManager() {
         if (!AppConstants.ANDROID_DOWNLOADS_INTEGRATION) {
             return false;
         }
 
+        if (Versions.feature23Plus) {
+            // As of Android M, the download manager has started deleting downloaded files when
+            // - a download is removed again from the download manager
+            // - the app that originally downloaded (or just added) the file is uninstalled.
+            // Since we
+            // - want to offer users a choice whether removing a download from the download history
+            //   should also remove the corresponding file
+            // - want to avoid users accidentally losing their downloads if they uninstall Firefox
+            // we therefore have to give up our system download manager integration on affected
+            // Android versions.
+            return false;
+        }
+
         int state = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
         try {
             final PackageManager pm = GeckoAppShell.getApplicationContext()
                                                    .getPackageManager();
             state = pm.getApplicationEnabledSetting("com.android.providers.downloads");
         } catch (IllegalArgumentException e) {
             // Download Manager package does not exist
             return false;