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

Jason Ginchereau commented on CB-9891:
--------------------------------------

Reproduced on Android Lollipop with the following steps:
1. Use the browser on the device to download a picture.
2. Start the Cordova app and execute code similar to that in this JIRA 
description.
3. Select the downloaded picture from the gallery.

I found this exception in the logcat:

java.lang.SecurityException: Permission Denial: reading 
com.android.providers.media.MediaDocumentsProvider uri 
content://com.android.providers.media.documents/document/image:10 from 
pid=1987, uid=10052 requires android.permission.MANAGE_DOCUMENTS, or 
grantUriPermission()
        at 
android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:539)
        at 
android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:452)
        at 
android.content.ContentProvider$Transport.query(ContentProvider.java:205)
        at 
android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
        at android.os.Binder.execTransact(Binder.java:446)
java.lang.SecurityException: Permission Denial: reading 
com.android.providers.media.MediaDocumentsProvider uri 
content://com.android.providers.media.documents/document/image:10 from 
pid=1987, uid=10052 requires android.permission.MANAGE_DOCUMENTS, or 
grantUriPermission()
        at android.os.Parcel.readException(Parcel.java:1546)
        at 
android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
        at 
android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
        at 
android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
        at android.content.ContentResolver.query(ContentResolver.java:478)
        at android.content.ContentResolver.query(ContentResolver.java:422)
        at 
org.apache.cordova.file.ContentFilesystem.openCursorForURL(ContentFilesystem.java:169)
        at 
org.apache.cordova.file.ContentFilesystem.getFileMetadataForLocalURL(ContentFilesystem.java:123)
        at org.apache.cordova.file.FileUtils.getFileMetadata(FileUtils.java:875)
        at org.apache.cordova.file.FileUtils.access$700(FileUtils.java:55)
        at org.apache.cordova.file.FileUtils$15.run(FileUtils.java:419)
        at org.apache.cordova.file.FileUtils$25.run(FileUtils.java:634)


> Inconsistent URI encoding causing permission errors on android
> --------------------------------------------------------------
>
>                 Key: CB-9891
>                 URL: https://issues.apache.org/jira/browse/CB-9891
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Camera, Plugin File
>    Affects Versions: 2.1.0, 3.0.0
>         Environment: Android 5+
>            Reporter: Connor Pearson
>            Assignee: Jason Ginchereau
>              Labels: Android, reproduced
>
> Using the camera plugin to get a picture from the photo library returns an 
> encoded URI. If you then call resolveLocalFileSystemURI the fileEntry object 
> returned contains the decoded path component of the URI. This path property 
> is used in the toInternalURL function which means it's also decoded. Because 
> Android gave us permission to the encoded URI, but not the decoded URI, 
> attempting to access the decoded URI results in a permission error. 
> {code:javascript}
> document.getElementById("myButton").addEventListener("click", function(){
>             navigator.camera.getPicture(function(uri){
>                 console.log(uri); 
> //content://com.android.providers.media.documents/document/image%3A27         
>               window.resolveLocalFileSystemURI(uri, function(fileEntry){
>                     console.log(fileEntry.toInternalURL()); 
> //cdvfile://localhost/content/com.android.providers.media.documents/document/image:27
>                                                                               
>                     fileEntry.file(function(){alert("success");}, 
> function(){alert("fail");});
>                 },function(error){
>                     // resolved by pulling in PR 119
>                     alert("Fail resolveFileSystemURI code: " + error.code);
>                 });
>             }, null, {sourceType: 0, allowEdit: false});
>         });
> {code}
> I feel like something must be wrong in one of the plugins, but I'm not sure 
> where.
> One possible fix is calling uri.getEncodedPath() instead of uri.getPath in 
> LocalFileSystemURL.parse and then removing the call to encodeURI() from 
> FileSystem.js, but I'm not sure if this is the right strategy.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to