You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2013/06/06 23:36:03 UTC
[1/6] android commit: Revert "CB-3496: Fixed streaming audio,
this is pretty important for mobile spec"
Updated Branches:
refs/heads/master e518eacbd -> 3753e3f35
Revert "CB-3496: Fixed streaming audio, this is pretty important for mobile spec"
This reverts commit aa81966e0bf1460c6e40b9f5cc7290247cc84786.
Going to revert all DataResource changes for on the 2.8.x branch.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/43172cf5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/43172cf5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/43172cf5
Branch: refs/heads/master
Commit: 43172cf53035e91125606fbb0046059c05c5a227
Parents: e518eac
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon May 27 22:20:01 2013 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jun 6 14:06:54 2013 -0700
----------------------------------------------------------------------
framework/src/org/apache/cordova/AudioHandler.java | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/43172cf5/framework/src/org/apache/cordova/AudioHandler.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AudioHandler.java b/framework/src/org/apache/cordova/AudioHandler.java
index ef20306..20c3c4e 100644
--- a/framework/src/org/apache/cordova/AudioHandler.java
+++ b/framework/src/org/apache/cordova/AudioHandler.java
@@ -58,10 +58,7 @@ public class AudioHandler extends CordovaPlugin {
public String getFilePath(String url, String source){
DataResource dataResource = DataResource.initiateNewDataRequestForUri(url, this.webView.pluginManager, cordova, source);
- if(dataResource.getUri().getScheme().equals("http") || dataResource.getUri().getScheme().equals("https"))
- return dataResource.getUri().toString();
- else
- return dataResource.getRealFile().getPath();
+ return dataResource.getRealFile().getPath();
}
/**
[3/6] android commit: Revert "DataRequest code cleaned up."
Posted by bo...@apache.org.
Revert "DataRequest code cleaned up."
This reverts commit a001d8cfb71930bf21ccc0b85715385ef409d8e0.
Reverting all DataResource changes for the 2.8.0 release.
Conflicts:
framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/e3989bcc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/e3989bcc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/e3989bcc
Branch: refs/heads/master
Commit: e3989bcc2b23588def3948239fc73630192a543b
Parents: 2f9c512
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon May 27 22:22:14 2013 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jun 6 14:10:13 2013 -0700
----------------------------------------------------------------------
.../src/org/apache/cordova/CameraLauncher.java | 12 ++--
framework/src/org/apache/cordova/FileHelper.java | 20 +++++---
framework/src/org/apache/cordova/FileUtils.java | 2 +-
.../cordova/IceCreamCordovaWebViewClient.java | 7 ++-
.../src/org/apache/cordova/api/CordovaPlugin.java | 4 +-
.../src/org/apache/cordova/api/DataResource.java | 37 +++++++--------
.../apache/cordova/api/DataResourceContext.java | 9 +++-
.../src/org/apache/cordova/api/PluginManager.java | 9 +--
8 files changed, 55 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e3989bcc/framework/src/org/apache/cordova/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java
index 134cf09..f434661 100755
--- a/framework/src/org/apache/cordova/CameraLauncher.java
+++ b/framework/src/org/apache/cordova/CameraLauncher.java
@@ -342,7 +342,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
// Add compressed version of captured image to returned media store Uri
DataResource dataResource = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent");
- OutputStream os = dataResource.getOutputStream();
+ OutputStream os = dataResource.getOs();
bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
os.close();
@@ -540,9 +540,9 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
private void writeUncompressedImage(Uri uri) throws FileNotFoundException,
IOException {
DataResource inputDataResource = DataResource.initiateNewDataRequestForUri(imageUri, webView.pluginManager, cordova, "CameraLauncher.writeUncompressedImage");
- InputStream fis = inputDataResource.getInputStream();
+ InputStream fis = inputDataResource.getIs();
DataResource outDataResource = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.writeUncompressedImage");
- OutputStream os = outDataResource.getOutputStream();
+ OutputStream os = outDataResource.getOs();
if(fis == null) {
throw new FileNotFoundException("Could not get the input file");
} else if(os == null) {
@@ -592,13 +592,13 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
// If no new width or height were specified return the original bitmap
DataResource dataResource = DataResource.initiateNewDataRequestForUri(imageUrl, webView.pluginManager, cordova, "CameraLauncher.getScaledBitmap");
if (this.targetWidth <= 0 && this.targetHeight <= 0) {
- return BitmapFactory.decodeStream(dataResource.getInputStream());
+ return BitmapFactory.decodeStream(dataResource.getIs());
}
// figure out the original width and height of the image
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
- BitmapFactory.decodeStream(dataResource.getInputStream(), null, options);
+ BitmapFactory.decodeStream(dataResource.getIs(), null, options);
//CB-2292: WTF? Why is the width null?
if(options.outWidth == 0 || options.outHeight == 0)
@@ -612,7 +612,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
// Load in the smallest bitmap possible that is closest to the size we want
options.inJustDecodeBounds = false;
options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, this.targetWidth, this.targetHeight);
- Bitmap unscaledBitmap = BitmapFactory.decodeStream(dataResource.getInputStream(), null, options);
+ Bitmap unscaledBitmap = BitmapFactory.decodeStream(dataResource.getIs(), null, options);
if (unscaledBitmap == null) {
return null;
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e3989bcc/framework/src/org/apache/cordova/FileHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileHelper.java b/framework/src/org/apache/cordova/FileHelper.java
index 69c7f48..e7bf98a 100644
--- a/framework/src/org/apache/cordova/FileHelper.java
+++ b/framework/src/org/apache/cordova/FileHelper.java
@@ -130,27 +130,33 @@ public class FileHelper {
*/
public static boolean isUriWritable(String uriString) {
String scheme = uriString.split(":")[0];
+ String writableSchemes[] = new String[]{ "content" };
if(scheme.equals("file")){
// special case file
- return !uriString.startsWith("file:///android_asset/");
+ if(uriString.startsWith("file:///android_asset/")){
+ return false;
+ } else {
+ return true;
+ }
}
- return "content".equals(scheme);
+ for(int i = writableSchemes.length - 1; i >= 0 ; i--){
+ if(writableSchemes[i].equals(scheme)){
+ return true;
+ }
+ }
+ return false;
}
/**
* Ensures the "file://" prefix exists for the given string
- * If the given URI string already has a scheme, it is returned unchanged
+ * If the given URI string has a "file://" prefix, it is returned unchanged
*
* @param path - the path string to operate on
* @return a String with the "file://" scheme set
*/
public static String insertFileProtocol(String path) {
if(!path.matches("^[a-z0-9+.-]+:.*")){
- //Ensure it is not a relative path
- if(!path.startsWith("/")){
- throw new IllegalArgumentException("Relative paths" + path + "are not allowed.");
- }
path = "file://" + path;
}
return path;
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e3989bcc/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index 4b136ed..fe5a4ab 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -897,7 +897,7 @@ public class FileUtils extends CordovaPlugin {
public void run() {
try {
DataResource dataResource = DataResource.initiateNewDataRequestForUri(filename, webView.pluginManager, cordova, "FileUtils.readFileAs");
- byte[] bytes = readAsBinaryHelper(dataResource.getInputStream(), start, end);
+ byte[] bytes = readAsBinaryHelper(dataResource.getIs(), start, end);
PluginResult result;
switch (resultType) {
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e3989bcc/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index 4b3408c..2a686d8 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -46,13 +46,16 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
// We need to support the new DataResource intercepts without breaking the shouldInterceptRequest mechanism.
DataResource dataResource = DataResource.initiateNewDataRequestForUri(url, this.appView.pluginManager, cordova,
- "WebViewClient.shouldInterceptRequest");
+ new DataResourceContext("WebViewClient.shouldInterceptRequest", true /* this is from a browser request*/));
url = dataResource.getUri().toString();
// This mechanism is no longer needed due to the dataResource mechanism. It would be awesome to just get rid of it.
//Check if plugins intercept the request
WebResourceResponse ret = super.shouldInterceptRequest(view, url);
-
+// The below bugfix is taken care of by the dataResource mechanism
+// if(ret == null && (url.contains("?") || url.contains("#") || needsIceCreamSpaceInAssetUrlFix(url))){
+// ret = generateWebResourceResponse(url);
+// }
if(ret == null) {
try {
ret = new WebResourceResponse(dataResource.getMimeType(), "UTF-8", dataResource.getInputStream());
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e3989bcc/framework/src/org/apache/cordova/api/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/CordovaPlugin.java b/framework/src/org/apache/cordova/api/CordovaPlugin.java
index 866677c..69f8fde 100644
--- a/framework/src/org/apache/cordova/api/CordovaPlugin.java
+++ b/framework/src/org/apache/cordova/api/CordovaPlugin.java
@@ -182,10 +182,10 @@ public class CordovaPlugin {
*
* @param dataResource The resource to be loaded.
* @param dataResourceContext Context associated with the resource load
- * @return Return a new DataResource if the plugin wants to assist in loading the request or null if it doesn't.
+ * @return Return a new DataResource if the plugin wants o assist in loading the request or null if it doesn't.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public DataResource handleDataResourceRequest(DataResource dataResource, DataResourceContext dataResourceContext) {
+ public DataResource shouldInterceptDataResourceRequest(DataResource dataResource, DataResourceContext dataResourceContext) {
return null;
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e3989bcc/framework/src/org/apache/cordova/api/DataResource.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/DataResource.java b/framework/src/org/apache/cordova/api/DataResource.java
index 5c1bb18..38bf31b 100644
--- a/framework/src/org/apache/cordova/api/DataResource.java
+++ b/framework/src/org/apache/cordova/api/DataResource.java
@@ -42,13 +42,10 @@ public class DataResource {
private String mimeType;
private Boolean writable;
private File realFile;
- private boolean retryIsLoad = true;
- private boolean retryOsLoad = true;
- private boolean retryMimeTypeLoad = true;
- private boolean retryWritableLoad = true;
- private boolean retryRealFileLoad = true;
+ private boolean retryLoad = true;
public DataResource(CordovaInterface cordova, Uri uri) {
+ super();
this.cordova = cordova;
this.uri = uri;
}
@@ -64,61 +61,61 @@ public class DataResource {
// Uri is always provided
return uri;
}
- public InputStream getInputStream() throws IOException {
- if(is == null && retryIsLoad) {
+ public InputStream getIs() throws IOException {
+ if(is == null && retryLoad) {
try {
is = FileHelper.getInputStreamFromUriString(uri.toString(), cordova);
} finally {
// We failed loading once, don't try loading anymore
if(is == null) {
- retryIsLoad = false;
+ retryLoad = false;
}
}
}
return is;
}
- public OutputStream getOutputStream() throws FileNotFoundException {
- if(os == null && retryOsLoad) {
+ public OutputStream getOs() throws FileNotFoundException {
+ if(os == null && retryLoad) {
try {
os = FileHelper.getOutputStreamFromUriString(uri.toString(), cordova);
} finally {
// We failed loading once, don't try loading anymore
if(os == null) {
- retryOsLoad = false;
+ retryLoad = false;
}
}
}
return os;
}
public String getMimeType() {
- if(mimeType == null && retryMimeTypeLoad) {
+ if(mimeType == null && retryLoad) {
try {
mimeType = FileHelper.getMimeType(uri.toString(), cordova);
} finally {
// We failed loading once, don't try loading anymore
if(mimeType == null) {
- retryMimeTypeLoad = false;
+ retryLoad = false;
}
}
}
return mimeType;
}
public boolean isWritable() {
- if(writable == null && retryWritableLoad) {
+ if(writable == null && retryLoad) {
try {
writable = FileHelper.isUriWritable(uri.toString());
} finally {
// We failed loading once, don't try loading anymore
if(writable == null) {
- retryWritableLoad = false;
+ retryLoad = false;
}
}
}
// default to false
- return writable != null && writable.booleanValue();
+ return writable != null? writable.booleanValue() : false;
}
public File getRealFile() {
- if(realFile == null && retryRealFileLoad) {
+ if(realFile == null && retryLoad) {
try {
String realPath = FileHelper.getRealPath(uri, cordova);
if(realPath != null) {
@@ -127,7 +124,7 @@ public class DataResource {
} finally {
// We failed loading once, don't try loading anymore
if(realFile == null) {
- retryRealFileLoad = false;
+ retryLoad = false;
}
}
}
@@ -141,7 +138,7 @@ public class DataResource {
return initiateNewDataRequestForUri(Uri.parse(uriString), pluginManager, cordova, requestSourceTag);
}
public static DataResource initiateNewDataRequestForUri(Uri uri, PluginManager pluginManager, CordovaInterface cordova, String requestSourceTag){
- return initiateNewDataRequestForUri(uri, pluginManager, cordova, new DataResourceContext(requestSourceTag));
+ return initiateNewDataRequestForUri(uri, pluginManager, cordova, new DataResourceContext(requestSourceTag, false /* Assume, not a browser request by default */ ));
}
public static DataResource initiateNewDataRequestForUri(String uriString, PluginManager pluginManager, CordovaInterface cordova, DataResourceContext dataResourceContext){
// if no protocol is specified, assume its file:
@@ -152,7 +149,7 @@ public class DataResource {
DataResource dataResource = new DataResource(cordova, uri);
if (pluginManager != null) {
// get the resource as returned by plugins
- dataResource = pluginManager.handleDataResourceRequestWithPlugins(dataResource, dataResourceContext);
+ dataResource = pluginManager.shouldInterceptDataResourceRequest(dataResource, dataResourceContext);
}
return dataResource;
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e3989bcc/framework/src/org/apache/cordova/api/DataResourceContext.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/DataResourceContext.java b/framework/src/org/apache/cordova/api/DataResourceContext.java
index 9cfe7bc..55bbc1d 100644
--- a/framework/src/org/apache/cordova/api/DataResourceContext.java
+++ b/framework/src/org/apache/cordova/api/DataResourceContext.java
@@ -30,11 +30,15 @@ public class DataResourceContext {
// A tag associated with the source of this dataResourceContext
private String source;
// If needed, any data associated with core plugins can be a part of the context object
+ // This field indicates whether the request came from a browser network request
+ private boolean isFromBrowser;
// If needed, any data associated with non core plugins should store data in a Map so as to not clutter the context object
private Map<String, Object> dataMap;
- public DataResourceContext(String source) {
+ public DataResourceContext(String source, boolean isFromBrowser) {
+ super();
this.requestId = new Random().nextInt();
this.source = source;
+ this.isFromBrowser = isFromBrowser;
this.dataMap = new HashMap<String, Object>();
}
public int getRequestId() {
@@ -43,6 +47,9 @@ public class DataResourceContext {
public String getSource() {
return source;
}
+ public boolean isFromBrowser() {
+ return isFromBrowser;
+ }
public Map<String, Object> getDataMap() {
return dataMap;
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/e3989bcc/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java
index e0ceabf..36ac357 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -54,7 +54,6 @@ public class PluginManager {
// Map URL schemes like foo: to plugins that want to handle those schemes
// This would allow how all URLs are handled to be offloaded to a plugin
protected HashMap<String, String> urlMap = new HashMap<String, String>();
- private int MAX_REPITIONS = 1000;
/**
* Constructor.
@@ -410,15 +409,13 @@ public class PluginManager {
* @param dataResourceContext The context of the dataResource request
* @return Return the resource request that will be loaded. The returned request may be modified or unchanged.
*/
- public DataResource handleDataResourceRequestWithPlugins(DataResource dataResource, DataResourceContext dataResourceContext){
- int repetitions = 0;
+ public DataResource shouldInterceptDataResourceRequest(DataResource dataResource, DataResourceContext dataResourceContext){
boolean requestModified = true;
- while(requestModified && repetitions < MAX_REPITIONS) {
+ while(requestModified) {
requestModified = false;
- repetitions ++;
for (PluginEntry entry : this.entries.values()) {
if (entry.plugin != null) {
- DataResource ret = entry.plugin.handleDataResourceRequest(dataResource, dataResourceContext);
+ DataResource ret = entry.plugin.shouldInterceptDataResourceRequest(dataResource, dataResourceContext);
if(ret != null) {
dataResource = ret;
requestModified = true;
[4/6] android commit: Revert "Changed all usages of FileHelper to use
the new DataResource mechanism."
Posted by bo...@apache.org.
Revert "Changed all usages of FileHelper to use the new DataResource mechanism."
This reverts commit 867358ea81619ce2b0e674758f1d66f1bc22172c.
Reverting all DataResource changes for the 2.8.0 release.
Conflicts:
framework/src/org/apache/cordova/FileUtils.java
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/c5b37cc7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/c5b37cc7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/c5b37cc7
Branch: refs/heads/master
Commit: c5b37cc7e7d5bc96d98fd17ea70a165c08761682
Parents: e3989bc
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon May 27 22:22:16 2013 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jun 6 14:12:44 2013 -0700
----------------------------------------------------------------------
framework/src/org/apache/cordova/AudioHandler.java | 13 +-
.../src/org/apache/cordova/CameraLauncher.java | 61 +++-----
framework/src/org/apache/cordova/Capture.java | 13 +-
framework/src/org/apache/cordova/FileUtils.java | 119 ++++++++++-----
.../cordova/IceCreamCordovaWebViewClient.java | 1 -
5 files changed, 107 insertions(+), 100 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c5b37cc7/framework/src/org/apache/cordova/AudioHandler.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AudioHandler.java b/framework/src/org/apache/cordova/AudioHandler.java
index 20c3c4e..fd8c9df 100644
--- a/framework/src/org/apache/cordova/AudioHandler.java
+++ b/framework/src/org/apache/cordova/AudioHandler.java
@@ -20,7 +20,7 @@ package org.apache.cordova;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.DataResource;
+
import android.content.Context;
import android.media.AudioManager;
@@ -56,11 +56,6 @@ public class AudioHandler extends CordovaPlugin {
this.pausedForPhone = new ArrayList<AudioPlayer>();
}
- public String getFilePath(String url, String source){
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(url, this.webView.pluginManager, cordova, source);
- return dataResource.getRealFile().getPath();
- }
-
/**
* Executes the request and returns PluginResult.
* @param action The action to execute.
@@ -73,13 +68,13 @@ public class AudioHandler extends CordovaPlugin {
String result = "";
if (action.equals("startRecordingAudio")) {
- this.startRecordingAudio(args.getString(0), getFilePath(args.getString(1), "AudioHandler.startRecordingAudio"));
+ this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(args.getString(1)));
}
else if (action.equals("stopRecordingAudio")) {
this.stopRecordingAudio(args.getString(0));
}
else if (action.equals("startPlayingAudio")) {
- this.startPlayingAudio(args.getString(0), getFilePath(args.getString(1), "AudioHandler.startPlayingAudio"));
+ this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(args.getString(1)));
}
else if (action.equals("seekToAudio")) {
this.seekToAudio(args.getString(0), args.getInt(1));
@@ -107,7 +102,7 @@ public class AudioHandler extends CordovaPlugin {
}
else if (action.equals("create")) {
String id = args.getString(0);
- String src = getFilePath(args.getString(1), "AudioHandler.create");
+ String src = FileHelper.stripFileProtocol(args.getString(1));
AudioPlayer audio = new AudioPlayer(this, id, src);
this.players.put(id, audio);
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c5b37cc7/framework/src/org/apache/cordova/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CameraLauncher.java b/framework/src/org/apache/cordova/CameraLauncher.java
index f434661..8e43786 100755
--- a/framework/src/org/apache/cordova/CameraLauncher.java
+++ b/framework/src/org/apache/cordova/CameraLauncher.java
@@ -20,15 +20,14 @@ package org.apache.cordova;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.DataResource;
import org.apache.cordova.api.LOG;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
@@ -42,6 +41,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Bitmap.CompressFormat;
+import android.graphics.Rect;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
@@ -290,7 +290,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
// If sending base64 image back
if (destType == DATA_URL) {
- bitmap = getScaledBitmap(imageUri.toString());
+ bitmap = getScaledBitmap(FileHelper.stripFileProtocol(imageUri.toString()));
if (bitmap == null) {
// Try to get the bitmap from intent.
bitmap = (Bitmap)intent.getExtras().get("data");
@@ -316,9 +316,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
if (this.saveToPhotoAlbum) {
Uri inputUri = getUriFromMediaStore();
//Just because we have a media URI doesn't mean we have a real file, we need to make it
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(inputUri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent");
- File file = dataResource.getRealFile();
- uri = Uri.fromFile(file);
+ uri = Uri.fromFile(new File(FileHelper.getRealPath(inputUri, this.cordova)));
} else {
uri = Uri.fromFile(new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), System.currentTimeMillis() + ".jpg"));
}
@@ -334,15 +332,14 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
this.callbackContext.success(uri.toString());
} else {
- bitmap = getScaledBitmap(imageUri.toString());
+ bitmap = getScaledBitmap(FileHelper.stripFileProtocol(imageUri.toString()));
if (rotate != 0 && this.correctOrientation) {
bitmap = getRotatedBitmap(rotate, bitmap, exif);
}
// Add compressed version of captured image to returned media store Uri
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent");
- OutputStream os = dataResource.getOs();
+ OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
os.close();
@@ -350,7 +347,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
if (this.encodingType == JPEG) {
String exifPath;
if (this.saveToPhotoAlbum) {
- exifPath = dataResource.getRealFile().getPath();
+ exifPath = FileHelper.getRealPath(uri, this.cordova);
} else {
exifPath = uri.getPath();
}
@@ -401,9 +398,8 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
this.callbackContext.success(uri.toString());
} else {
String uriString = uri.toString();
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent");
// Get the path to the image. Makes loading so much easier.
- String mimeType = dataResource.getMimeType();
+ String mimeType = FileHelper.getMimeType(uriString, this.cordova);
// If we don't have a valid image so quit.
if (!("image/jpeg".equalsIgnoreCase(mimeType) || "image/png".equalsIgnoreCase(mimeType))) {
Log.d(LOG_TAG, "I either have a null image path or bitmap");
@@ -444,8 +440,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
// Create an ExifHelper to save the exif data that is lost during compression
String resizePath = DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/resize.jpg";
// Some content: URIs do not map to file paths (e.g. picasa).
- File realFile = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent").getRealFile();
- String realPath = realFile != null? realFile.getPath() : null;
+ String realPath = FileHelper.getRealPath(uri, this.cordova);
ExifHelper exif = new ExifHelper();
if (realPath != null && this.encodingType == JPEG) {
try {
@@ -539,15 +534,8 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
*/
private void writeUncompressedImage(Uri uri) throws FileNotFoundException,
IOException {
- DataResource inputDataResource = DataResource.initiateNewDataRequestForUri(imageUri, webView.pluginManager, cordova, "CameraLauncher.writeUncompressedImage");
- InputStream fis = inputDataResource.getIs();
- DataResource outDataResource = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.writeUncompressedImage");
- OutputStream os = outDataResource.getOs();
- if(fis == null) {
- throw new FileNotFoundException("Could not get the input file");
- } else if(os == null) {
- throw new FileNotFoundException("Could not get the output file");
- }
+ FileInputStream fis = new FileInputStream(FileHelper.stripFileProtocol(imageUri.toString()));
+ OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
byte[] buffer = new byte[4096];
int len;
while ((len = fis.read(buffer)) != -1) {
@@ -590,15 +578,14 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
*/
private Bitmap getScaledBitmap(String imageUrl) throws IOException {
// If no new width or height were specified return the original bitmap
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(imageUrl, webView.pluginManager, cordova, "CameraLauncher.getScaledBitmap");
if (this.targetWidth <= 0 && this.targetHeight <= 0) {
- return BitmapFactory.decodeStream(dataResource.getIs());
+ return BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova));
}
// figure out the original width and height of the image
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
- BitmapFactory.decodeStream(dataResource.getIs(), null, options);
+ BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova), null, options);
//CB-2292: WTF? Why is the width null?
if(options.outWidth == 0 || options.outHeight == 0)
@@ -612,7 +599,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
// Load in the smallest bitmap possible that is closest to the size we want
options.inJustDecodeBounds = false;
options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, this.targetWidth, this.targetHeight);
- Bitmap unscaledBitmap = BitmapFactory.decodeStream(dataResource.getIs(), null, options);
+ Bitmap unscaledBitmap = BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova), null, options);
if (unscaledBitmap == null) {
return null;
}
@@ -711,20 +698,16 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
bitmap.recycle();
}
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(oldImage, webView.pluginManager, cordova, "CameraLauncher.cleanup");
- File file = dataResource.getRealFile();
- if(file != null) {
- // Clean up initial camera-written image file.
- file.delete();
-
- checkForDuplicateImage(imageType);
- // Scan for the gallery to update pic refs in gallery
- if (this.saveToPhotoAlbum && newImage != null) {
- this.scanForGallery(newImage);
- }
+ // Clean up initial camera-written image file.
+ (new File(FileHelper.stripFileProtocol(oldImage.toString()))).delete();
- System.gc();
+ checkForDuplicateImage(imageType);
+ // Scan for the gallery to update pic refs in gallery
+ if (this.saveToPhotoAlbum && newImage != null) {
+ this.scanForGallery(newImage);
}
+
+ System.gc();
}
/**
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c5b37cc7/framework/src/org/apache/cordova/Capture.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Capture.java b/framework/src/org/apache/cordova/Capture.java
index d7ad419..5f737ca 100644
--- a/framework/src/org/apache/cordova/Capture.java
+++ b/framework/src/org/apache/cordova/Capture.java
@@ -26,7 +26,6 @@ import java.io.OutputStream;
import android.os.Build;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.DataResource;
import org.apache.cordova.api.LOG;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
@@ -130,8 +129,7 @@ public class Capture extends CordovaPlugin {
// If the mimeType isn't set the rest will fail
// so let's see if we can determine it.
if (mimeType == null || mimeType.equals("") || "null".equals(mimeType)) {
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "Capture.dataResource");
- mimeType = dataResource.getMimeType();
+ mimeType = FileHelper.getMimeType(filePath, cordova);
}
Log.d(LOG_TAG, "Mime type = " + mimeType);
@@ -158,8 +156,7 @@ public class Capture extends CordovaPlugin {
private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "Capture.getImageData");
- BitmapFactory.decodeFile(dataResource.getRealFile().getPath(), options);
+ BitmapFactory.decodeFile(FileHelper.stripFileProtocol(filePath), options);
obj.put("height", options.outHeight);
obj.put("width", options.outWidth);
return obj;
@@ -351,8 +348,7 @@ public class Capture extends CordovaPlugin {
* @throws IOException
*/
private JSONObject createMediaFile(Uri data) {
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(data, webView.pluginManager, cordova, "Capture.createMediaFile");
- File fp = dataResource.getRealFile();
+ File fp = new File(FileHelper.getRealPath(data, this.cordova));
JSONObject obj = new JSONObject();
try {
@@ -362,7 +358,6 @@ public class Capture extends CordovaPlugin {
// Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp files
// are reported as video/3gpp. I'm doing this hacky check of the URI to see if it
// is stored in the audio or video content store.
-
if (fp.getAbsoluteFile().toString().endsWith(".3gp") || fp.getAbsoluteFile().toString().endsWith(".3gpp")) {
if (data.toString().contains("/audio/")) {
obj.put("type", AUDIO_3GPP);
@@ -370,7 +365,7 @@ public class Capture extends CordovaPlugin {
obj.put("type", VIDEO_3GPP);
}
} else {
- obj.put("type", dataResource.getMimeType());
+ obj.put("type", FileHelper.getMimeType(fp.getAbsolutePath(), cordova));
}
obj.put("lastModifiedDate", fp.lastModified());
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c5b37cc7/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index fe5a4ab..f6db0ac 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -18,6 +18,8 @@
*/
package org.apache.cordova;
+import android.database.Cursor;
+import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Base64;
@@ -25,7 +27,6 @@ import android.util.Log;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.DataResource;
import org.apache.cordova.api.PluginResult;
import org.apache.cordova.file.EncodingException;
import org.apache.cordova.file.FileExistsException;
@@ -45,6 +46,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLDecoder;
import java.nio.channels.FileChannel;
/**
@@ -231,7 +234,7 @@ public class FileUtils extends CordovaPlugin {
* @param filePath the path to check
*/
private void notifyDelete(String filePath) {
- String newFilePath = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.notifyDelete").getRealFile().getPath();
+ String newFilePath = FileHelper.getRealPath(filePath, cordova);
try {
this.cordova.getActivity().getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
MediaStore.Images.Media.DATA + " = ?",
@@ -253,10 +256,37 @@ public class FileUtils extends CordovaPlugin {
* @throws IOException if the user can't read the file
* @throws JSONException
*/
+ @SuppressWarnings("deprecation")
private JSONObject resolveLocalFileSystemURI(String url) throws IOException, JSONException {
- File fp = DataResource.initiateNewDataRequestForUri(url, webView.pluginManager, cordova, "FileUtils.resolveLocalFileSystemURI").getRealFile();
+ String decoded = URLDecoder.decode(url, "UTF-8");
- if (fp == null || !fp.exists()) {
+ File fp = null;
+
+ // Handle the special case where you get an Android content:// uri.
+ if (decoded.startsWith("content:")) {
+ Cursor cursor = this.cordova.getActivity().managedQuery(Uri.parse(decoded), new String[] { MediaStore.Images.Media.DATA }, null, null, null);
+ // Note: MediaStore.Images/Audio/Video.Media.DATA is always "_data"
+ int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+ cursor.moveToFirst();
+ fp = new File(cursor.getString(column_index));
+ } else {
+ // Test to see if this is a valid URL first
+ @SuppressWarnings("unused")
+ URL testUrl = new URL(decoded);
+
+ if (decoded.startsWith("file://")) {
+ int questionMark = decoded.indexOf("?");
+ if (questionMark < 0) {
+ fp = new File(decoded.substring(7, decoded.length()));
+ } else {
+ fp = new File(decoded.substring(7, questionMark));
+ }
+ } else {
+ fp = new File(decoded);
+ }
+ }
+
+ if (!fp.exists()) {
throw new FileNotFoundException();
}
if (!fp.canRead()) {
@@ -274,9 +304,9 @@ public class FileUtils extends CordovaPlugin {
* @throws JSONException
*/
private JSONArray readEntries(String fileName) throws FileNotFoundException, JSONException {
- File fp = DataResource.initiateNewDataRequestForUri(fileName, webView.pluginManager, cordova, "FileUtils.readEntries").getRealFile();
+ File fp = createFileObject(fileName);
- if (fp == null || !fp.exists()) {
+ if (!fp.exists()) {
// The directory we are listing doesn't exist so we should fail.
throw new FileNotFoundException();
}
@@ -311,10 +341,8 @@ public class FileUtils extends CordovaPlugin {
* @throws FileExistsException
*/
private JSONObject transferTo(String fileName, String newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException {
- DataResource dataResourceFrom = DataResource.initiateNewDataRequestForUri(fileName, webView.pluginManager, cordova, "FileUtils.transferTo");
- String newFileName = dataResourceFrom.getRealFile().getPath();
- DataResource dataResourceTo = DataResource.initiateNewDataRequestForUri(newParent, webView.pluginManager, cordova, "FileUtils.transferTo");
- newParent = dataResourceTo.getRealFile().getPath();
+ String newFileName = FileHelper.getRealPath(fileName, cordova);
+ newParent = FileHelper.getRealPath(newParent, cordova);
// Check for invalid file name
if (newName != null && newName.contains(":")) {
@@ -585,7 +613,7 @@ public class FileUtils extends CordovaPlugin {
* @throws FileExistsException
*/
private boolean removeRecursively(String filePath) throws FileExistsException {
- File fp = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.readEntries").getRealFile();
+ File fp = createFileObject(filePath);
// You can't delete the root directory.
if (atRootDirectory(filePath)) {
@@ -626,7 +654,7 @@ public class FileUtils extends CordovaPlugin {
* @throws InvalidModificationException
*/
private boolean remove(String filePath) throws NoModificationAllowedException, InvalidModificationException {
- File fp = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.readEntries").getRealFile();
+ File fp = createFileObject(filePath);
// You can't delete the root directory.
if (atRootDirectory(filePath)) {
@@ -670,8 +698,7 @@ public class FileUtils extends CordovaPlugin {
throw new EncodingException("This file has a : in it's name");
}
- String filePath = getFullFilePath(dirPath, fileName);
- File fp = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.getFile").getRealFile();
+ File fp = createFileObject(dirPath, fileName);
if (create) {
if (exclusive && fp.exists()) {
@@ -713,14 +740,15 @@ public class FileUtils extends CordovaPlugin {
* @param fileName new file name
* @return
*/
- private String getFullFilePath(String dirPath, String fileName) {
+ private File createFileObject(String dirPath, String fileName) {
+ File fp = null;
if (fileName.startsWith("/")) {
- return fileName;
+ fp = new File(fileName);
} else {
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(dirPath, webView.pluginManager, cordova, "FileUtils.getFullFilePath");
- dirPath = dataResource.getRealFile().getPath();
- return dirPath + File.separator + fileName;
+ dirPath = FileHelper.getRealPath(dirPath, cordova);
+ fp = new File(dirPath + File.separator + fileName);
}
+ return fp;
}
/**
@@ -732,13 +760,12 @@ public class FileUtils extends CordovaPlugin {
* @throws JSONException
*/
private JSONObject getParent(String filePath) throws JSONException {
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.getParent");
- filePath = dataResource.getRealFile().getPath();
+ filePath = FileHelper.getRealPath(filePath, cordova);
if (atRootDirectory(filePath)) {
return getEntry(filePath);
}
- return getEntry(dataResource.getRealFile().getParent());
+ return getEntry(new File(filePath).getParent());
}
/**
@@ -749,7 +776,7 @@ public class FileUtils extends CordovaPlugin {
* @return true if we are at the root, false otherwise.
*/
private boolean atRootDirectory(String filePath) {
- filePath = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.atRootDirectory").getRealFile().getPath();
+ filePath = FileHelper.getRealPath(filePath, cordova);
if (filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + cordova.getActivity().getPackageName() + "/cache") ||
filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath()) ||
@@ -760,6 +787,19 @@ public class FileUtils extends CordovaPlugin {
}
/**
+ * Create a File object from the passed in path
+ *
+ * @param filePath
+ * @return
+ */
+ private File createFileObject(String filePath) {
+ filePath = FileHelper.getRealPath(filePath, cordova);
+
+ File file = new File(filePath);
+ return file;
+ }
+
+ /**
* Look up metadata about this entry.
*
* @param filePath to entry
@@ -767,9 +807,9 @@ public class FileUtils extends CordovaPlugin {
* @throws FileNotFoundException
*/
private long getMetadata(String filePath) throws FileNotFoundException {
- File file = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.getMetadata").getRealFile();
+ File file = createFileObject(filePath);
- if (file == null || !file.exists()) {
+ if (!file.exists()) {
throw new FileNotFoundException("Failed to find file in getMetadata");
}
@@ -785,16 +825,15 @@ public class FileUtils extends CordovaPlugin {
* @throws JSONException
*/
private JSONObject getFileMetadata(String filePath) throws FileNotFoundException, JSONException {
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.getMetadata");
- File file = dataResource.getRealFile();
+ File file = createFileObject(filePath);
- if (file == null || !file.exists()) {
+ if (!file.exists()) {
throw new FileNotFoundException("File: " + filePath + " does not exist.");
}
JSONObject metadata = new JSONObject();
metadata.put("size", file.length());
- metadata.put("type", dataResource.getMimeType());
+ metadata.put("type", FileHelper.getMimeType(filePath, cordova));
metadata.put("name", file.getName());
metadata.put("fullPath", filePath);
metadata.put("lastModifiedDate", file.lastModified());
@@ -896,8 +935,7 @@ public class FileUtils extends CordovaPlugin {
this.cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(filename, webView.pluginManager, cordova, "FileUtils.readFileAs");
- byte[] bytes = readAsBinaryHelper(dataResource.getIs(), start, end);
+ byte[] bytes = readAsBinaryHelper(filename, start, end);
PluginResult result;
switch (resultType) {
@@ -938,9 +976,10 @@ public class FileUtils extends CordovaPlugin {
* @return Contents of the file as a byte[].
* @throws IOException
*/
- private byte[] readAsBinaryHelper(InputStream inputStream, int start, int end) throws IOException {
+ private byte[] readAsBinaryHelper(String filename, int start, int end) throws IOException {
int numBytesToRead = end - start;
byte[] bytes = new byte[numBytesToRead];
+ InputStream inputStream = FileHelper.getInputStreamFromUriString(filename, cordova);
int numBytesRead = 0;
if (start > 0) {
@@ -969,8 +1008,7 @@ public class FileUtils extends CordovaPlugin {
throw new NoModificationAllowedException("Couldn't write to file given its content URI");
}
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(filename, webView.pluginManager, cordova, "FileUtils.write");
- filename = dataResource.getRealFile().getPath();
+ filename = FileHelper.getRealPath(filename, cordova);
boolean append = false;
if (offset > 0) {
@@ -999,16 +1037,13 @@ public class FileUtils extends CordovaPlugin {
* @throws NoModificationAllowedException
*/
private long truncateFile(String filename, long size) throws FileNotFoundException, IOException, NoModificationAllowedException {
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(filename, webView.pluginManager, cordova, "FileUtils.truncateFile");
- if(!dataResource.isWritable()) {
- throw new NoModificationAllowedException("Couldn't truncate file as it is not writable");
- }
- File file = dataResource.getRealFile();
- if(file == null) {
- throw new FileNotFoundException("Couldn't get the file");
+ if (filename.startsWith("content://")) {
+ throw new NoModificationAllowedException("Couldn't truncate file given its content URI");
}
- RandomAccessFile raf = new RandomAccessFile(file, "rw");
+ filename = FileHelper.getRealPath(filename, cordova);
+
+ RandomAccessFile raf = new RandomAccessFile(filename, "rw");
try {
if (raf.length() >= size) {
FileChannel channel = raf.getChannel();
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c5b37cc7/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index 2a686d8..d71fbe8 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -49,7 +49,6 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
new DataResourceContext("WebViewClient.shouldInterceptRequest", true /* this is from a browser request*/));
url = dataResource.getUri().toString();
- // This mechanism is no longer needed due to the dataResource mechanism. It would be awesome to just get rid of it.
//Check if plugins intercept the request
WebResourceResponse ret = super.shouldInterceptRequest(view, url);
// The below bugfix is taken care of by the dataResource mechanism
[6/6] android commit: Trying to get DataResource reverted so that we
don't have to worry about this blowing up while we're breaking things out.
DataResource should be on a branch until it's ready!
Posted by bo...@apache.org.
Trying to get DataResource reverted so that we don't have to worry about this blowing up while we're breaking things out. DataResource should be on a branch until it's ready!
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/3753e3f3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/3753e3f3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/3753e3f3
Branch: refs/heads/master
Commit: 3753e3f3532da0f4dbd08ee1c1b68cf5be6465b9
Parents: 979d8e6
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Jun 6 14:35:12 2013 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jun 6 14:35:12 2013 -0700
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileUtils.java | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/3753e3f3/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index f6db0ac..aeca505 100755
--- a/framework/src/org/apache/cordova/FileUtils.java
+++ b/framework/src/org/apache/cordova/FileUtils.java
@@ -949,7 +949,7 @@ public class FileUtils extends CordovaPlugin {
result = new PluginResult(PluginResult.Status.OK, bytes, true);
break;
default: // Base64.
- String contentType = dataResource.getMimeType();
+ String contentType = FileHelper.getMimeType(filename, cordova);
byte[] base64 = Base64.encode(bytes, Base64.DEFAULT);
String s = "data:" + contentType + ";base64," + new String(base64, "US-ASCII");
result = new PluginResult(PluginResult.Status.OK, s);
[2/6] android commit: Revert "DataResource bugfix WebviewClient logs
error for http urls."
Posted by bo...@apache.org.
Revert "DataResource bugfix WebviewClient logs error for http urls."
This reverts commit 8f91ebf194baa8028367e9e41f2e5ee2ff099b88.
Reverting all DataResource changes for the 2.8.0 release.
Conflicts:
framework/src/org/apache/cordova/FileHelper.java
framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/2f9c512b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/2f9c512b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/2f9c512b
Branch: refs/heads/master
Commit: 2f9c512b5942ae2c04002fe8c5581b6d514b8c52
Parents: 43172cf
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon May 27 22:21:50 2013 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jun 6 14:08:52 2013 -0700
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileHelper.java | 2 +-
.../cordova/IceCreamCordovaWebViewClient.java | 8 +-------
2 files changed, 2 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/2f9c512b/framework/src/org/apache/cordova/FileHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileHelper.java b/framework/src/org/apache/cordova/FileHelper.java
index 0d13c12..69c7f48 100644
--- a/framework/src/org/apache/cordova/FileHelper.java
+++ b/framework/src/org/apache/cordova/FileHelper.java
@@ -107,7 +107,7 @@ public class FileHelper {
return new FileInputStream(getRealPath(uriString, cordova));
}
} else {
- return null;
+ return new FileInputStream(getRealPath(uriString, cordova));
}
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/2f9c512b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index d68b6b8..4b3408c 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -19,7 +19,6 @@
package org.apache.cordova;
import java.io.IOException;
-import java.io.InputStream;
import org.apache.cordova.api.CordovaInterface;
import org.apache.cordova.api.DataResource;
@@ -56,12 +55,7 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
if(ret == null) {
try {
- InputStream is = dataResource.getInputStream();
- if(is != null) {
- String mimeType = dataResource.getMimeType();
- // If we don't know how to open this file, let the browser continue loading
- ret = new WebResourceResponse(mimeType, "UTF-8", is);
- }
+ ret = new WebResourceResponse(dataResource.getMimeType(), "UTF-8", dataResource.getInputStream());
} catch(IOException e) {
LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file.", e);
}
[5/6] android commit: Revert "Added "DataResource" - allows many
plugins to intercept a single request"
Posted by bo...@apache.org.
Revert "Added "DataResource" - allows many plugins to intercept a single request"
This reverts commit 62c3e4652975f3e23a2f5a203dc13f7d4c98a30e.
Reverting all DataResource changes for the 2.8.0 release.
Conflicts:
framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
framework/src/org/apache/cordova/api/DataResource.java
framework/src/org/apache/cordova/api/DataResourceContext.java
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/979d8e66
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/979d8e66
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/979d8e66
Branch: refs/heads/master
Commit: 979d8e66f26d27a132d7514386b777fc8fc234f3
Parents: c5b37cc
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon May 27 22:22:18 2013 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jun 6 14:14:14 2013 -0700
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileHelper.java | 58 +-----
.../cordova/IceCreamCordovaWebViewClient.java | 48 +++--
.../src/org/apache/cordova/api/CordovaPlugin.java | 14 --
.../src/org/apache/cordova/api/DataResource.java | 156 ---------------
.../apache/cordova/api/DataResourceContext.java | 56 -----
.../src/org/apache/cordova/api/PluginManager.java | 26 ---
6 files changed, 35 insertions(+), 323 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/979d8e66/framework/src/org/apache/cordova/FileHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileHelper.java b/framework/src/org/apache/cordova/FileHelper.java
index e7bf98a..ebbdc8d 100644
--- a/framework/src/org/apache/cordova/FileHelper.java
+++ b/framework/src/org/apache/cordova/FileHelper.java
@@ -26,11 +26,10 @@ import org.apache.cordova.api.CordovaInterface;
import org.apache.cordova.api.LOG;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
+import java.net.URLConnection;
+import java.util.Locale;
public class FileHelper {
private static final String LOG_TAG = "FileUtils";
@@ -91,7 +90,7 @@ public class FileHelper {
* @throws IOException
*/
public static InputStream getInputStreamFromUriString(String uriString, CordovaInterface cordova) throws IOException {
- if (uriString.startsWith("content:")) {
+ if (uriString.startsWith("content")) {
Uri uri = Uri.parse(uriString);
return cordova.getActivity().getContentResolver().openInputStream(uri);
} else if (uriString.startsWith("file://")) {
@@ -111,57 +110,6 @@ public class FileHelper {
}
}
- public static OutputStream getOutputStreamFromUriString(String uriString, CordovaInterface cordova) throws FileNotFoundException{
- if (uriString.startsWith("content:")) {
- Uri uri = Uri.parse(uriString);
- return cordova.getActivity().getContentResolver().openOutputStream(uri);
- } else if (uriString.startsWith("file:") && !uriString.startsWith("file:///android_asset/")) {
- String realPath = uriString.substring(7);
- return new FileOutputStream(realPath);
- } else {
- return null;
- }
- }
- /**
- * Returns whether the uri can be written to by openeing a File to that uri
- *
- * @param the URI to test
- * @return boolean indicating whether the uri is writable
- */
- public static boolean isUriWritable(String uriString) {
- String scheme = uriString.split(":")[0];
- String writableSchemes[] = new String[]{ "content" };
-
- if(scheme.equals("file")){
- // special case file
- if(uriString.startsWith("file:///android_asset/")){
- return false;
- } else {
- return true;
- }
- }
- for(int i = writableSchemes.length - 1; i >= 0 ; i--){
- if(writableSchemes[i].equals(scheme)){
- return true;
- }
- }
- return false;
- }
-
- /**
- * Ensures the "file://" prefix exists for the given string
- * If the given URI string has a "file://" prefix, it is returned unchanged
- *
- * @param path - the path string to operate on
- * @return a String with the "file://" scheme set
- */
- public static String insertFileProtocol(String path) {
- if(!path.matches("^[a-z0-9+.-]+:.*")){
- path = "file://" + path;
- }
- return path;
- }
-
/**
* Removes the "file://" prefix from the given URI string, if applicable.
* If the given URI string doesn't have a "file://" prefix, it is returned unchanged.
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/979d8e66/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index d71fbe8..847972e 100644
--- a/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -19,10 +19,9 @@
package org.apache.cordova;
import java.io.IOException;
+import java.io.InputStream;
import org.apache.cordova.api.CordovaInterface;
-import org.apache.cordova.api.DataResource;
-import org.apache.cordova.api.DataResourceContext;
import org.apache.cordova.api.LOG;
import android.annotation.TargetApi;
@@ -44,24 +43,41 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
- // We need to support the new DataResource intercepts without breaking the shouldInterceptRequest mechanism.
- DataResource dataResource = DataResource.initiateNewDataRequestForUri(url, this.appView.pluginManager, cordova,
- new DataResourceContext("WebViewClient.shouldInterceptRequest", true /* this is from a browser request*/));
- url = dataResource.getUri().toString();
-
//Check if plugins intercept the request
WebResourceResponse ret = super.shouldInterceptRequest(view, url);
-// The below bugfix is taken care of by the dataResource mechanism
-// if(ret == null && (url.contains("?") || url.contains("#") || needsIceCreamSpaceInAssetUrlFix(url))){
-// ret = generateWebResourceResponse(url);
-// }
- if(ret == null) {
+ if(ret == null && (url.contains("?") || url.contains("#") || needsIceCreamSpaceInAssetUrlFix(url))){
+ ret = generateWebResourceResponse(url);
+ }
+ return ret;
+ }
+
+ private WebResourceResponse generateWebResourceResponse(String url) {
+ if (url.startsWith("file:///android_asset/")) {
+ String mimetype = FileHelper.getMimeType(url, cordova);
+
try {
- ret = new WebResourceResponse(dataResource.getMimeType(), "UTF-8", dataResource.getInputStream());
- } catch(IOException e) {
- LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file.", e);
+ InputStream stream = FileHelper.getInputStreamFromUriString(url, cordova);
+ WebResourceResponse response = new WebResourceResponse(mimetype, "UTF-8", stream);
+ return response;
+ } catch (IOException e) {
+ LOG.e("generateWebResourceResponse", e.getMessage(), e);
}
}
- return ret;
+ return null;
}
+
+ private static boolean needsIceCreamSpaceInAssetUrlFix(String url) {
+ if (!url.contains("%20")){
+ 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;
+ default:
+ return false;
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/979d8e66/framework/src/org/apache/cordova/api/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/CordovaPlugin.java b/framework/src/org/apache/cordova/api/CordovaPlugin.java
index 69f8fde..2b225e6 100644
--- a/framework/src/org/apache/cordova/api/CordovaPlugin.java
+++ b/framework/src/org/apache/cordova/api/CordovaPlugin.java
@@ -176,20 +176,6 @@ public class CordovaPlugin {
}
/**
- * All plugins can now choose if they want to modify any uri requests. This includes all webview requests, opening of files, content uri's etc.
- * This mechanism allows several plugins to modify the same request
- * @param requestSource The source of the incoming request
- *
- * @param dataResource The resource to be loaded.
- * @param dataResourceContext Context associated with the resource load
- * @return Return a new DataResource if the plugin wants o assist in loading the request or null if it doesn't.
- */
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- public DataResource shouldInterceptDataResourceRequest(DataResource dataResource, DataResourceContext dataResourceContext) {
- return null;
- }
-
- /**
* Called when the WebView does a top-level navigation or refreshes.
*
* Plugins should stop any long-running processes and clean up internal state.
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/979d8e66/framework/src/org/apache/cordova/api/DataResource.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/DataResource.java b/framework/src/org/apache/cordova/api/DataResource.java
deleted file mode 100644
index 38bf31b..0000000
--- a/framework/src/org/apache/cordova/api/DataResource.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova.api;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.cordova.FileHelper;
-
-import android.net.Uri;
-
-/*
- * All requests to access files, browser network requests etc have to go through this class.
- */
-public class DataResource {
- private CordovaInterface cordova;
-
- // Uri of the request. Always required.
- private Uri uri;
- // Remaining fields may or may not be null
- private InputStream is;
- private OutputStream os;
- private String mimeType;
- private Boolean writable;
- private File realFile;
- private boolean retryLoad = true;
-
- public DataResource(CordovaInterface cordova, Uri uri) {
- super();
- this.cordova = cordova;
- this.uri = uri;
- }
- public DataResource(CordovaInterface cordova, Uri uri, InputStream is,
- OutputStream os, String mimeType, boolean writable, File realFile) {
- this(cordova, uri);
- this.is = is;
- this.mimeType = mimeType;
- this.writable = Boolean.valueOf(writable);
- this.realFile = realFile;
- }
- public Uri getUri() {
- // Uri is always provided
- return uri;
- }
- public InputStream getIs() throws IOException {
- if(is == null && retryLoad) {
- try {
- is = FileHelper.getInputStreamFromUriString(uri.toString(), cordova);
- } finally {
- // We failed loading once, don't try loading anymore
- if(is == null) {
- retryLoad = false;
- }
- }
- }
- return is;
- }
- public OutputStream getOs() throws FileNotFoundException {
- if(os == null && retryLoad) {
- try {
- os = FileHelper.getOutputStreamFromUriString(uri.toString(), cordova);
- } finally {
- // We failed loading once, don't try loading anymore
- if(os == null) {
- retryLoad = false;
- }
- }
- }
- return os;
- }
- public String getMimeType() {
- if(mimeType == null && retryLoad) {
- try {
- mimeType = FileHelper.getMimeType(uri.toString(), cordova);
- } finally {
- // We failed loading once, don't try loading anymore
- if(mimeType == null) {
- retryLoad = false;
- }
- }
- }
- return mimeType;
- }
- public boolean isWritable() {
- if(writable == null && retryLoad) {
- try {
- writable = FileHelper.isUriWritable(uri.toString());
- } finally {
- // We failed loading once, don't try loading anymore
- if(writable == null) {
- retryLoad = false;
- }
- }
- }
- // default to false
- return writable != null? writable.booleanValue() : false;
- }
- public File getRealFile() {
- if(realFile == null && retryLoad) {
- try {
- String realPath = FileHelper.getRealPath(uri, cordova);
- if(realPath != null) {
- realFile = new File(realPath);
- }
- } finally {
- // We failed loading once, don't try loading anymore
- if(realFile == null) {
- retryLoad = false;
- }
- }
- }
- return realFile;
- }
-
- // static instantiation methods
- public static DataResource initiateNewDataRequestForUri(String uriString, PluginManager pluginManager, CordovaInterface cordova, String requestSourceTag){
- // if no protocol is specified, assume its file:
- uriString = FileHelper.insertFileProtocol(uriString);
- return initiateNewDataRequestForUri(Uri.parse(uriString), pluginManager, cordova, requestSourceTag);
- }
- public static DataResource initiateNewDataRequestForUri(Uri uri, PluginManager pluginManager, CordovaInterface cordova, String requestSourceTag){
- return initiateNewDataRequestForUri(uri, pluginManager, cordova, new DataResourceContext(requestSourceTag, false /* Assume, not a browser request by default */ ));
- }
- public static DataResource initiateNewDataRequestForUri(String uriString, PluginManager pluginManager, CordovaInterface cordova, DataResourceContext dataResourceContext){
- // if no protocol is specified, assume its file:
- uriString = FileHelper.insertFileProtocol(uriString);
- return initiateNewDataRequestForUri(Uri.parse(uriString), pluginManager, cordova, dataResourceContext);
- }
- public static DataResource initiateNewDataRequestForUri(Uri uri, PluginManager pluginManager, CordovaInterface cordova, DataResourceContext dataResourceContext){
- DataResource dataResource = new DataResource(cordova, uri);
- if (pluginManager != null) {
- // get the resource as returned by plugins
- dataResource = pluginManager.shouldInterceptDataResourceRequest(dataResource, dataResourceContext);
- }
- return dataResource;
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/979d8e66/framework/src/org/apache/cordova/api/DataResourceContext.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/DataResourceContext.java b/framework/src/org/apache/cordova/api/DataResourceContext.java
deleted file mode 100644
index 55bbc1d..0000000
--- a/framework/src/org/apache/cordova/api/DataResourceContext.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova.api;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-/*
- * Some context information associated with a DataRequest.
- */
-public class DataResourceContext {
- // A random id that is unique for a particular request.
- private int requestId;
- // A tag associated with the source of this dataResourceContext
- private String source;
- // If needed, any data associated with core plugins can be a part of the context object
- // This field indicates whether the request came from a browser network request
- private boolean isFromBrowser;
- // If needed, any data associated with non core plugins should store data in a Map so as to not clutter the context object
- private Map<String, Object> dataMap;
- public DataResourceContext(String source, boolean isFromBrowser) {
- super();
- this.requestId = new Random().nextInt();
- this.source = source;
- this.isFromBrowser = isFromBrowser;
- this.dataMap = new HashMap<String, Object>();
- }
- public int getRequestId() {
- return requestId;
- }
- public String getSource() {
- return source;
- }
- public boolean isFromBrowser() {
- return isFromBrowser;
- }
- public Map<String, Object> getDataMap() {
- return dataMap;
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/979d8e66/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java
index 36ac357..71fc258 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -400,30 +400,4 @@ public class PluginManager {
LOG.e(TAG, "https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
LOG.e(TAG, "=====================================================================================");
}
-
- /**
- * Called when the any resource is going to be loaded - either from the webview, files or any other resource
- *
- *
- * @param dataResource The resource request to be loaded.
- * @param dataResourceContext The context of the dataResource request
- * @return Return the resource request that will be loaded. The returned request may be modified or unchanged.
- */
- public DataResource shouldInterceptDataResourceRequest(DataResource dataResource, DataResourceContext dataResourceContext){
- boolean requestModified = true;
- while(requestModified) {
- requestModified = false;
- for (PluginEntry entry : this.entries.values()) {
- if (entry.plugin != null) {
- DataResource ret = entry.plugin.shouldInterceptDataResourceRequest(dataResource, dataResourceContext);
- if(ret != null) {
- dataResource = ret;
- requestModified = true;
- break;
- }
- }
- }
- }
- return dataResource;
- }
}