diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index 9b0c832d..61daff99 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -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 diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/MyCookieManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/MyCookieManager.java index 2b1e81e3..1a775018 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/MyCookieManager.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/MyCookieManager.java @@ -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); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/Util.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/Util.java index 99205884..c82ab02a 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/Util.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/Util.java @@ -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(); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/content_blocker/ContentBlockerHandler.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/content_blocker/ContentBlockerHandler.java index c6458edd..6badbc86 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/content_blocker/ContentBlockerHandler.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/content_blocker/ContentBlockerHandler.java @@ -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(); } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java index 94f997e5..6cb763c4 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java @@ -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); } } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/process_global_config/ProcessGlobalConfigManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/process_global_config/ProcessGlobalConfigManager.java index a69c6b1a..0b63e3f4 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/process_global_config/ProcessGlobalConfigManager.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/process_global_config/ProcessGlobalConfigManager.java @@ -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) 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(); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/service_worker/ServiceWorkerManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/service_worker/ServiceWorkerManager.java index 932e988a..4dde63e7 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/service_worker/ServiceWorkerManager.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/service_worker/ServiceWorkerManager.java @@ -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; } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/WebViewAssetLoaderExt.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/WebViewAssetLoaderExt.java index c15cfa5f..0a0c747e 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/WebViewAssetLoaderExt.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/WebViewAssetLoaderExt.java @@ -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; } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/JavaScriptBridgeInterface.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/JavaScriptBridgeInterface.java index a805b519..615a1f86 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/JavaScriptBridgeInterface.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/JavaScriptBridgeInterface.java @@ -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; } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/FlutterWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/FlutterWebView.java index b7666768..5605b68e 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/FlutterWebView.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/FlutterWebView.java @@ -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); } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java index dd56b1d8..ed11145c 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java @@ -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); } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewChromeClient.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewChromeClient.java index 6940eafd..de544f97 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewChromeClient.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewChromeClient.java @@ -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; } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java index ba2ba48c..c409efe5 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java @@ -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; diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java index 2c4e0201..5aecaa5b 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java @@ -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; diff --git a/flutter_inappwebview_android/pubspec.yaml b/flutter_inappwebview_android/pubspec.yaml index 95615e55..7782e829 100644 --- a/flutter_inappwebview_android/pubspec.yaml +++ b/flutter_inappwebview_android/pubspec.yaml @@ -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