Bug 1450449 - Part 1: Add FileProvider. r=jchen
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 12 May 2018 22:19:08 +0200
changeset 476055 d4d9645e40cb93bf772054d8235c4570a3ba47d3
parent 476054 0673137d307f3878d4cf48160cfa16efb66c25b6
child 476056 dd8790d74ceca129f42b8e59cc6d31d6048cd5ea
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1450449
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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 =