cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-13781) Error requesting permission on Android 8 - Save on photo album issue
Date Mon, 15 Jan 2018 22:14:00 GMT

    [ https://issues.apache.org/jira/browse/CB-13781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16326597#comment-16326597
] 

ASF GitHub Bot commented on CB-13781:
-------------------------------------

infil00p closed pull request #308: CB-13781: (android) Fixed permissions request on Android
8 to save a …
URL: https://github.com/apache/cordova-plugin-camera/pull/308
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/android/CameraLauncher.java b/src/android/CameraLauncher.java
index 0f9b4b0c..a8e6fc43 100644
--- a/src/android/CameraLauncher.java
+++ b/src/android/CameraLauncher.java
@@ -113,7 +113,7 @@ Licensed to the Apache Software Foundation (ASF) under one
     private boolean orientationCorrected;   // Has the picture's orientation been corrected
     private boolean allowEdit;              // Should we allow the user to crop the image.
 
-    protected final static String[] permissions = { Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE
};
+    protected final static String[] permissions = { Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE };
 
     public CallbackContext callbackContext;
     private int numPics;
@@ -245,7 +245,8 @@ private String getTempDirectoryPath() {
      * @param encodingType           Compression quality hint (0-100: 0=low quality &
high compression, 100=compress of max quality)
      */
     public void callTakePicture(int returnType, int encodingType) {
-        boolean saveAlbumPermission = PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
+        boolean saveAlbumPermission = PermissionHelper.hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
+                && PermissionHelper.hasPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
         boolean takePicturePermission = PermissionHelper.hasPermission(this, Manifest.permission.CAMERA);
 
         // CB-10120: The CAMERA permission does not need to be requested unless it is declared
@@ -276,7 +277,8 @@ public void callTakePicture(int returnType, int encodingType) {
         } else if (saveAlbumPermission && !takePicturePermission) {
             PermissionHelper.requestPermission(this, TAKE_PIC_SEC, Manifest.permission.CAMERA);
         } else if (!saveAlbumPermission && takePicturePermission) {
-            PermissionHelper.requestPermission(this, TAKE_PIC_SEC, Manifest.permission.READ_EXTERNAL_STORAGE);
+            PermissionHelper.requestPermissions(this, TAKE_PIC_SEC,
+                    new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE});
         } else {
             PermissionHelper.requestPermissions(this, TAKE_PIC_SEC, permissions);
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Error requesting permission on Android 8 - Save on photo album issue
> --------------------------------------------------------------------
>
>                 Key: CB-13781
>                 URL: https://issues.apache.org/jira/browse/CB-13781
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-camera
>            Reporter: Rubén Panadero
>            Priority: Critical
>
> Google has changed how an android application must request permissions on Android 8.
In fact, it is considered as fix by Google due to a wrong behavior on previous versions.
> Related documentation:
> [https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp]
> This change made by Google has affected the cordova-camera-plugin. To save a photo in
Photo Album, the plugin just requests the READ_EXTERNAL_STORAGE permission right now, but
that is not enough on Android 8 because the plugin writes the photo file into Pictures folder
so it has to request the writing permission, which is missing, as well.
> This is the error that the plugin throws when a photo is tried to be saved into the
photo album on Android 8.
> > 01-12 11:38:16.757 W/System.err(22321): java.io.FileNotFoundException: open failed:
EACCES (Permission denied)
> > 01-12 11:38:16.758 W/System.err(22321): at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:313)
> > 01-12 11:38:16.758 W/System.err(22321): at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:211)
> > 01-12 11:38:16.758 W/System.err(22321): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1242)
> > 01-12 11:38:16.758 W/System.err(22321): at android.content.ContentResolver.openOutputStream(ContentResolver.java:1007)
> > 01-12 11:38:16.758 W/System.err(22321): at android.content.ContentResolver.openOutputStream(ContentResolver.java:983)
> > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:979)
> > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:1015)
> > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:603)
> > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:919)
> > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:152)
> > 01-12 11:38:16.758 W/System.err(22321): at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:358)
> > 01-12 11:38:16.758 W/System.err(22321): at android.app.Activity.dispatchActivityResult(Activity.java:7235)
> > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread.deliverResults(ActivityThread.java:4336)
> > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4383)
> > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread.-wrap19(Unknown
Source:0)
> > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1652)
> > 01-12 11:38:16.758 W/System.err(22321): at android.os.Handler.dispatchMessage(Handler.java:105)
> > 01-12 11:38:16.758 W/System.err(22321): at android.os.Looper.loop(Looper.java:164)
> > 01-12 11:38:16.758 W/System.err(22321): at android.app.ActivityThread.main(ActivityThread.java:6600)
> > 01-12 11:38:16.758 W/System.err(22321): at java.lang.reflect.Method.invoke(Native
Method)
> > 01-12 11:38:16.758 W/System.err(22321): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
> > 01-12 11:38:16.758 W/System.err(22321): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:772)
> To sum up, if the plugin has to save a photo in the photo album, this one has to request
both READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message