mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 20:33:07 +08:00
[CB-3384] Fix thread assertion when plugins remap URIs
This commit is contained in:
parent
8202ab83fa
commit
b915aafb5b
@ -156,9 +156,24 @@ public class CordovaResourceApi {
|
|||||||
* @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
|
* @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
|
||||||
* resolved before being passed into this function.
|
* resolved before being passed into this function.
|
||||||
* @throws Throws an IOException if the URI cannot be opened.
|
* @throws Throws an IOException if the URI cannot be opened.
|
||||||
|
* @throws Throws an IllegalStateException if called on a foreground thread.
|
||||||
*/
|
*/
|
||||||
public OpenForReadResult openForRead(Uri uri) throws IOException {
|
public OpenForReadResult openForRead(Uri uri) throws IOException {
|
||||||
|
return openForRead(uri, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a stream to the givne URI, also providing the MIME type & length.
|
||||||
|
* @return Never returns null.
|
||||||
|
* @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be
|
||||||
|
* resolved before being passed into this function.
|
||||||
|
* @throws Throws an IOException if the URI cannot be opened.
|
||||||
|
* @throws Throws an IllegalStateException if called on a foreground thread and skipThreadCheck is false.
|
||||||
|
*/
|
||||||
|
public OpenForReadResult openForRead(Uri uri, boolean skipThreadCheck) throws IOException {
|
||||||
|
if (!skipThreadCheck) {
|
||||||
assertBackgroundThread();
|
assertBackgroundThread();
|
||||||
|
}
|
||||||
switch (getUriType(uri)) {
|
switch (getUriType(uri)) {
|
||||||
case URI_TYPE_FILE: {
|
case URI_TYPE_FILE: {
|
||||||
FileInputStream inputStream = new FileInputStream(uri.getPath());
|
FileInputStream inputStream = new FileInputStream(uri.getPath());
|
||||||
|
@ -59,7 +59,7 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
|
|||||||
Uri remappedUri = resourceApi.remapUri(origUri);
|
Uri remappedUri = resourceApi.remapUri(origUri);
|
||||||
|
|
||||||
if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri)) {
|
if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri)) {
|
||||||
OpenForReadResult result = resourceApi.openForRead(remappedUri);
|
OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
|
||||||
return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
|
return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
|
||||||
}
|
}
|
||||||
// If we don't need to special-case the request, let the browser load it.
|
// If we don't need to special-case the request, let the browser load it.
|
||||||
|
Loading…
Reference in New Issue
Block a user