Throw platform exception when ProcessGlobalConfig.apply throws an error on the native side to be able to catch it on Flutter side, updated e.printStackTrace with Log.e where possible
This commit is contained in:
parent
35fea2c331
commit
23097dbce0
|
@ -1,3 +1,7 @@
|
|||
## 1.0.4
|
||||
|
||||
- Throw platform exception when ProcessGlobalConfig.apply throws an error on the native side
|
||||
|
||||
## 1.0.3
|
||||
|
||||
- Updated `ContentBlockerHandler` CSS_DISPLAY_NONE action type and `JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_SOURCE` javascript implementation code
|
||||
|
|
|
@ -250,16 +250,14 @@ public class MyCookieManager extends ChannelDelegateImpl {
|
|||
cookieMap.put("expiresDate", expiryDate.getTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
} else if (cookieParamName.equalsIgnoreCase("Max-Age")) {
|
||||
try {
|
||||
long maxAge = Long.parseLong(cookieParamValue);
|
||||
cookieMap.put("expiresDate", System.currentTimeMillis() + maxAge);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
} else if (cookieParamName.equalsIgnoreCase("Domain")) {
|
||||
cookieMap.put("domain", cookieParamValue);
|
||||
|
|
|
@ -142,15 +142,13 @@ public class Util {
|
|||
}
|
||||
certificateFileStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
Log.e(LOG_TAG, "", e);
|
||||
} finally {
|
||||
if (certificateFileStream != null) {
|
||||
try {
|
||||
certificateFileStream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
Log.e(LOG_TAG, ex.getMessage());
|
||||
Log.e(LOG_TAG, "", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -193,8 +191,7 @@ public class Util {
|
|||
}
|
||||
catch (Exception e) {
|
||||
if (!(e instanceof SSLHandshakeException)) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
if (urlConnection != null) {
|
||||
urlConnection.disconnect();
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.pichillilorenzo.flutter_inappwebview_android.content_blocker;
|
|||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebResourceResponse;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -229,7 +230,7 @@ public class ContentBlockerHandler {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
if (!(e instanceof SSLHandshakeException)) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
} finally {
|
||||
urlConnection.disconnect();
|
||||
|
@ -262,8 +263,7 @@ public class ContentBlockerHandler {
|
|||
// response.close();
|
||||
// }
|
||||
// if (!(e instanceof SSLHandshakeException)) {
|
||||
// e.printStackTrace();
|
||||
// Log.e(LOG_TAG, e.getMessage());
|
||||
// Log.e(LOG_TAG, "", e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public class ContentBlockerHandler {
|
|||
responseResourceType = getResourceTypeFromContentType(contentType);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
} finally {
|
||||
urlConnection.disconnect();
|
||||
}
|
||||
|
|
|
@ -163,7 +163,6 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
|
|||
try {
|
||||
webView.loadFile(initialFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, initialFile + " asset file cannot be found!", e);
|
||||
return;
|
||||
}
|
||||
|
@ -417,8 +416,7 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
|
|||
openActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivityIfNeeded(openActivity, 0);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
Log.d(LOG_TAG, e.getMessage());
|
||||
Log.d(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.pichillilorenzo.flutter_inappwebview_android.process_global_config;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.webkit.ProcessGlobalConfig;
|
||||
|
@ -13,7 +15,7 @@ import io.flutter.plugin.common.MethodCall;
|
|||
import io.flutter.plugin.common.MethodChannel;
|
||||
|
||||
public class ProcessGlobalConfigManager extends ChannelDelegateImpl {
|
||||
protected static final String LOG_TAG = "ProcessGlobalConfigManager";
|
||||
protected static final String LOG_TAG = "ProcessGlobalConfigM";
|
||||
public static final String METHOD_CHANNEL_NAME = "com.pichillilorenzo/flutter_inappwebview_processglobalconfig";
|
||||
|
||||
@Nullable
|
||||
|
@ -31,9 +33,15 @@ public class ProcessGlobalConfigManager extends ChannelDelegateImpl {
|
|||
if (plugin != null && plugin.activity != null) {
|
||||
ProcessGlobalConfigSettings settings = (new ProcessGlobalConfigSettings())
|
||||
.parse((Map<String, Object>) call.argument("settings"));
|
||||
ProcessGlobalConfig.apply(settings.toProcessGlobalConfig(plugin.activity));
|
||||
try {
|
||||
ProcessGlobalConfig.apply(settings.toProcessGlobalConfig(plugin.activity));
|
||||
result.success(true);
|
||||
} catch (Exception e) {
|
||||
result.error(LOG_TAG, "", e);
|
||||
}
|
||||
} else {
|
||||
result.success(false);
|
||||
}
|
||||
result.success(true);
|
||||
break;
|
||||
default:
|
||||
result.notImplemented();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.pichillilorenzo.flutter_inappwebview_android.service_worker;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
|
||||
|
@ -61,7 +62,7 @@ public class ServiceWorkerManager implements Disposable {
|
|||
try {
|
||||
response = channelDelegate.shouldInterceptRequest(requestExt);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.pichillilorenzo.flutter_inappwebview_android.types;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebResourceResponse;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -122,7 +123,7 @@ public class WebViewAssetLoaderExt implements Disposable {
|
|||
try {
|
||||
response = channelDelegate.handle(path);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class JavaScriptBridgeInterface {
|
|||
inAppWebView.callAsyncJavaScriptCallbacks.remove(resultUuid);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
return;
|
||||
} else if (handlerName.equals("evaluateJavaScriptWithContentWorld")) {
|
||||
|
@ -114,7 +114,7 @@ public class JavaScriptBridgeInterface {
|
|||
inAppWebView.evaluateJavaScriptContentWorldCallbacks.remove(resultUuid);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,6 @@ public class FlutterWebView implements PlatformWebView {
|
|||
try {
|
||||
webView.loadFile(initialFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, initialFile + " asset file cannot be found!", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -729,7 +729,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
|
|||
try {
|
||||
compressFormat = Bitmap.CompressFormat.valueOf((String) screenshotConfiguration.get("compressFormat"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
|
||||
quality = (Integer) screenshotConfiguration.get("quality");
|
||||
|
@ -743,13 +743,13 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
|
|||
try {
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
screenshotBitmap.recycle();
|
||||
result.success(byteArrayOutputStream.toByteArray());
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
result.success(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -790,11 +790,7 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
|
|||
try {
|
||||
byteArrayOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
String errorMessage = e.getMessage();
|
||||
if (errorMessage != null) {
|
||||
Log.e(LOG_TAG, errorMessage);
|
||||
}
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
icon.recycle();
|
||||
|
||||
|
@ -1176,7 +1172,6 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
|
|||
capturedFile = getCapturedFile(intentType);
|
||||
} catch (IOException e) {
|
||||
Log.e(LOG_TAG, "Error occurred while creating the File", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (capturedFile == null) {
|
||||
return null;
|
||||
|
@ -1199,11 +1194,7 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
|
|||
fileProviderAuthority,
|
||||
capturedFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
String errorMessage = e.getMessage();
|
||||
if (errorMessage != null) {
|
||||
Log.e(LOG_TAG, errorMessage);
|
||||
}
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -360,7 +360,7 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
protocol = uri.getScheme();
|
||||
port = uri.getPort();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -451,7 +451,7 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
protocol = uri.getScheme();
|
||||
port = uri.getPort();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
|
||||
URLProtectionSpace protectionSpace = new URLProtectionSpace(host, protocol, null, port, sslError.getCertificate(), sslError);
|
||||
|
@ -510,7 +510,7 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
URI uri = new URI(url);
|
||||
protocol = uri.getScheme();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
return webResourceResponse;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -650,7 +650,7 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
try {
|
||||
response = webView.channelDelegate.shouldInterceptRequest(request);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
try {
|
||||
customSchemeResponse = webView.channelDelegate.onLoadResourceWithCustomScheme(request);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
try {
|
||||
response = webView.contentBlockerHandler.checkUrl(webView, request, customSchemeResponse.getContentType());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
if (response != null)
|
||||
return response;
|
||||
|
@ -712,7 +712,7 @@ public class InAppWebViewClient extends WebViewClient {
|
|||
try {
|
||||
response = webView.contentBlockerHandler.checkUrl(webView, request);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
|
|
|
@ -372,7 +372,7 @@ public class InAppWebViewClientCompat extends WebViewClientCompat {
|
|||
protocol = uri.getScheme();
|
||||
port = uri.getPort();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ public class InAppWebViewClientCompat extends WebViewClientCompat {
|
|||
protocol = uri.getScheme();
|
||||
port = uri.getPort();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
|
||||
URLProtectionSpace protectionSpace = new URLProtectionSpace(host, protocol, null, port, sslError.getCertificate(), sslError);
|
||||
|
@ -522,7 +522,7 @@ public class InAppWebViewClientCompat extends WebViewClientCompat {
|
|||
URI uri = new URI(url);
|
||||
protocol = uri.getScheme();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -667,7 +667,7 @@ public class InAppWebViewClientCompat extends WebViewClientCompat {
|
|||
return webResourceResponse;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -677,7 +677,7 @@ public class InAppWebViewClientCompat extends WebViewClientCompat {
|
|||
try {
|
||||
response = webView.channelDelegate.shouldInterceptRequest(request);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ public class InAppWebViewClientCompat extends WebViewClientCompat {
|
|||
try {
|
||||
customSchemeResponse = webView.channelDelegate.onLoadResourceWithCustomScheme(request);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ public class InAppWebViewClientCompat extends WebViewClientCompat {
|
|||
try {
|
||||
response = webView.contentBlockerHandler.checkUrl(webView, request, customSchemeResponse.getContentType());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
if (response != null)
|
||||
return response;
|
||||
|
@ -739,7 +739,7 @@ public class InAppWebViewClientCompat extends WebViewClientCompat {
|
|||
try {
|
||||
response = webView.contentBlockerHandler.checkUrl(webView, request);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, "", e);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_inappwebview_android
|
||||
description: Android implementation of the flutter_inappwebview plugin.
|
||||
version: 1.0.3
|
||||
version: 1.0.4
|
||||
homepage: https://inappwebview.dev/
|
||||
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_android
|
||||
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues
|
||||
|
|
Loading…
Reference in New Issue