[
https://issues.apache.org/jira/browse/CB-5398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13975215#comment-13975215
]
Randy Lau commented on CB-5398:
-------------------------------
Julian - having the same issue as well.
I tried merging in their changes to IceCreamCordovaWebViewClient.java. This
change fixed a GET error I saw before the change:
("GET content://com.android.providers.media.documents/document/image%3A13966").
However, I'm still getting the Android permissions issue:
("java.lang.SecurityException: Permission Denial: reading
com.android.providers.media.MediaDocumentsProvider uri
content://com.android.providers.media.documents/document/image:13966 from
pid=10618, uid=10287 requires android.permission.MANAGE_DOCUMENTS, or
grantUriPermission()")
Am I missing something? I have the MANAGE_DOCUMENTS and INTERNET permissions
in my AndroidManifest.xml as well.
IceCreamCordovaWebViewClient.java code below:
package org.apache.cordova;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaResourceApi.OpenForReadResult;
import org.apache.cordova.LOG;
import android.annotation.TargetApi;
import android.net.Uri;
import android.os.Build;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
private static final String TAG = "IceCreamCordovaWebViewClient";
public IceCreamCordovaWebViewClient(CordovaInterface cordova) {
super(cordova);
}
public IceCreamCordovaWebViewClient(CordovaInterface cordova,
CordovaWebView view) {
super(cordova, view);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url)
{
try {
// Check the against the white-list.
if ((url.startsWith("http:") || url.startsWith("https:")) &&
!Config.isUrlWhiteListed(url)) {
LOG.w(TAG, "URL blocked by whitelist: " + url);
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
CordovaResourceApi resourceApi = appView.getResourceApi();
Uri origUri = Uri.parse(url);
// Allow plugins to intercept WebView requests.
Uri remappedUri = resourceApi.remapUri(origUri);
if (!origUri.equals(remappedUri) ||
needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
OpenForReadResult result = resourceApi.openForRead(remappedUri,
true);
return new WebResourceResponse(result.mimeType, "UTF-8",
result.inputStream);
}
// If we don't need to special-case the request, let the browser
load it.
return null;
} catch (IOException e) {
if (!(e instanceof FileNotFoundException)) {
LOG.e("IceCreamCordovaWebViewClient", "Error occurred while
loading a file (returning a 404).", e);
}
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
}
private static boolean needsKitKatContentUrlFix(Uri uri) {
return android.os.Build.VERSION.SDK_INT >=
android.os.Build.VERSION_CODES.KITKAT && "content".equals(uri.getScheme());
}
private static boolean needsSpecialsInAssetUrlFix(Uri uri) {
if (CordovaResourceApi.getUriType(uri) !=
CordovaResourceApi.URI_TYPE_ASSET) {
return false;
}
if (uri.getQuery() != null || uri.getFragment() != null) {
return true;
}
if (!uri.toString().contains("%")) {
return false;
}
switch(android.os.Build.VERSION.SDK_INT){
case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH:
case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
return true;
}
return false;
}
}
> Pick image from Library or Photo album on android 4.4
> -----------------------------------------------------
>
> Key: CB-5398
> URL: https://issues.apache.org/jira/browse/CB-5398
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android, Plugin Camera
> Affects Versions: 2.9.0, 3.2.0
> Environment: android 4.4
> Reporter: julio cesar
> Assignee: Mike Billau
> Fix For: 3.5.0
>
>
> An android 4.4 try to pick a photo using pictureSource.PHOTOLIBRARY or
> pictureSource.SAVEDPHOTOALBUM and return type destinationType.FILE_URI.
> Now android 4.4, when you select the above options, it opens an "open from"
> dialog that let you choose from new places as "Recent", "Drive", "Images"
> and "Downloads" (the names might not be the same as I use the device in
> spanish and translated it).
> If you choose any of them, you get an error, AndroidProtocolHandler, unable
> to open content URL: the url here with a content://com.android.providers
> format.
> I've tested on phonegap 2.9 because this is the version I use, but I suppose
> it affects all of them. (in fact I use 2.9.1)
--
This message was sent by Atlassian JIRA
(v6.2#6252)