You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/06/24 22:17:34 UTC

[GitHub] [cordova-plugin-camera] dpolivy opened a new issue #470: Android: java.io.FileNotFoundException · open failed: EACCES (Permission denied) when saving to photo gallery

dpolivy opened a new issue #470: Android: java.io.FileNotFoundException · open failed: EACCES (Permission denied) when saving to photo gallery
URL: https://github.com/apache/cordova-plugin-camera/issues/470
 
 
   # Bug Report
   
   ## Problem
   On Android, when `saveToPhotoAlbum` is `true`, I have some users who are reporting that taking a picture does not return the picture to the Cordova app, even though the Camera UI seems to indicate a photo was successfully taken.
   
   Under the covers, Android is throwing a `FileNotFoundException` with `EACCES` as the error when trying to open the output stream to write the file to the library.
   
   ### What is expected to happen?
   When taking a photo, it should be returned to the Cordova app. If `saveToPhotoAlbum` is `true`, then the photo should also be saved to the user's photo gallery.
   
   ### What does actually happen?
   After taking the picture and confirming it in the Camera UI, the app returns control to the Cordova app, but the app does not receive the taken image. It's as if you cancelled taking a picture.
   
   ## Information
   As best I can tell, this seems to affect users who may have an SD card. I cannot reproduce this on my Nexus 5 or Pixel 2 devices (neither of which support SD cards). In collecting stack traces/debug logs from affected users, I've found the following codepath is throwing an exception:
   
   ````
   java.io.FileNotFoundException: open failed: EACCES (Permission denied)
           at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:313)
           at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:211)
           at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1248)
           at android.content.ContentResolver.openOutputStream(ContentResolver.java:1013)
           at android.content.ContentResolver.openOutputStream(ContentResolver.java:989)
           at org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:1038)
           at org.apache.cordova.camera.CameraLauncher.writeUncompressedImage(CameraLauncher.java:1074)
           at org.apache.cordova.camera.CameraLauncher.processResultFromCamera(CameraLauncher.java:657)
           at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:978)
           at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:159)
           at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:359)
           at android.app.Activity.dispatchActivityResult(Activity.java:7547)
           at android.app.ActivityThread.deliverResults(ActivityThread.java:4487)
           at android.app.ActivityThread.handleSendResult(ActivityThread.java:4534)
           at android.app.ActivityThread.-wrap20(Unknown)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1752)
           at android.os.Handler.dispatchMessage(Handler.java:105)
           at android.os.Looper.loop(Looper.java:164)
           at android.app.ActivityThread.main(ActivityThread.java:6944)
           at java.lang.reflect.Method.invoke(Method.java:-2)
           at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
   ````
   
   When the user goes into Settings > Apps & Notifications > Apps and looks at the Permissions for the app, Storage IS enabled. So the app should have access to read/write external storage.
   
   The offending line in `CameraLauncher.java` is https://github.com/apache/cordova-plugin-camera/blob/master/src/android/CameraLauncher.java#L866
   
   Perhaps there is some other permission missing when there is an SD card installed?
   
   ### Command or Code
   Take a picture with the `saveToPhotoLibrary` option being set to `true`.
   
   ### Environment, Platform, Device
   It seems to be a device specific issue, though it repros on the latest Android releases. I think most, but not all, users are on a Samsung Galaxy device.
   
   ### Version information
   Reproduces with cordova-plugin-camera 4.0.4-dev
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

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