Bug 1450449 - Part 1: Add FileProvider. r?jchen draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 12 May 2018 22:19:08 +0200
changeset 803366 703dce7078d2296c209dd0b2e5aabf1790c76361
parent 803365 f4f864ee758026ee2c8ae3c02734eb23ca1bb3f1
child 803367 b026a1820d87d940485e757bb6477fa4ce4a1948
child 803373 f0b3d6ffb0c11b719c661745233edc798e18d740
child 803595 f6464ef0686ed9328c58dcc4a0852b2f6dc0ea3e
push id112080
push usermozilla@buttercookie.de
push dateSun, 03 Jun 2018 14:54:29 +0000
reviewersjchen
bugs1450449
milestone62.0a1
Bug 1450449 - Part 1: Add FileProvider. r?jchen In case we change our thinking on launching of downloaded files and start using content:// URIs for that case as well, we already allow our FileProvider to generate URIs for the whole file system using <root-path>. This is because users can in principle move our download directory to an arbitrary location on the file system as long as it is accessible to Firefox. However not all of these locations (e.g. on a removable SD card) can be specified through the other methods of specifying available files for a FileProvider, so only the <root- path> option remains. MozReview-Commit-ID: 2UStBlU4JsG
mobile/android/app/src/main/res/xml/provider_paths.xml
mobile/android/base/AndroidManifest.xml.in
mobile/android/base/AppConstants.java.in
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/main/res/xml/provider_paths.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+    <root-path
+        name="root"
+        path="." />
+</paths>
--- a/mobile/android/base/AndroidManifest.xml.in
+++ b/mobile/android/base/AndroidManifest.xml.in
@@ -368,16 +368,24 @@
         <provider android:name="org.mozilla.gecko.db.HomeProvider"
                   android:authorities="@ANDROID_PACKAGE_NAME@.db.home"
                   android:exported="false"/>
 
         <provider android:name="org.mozilla.gecko.db.SearchHistoryProvider"
                   android:authorities="@ANDROID_PACKAGE_NAME@.db.searchhistory"
                   android:exported="false"/>
 
+        <provider android:name="android.support.v4.content.FileProvider"
+                  android:authorities="@ANDROID_PACKAGE_NAME@.fileprovider"
+                  android:exported="false"
+                  android:grantUriPermissions="true">
+                  <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
+                             android:resource="@xml/provider_paths" />
+        </provider>
+
         <service
             android:exported="false"
             android:name="org.mozilla.gecko.updater.UpdateService"
             android:process="@MANGLED_ANDROID_PACKAGE_NAME@.UpdateService">
         </service>
 
         <service
             android:exported="false"
--- a/mobile/android/base/AppConstants.java.in
+++ b/mobile/android/base/AppConstants.java.in
@@ -20,16 +20,17 @@ import android.os.Build;
 // Normally, we'd annotate with @RobocopTarget.  Since AppConstants is compiled
 // before RobocopTarget, we instead add o.m.g.AppConstants directly to the
 // Proguard configuration.
 public class AppConstants {
     public static final String ANDROID_PACKAGE_NAME = "@ANDROID_PACKAGE_NAME@";
     public static final String MANGLED_ANDROID_PACKAGE_NAME = "@MANGLED_ANDROID_PACKAGE_NAME@";
 
     public static final String MOZ_ANDROID_SHARED_FXACCOUNT_TYPE = "@ANDROID_PACKAGE_NAME@_fxaccount";
+    public static final String MOZ_FILE_PROVIDER_AUTHORITY = "@ANDROID_PACKAGE_NAME@.fileprovider";
 
     /**
      * Encapsulates access to compile-time version definitions, allowing
      * for dead code removal for particular APKs.
      */
     public static final class Versions {
         public static final int MIN_SDK_VERSION = @MOZ_ANDROID_MIN_SDK_VERSION@;
         public static final int MAX_SDK_VERSION =