Bug 1451061 - Review Permissions usage for Android 8 behaviour changes r?JanH draft
authorAndrei Lazar <andrei.a.lazar@softvision.ro>
Thu, 05 Jul 2018 13:15:10 +0300
changeset 817989 4c5c44eb7dd068f4be4245d4fd09e919503c5faf
parent 817988 9a91c36b6e3c6278f13a0c942d0bdf1f238aeb4d
child 817990 2d87fc6f48a95558acf268bf1669510abb1d4c02
push id116231
push userplingurar@mozilla.com
push dateFri, 13 Jul 2018 19:23:06 +0000
reviewersJanH
bugs1451061
milestone63.0a1
Bug 1451061 - Review Permissions usage for Android 8 behaviour changes r?JanH Added reading permission as a safety measure for any future android updates. MozReview-Commit-ID: Be6V8hn9KF8 ***
mobile/android/chrome/content/browser.js
mobile/android/modules/RuntimePermissions.jsm
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -4179,19 +4179,19 @@ Tab.prototype = {
           let error = docURI.search(/e\=/);
           let duffUrl = docURI.search(/\&u\=/);
           let errorExtra = decodeURIComponent(docURI.slice(error + 2, duffUrl));
           // Here is a list of errorExtra types (et_*)
           // http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/netError.xhtml#287
           if (errorExtra == "fileAccessDenied") {
             // Check if we already have the permissions, then - if we do not have them, show the prompt and reload the page.
             // If we already have them, it means access to file was denied.
-            RuntimePermissions.checkPermission(RuntimePermissions.WRITE_EXTERNAL_STORAGE).then((permissionAlreadyGranted) => {
+            RuntimePermissions.checkPermission(RuntimePermissions.READ_EXTERNAL_STORAGE).then((permissionAlreadyGranted) => {
               if (!permissionAlreadyGranted) {
-                RuntimePermissions.waitForPermissions(RuntimePermissions.WRITE_EXTERNAL_STORAGE).then((permissionGranted) => {
+                RuntimePermissions.waitForPermissions(RuntimePermissions.READ_EXTERNAL_STORAGE).then((permissionGranted) => {
                   if (permissionGranted) {
                     this.browser.reload();
                   }
                 });
               }
             });
           }
 
--- a/mobile/android/modules/RuntimePermissions.jsm
+++ b/mobile/android/modules/RuntimePermissions.jsm
@@ -12,23 +12,25 @@ ChromeUtils.defineModuleGetter(this, "Ev
                                "resource://gre/modules/Messaging.jsm");
 
 // See: http://developer.android.com/reference/android/Manifest.permission.html
 const ACCESS_COARSE_LOCATION = "android.permission.ACCESS_COARSE_LOCATION";
 const ACCESS_FINE_LOCATION = "android.permission.ACCESS_FINE_LOCATION";
 const CAMERA = "android.permission.CAMERA";
 const RECORD_AUDIO = "android.permission.RECORD_AUDIO";
 const WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE";
+const READ_EXTERNAL_STORAGE = "android.permission.READ_EXTERNAL_STORAGE";
 
 var RuntimePermissions = {
   ACCESS_COARSE_LOCATION: ACCESS_COARSE_LOCATION,
   ACCESS_FINE_LOCATION: ACCESS_FINE_LOCATION,
   CAMERA: CAMERA,
   RECORD_AUDIO: RECORD_AUDIO,
   WRITE_EXTERNAL_STORAGE: WRITE_EXTERNAL_STORAGE,
+  READ_EXTERNAL_STORAGE: READ_EXTERNAL_STORAGE,
 
   /**
    * Check whether the permissions have been granted or not. If needed prompt the user to accept the permissions.
    *
    * @returns A promise resolving to true if all the permissions have been granted or false if any of the
    *          permissions have been denied.
    */
   waitForPermissions: function(permission) {