Reattach the scheme to filepath of UploadHandler
The native layer expects the filepath in a Url
format. Sending an absolute path causes the conversion
to a url to be invalid.
Thus reattaching the scheme converts the file path
to valid URL.
Change-Id: I5566108398ccc4dcba6d750c95f63b84cacf492b
diff --git a/src/com/android/browser/UploadHandler.java b/src/com/android/browser/UploadHandler.java
index 34de006..e0d1527 100644
--- a/src/com/android/browser/UploadHandler.java
+++ b/src/com/android/browser/UploadHandler.java
@@ -106,11 +106,11 @@
}
}
- // try to get local file path from uri
boolean hasGoodFilePath = false;
String filePath = null;
if (result != null) {
String scheme = result.getScheme();
+ // try to get local file path from uri
if ("file".equals(scheme)) {
filePath = result.getPath();
hasGoodFilePath = filePath != null && !filePath.isEmpty();
@@ -118,6 +118,10 @@
filePath = getFilePath(mController.getContext(), result);
hasGoodFilePath = filePath != null && !filePath.isEmpty();
}
+
+ // The native layer only accepts path based on file scheme
+ // and skips anything else passed to it
+ filePath = "file://"+filePath;
}
// Add for carrier feature - prevent uploading DRM type files.
@@ -134,7 +138,6 @@
}
if (mUploadMessage != null) {
-
if (!isDRMFileType) {
mUploadMessage.onReceiveValue(result);
} else {
@@ -145,6 +148,7 @@
if (mUploadFilePaths != null) {
if (hasGoodFilePath && !isDRMFileType) {
Log.d(TAG, "upload file path:" + filePath);
+
mUploadFilePaths.onReceiveValue(new String[]{filePath});
} else {
mUploadFilePaths.onReceiveValue(null);