You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/03/12 11:39:29 UTC
(cordova-android) branch pr-add-preference-AndroidMinimumWebViewVersion updated (d49d5c05 -> bc2d92e3)
This is an automated email from the ASF dual-hosted git repository.
manuelbeck pushed a change to branch pr-add-preference-AndroidMinimumWebViewVersion
in repository https://gitbox.apache.org/repos/asf/cordova-android.git
from d49d5c05 feat: add web view version check by preference `AndroidMinimumWebViewVersion`
new 2981046b feat: block futher loading, when web view is too old
new bc2d92e3 feat: improve web view detection on older android versions
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/org/apache/cordova/CordovaActivity.java | 49 ++++++++++++++++------
1 file changed, 37 insertions(+), 12 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
(cordova-android) 01/02: feat: block futher loading, when web view is too old
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
manuelbeck pushed a commit to branch pr-add-preference-AndroidMinimumWebViewVersion
in repository https://gitbox.apache.org/repos/asf/cordova-android.git
commit 2981046b5bd52914e72f92bf21af0d28ff1ee9a6
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Thu Mar 12 12:37:13 2026 +0100
feat: block futher loading, when web view is too old
- Generated-By: GPT-5.3-Codex, Visual Studio Code
---
framework/src/org/apache/cordova/CordovaActivity.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index 992e3821..c6898291 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -111,6 +111,11 @@ public class CordovaActivity extends AppCompatActivity {
private boolean canEdgeToEdge = false;
private boolean isFullScreen = false;
+ /**
+ * Flag set in {@link #checkWebViewVersion} indicating whether the WebView version
+ * is below the minimum required version specified in config.xml.
+ */
+ private boolean isWebViewVersionBlocked = false;
/**
* Called when the activity is first created.
@@ -172,6 +177,10 @@ public class CordovaActivity extends AppCompatActivity {
}
protected void init() {
+ if (isWebViewVersionBlocked) {
+ return;
+ }
+
appView = makeWebView();
createViews();
if (!appView.isInitialized()) {
@@ -286,6 +295,10 @@ public class CordovaActivity extends AppCompatActivity {
* Load the url into the WebView.
*/
public void loadUrl(String url) {
+ if (isWebViewVersionBlocked) {
+ return;
+ }
+
if (appView == null) {
init();
}
@@ -596,8 +609,9 @@ public class CordovaActivity extends AppCompatActivity {
}
/**
- * Check if the WebView version meets the minimum required version.
- * If not, display an error dialog and exit the app.
+ * Check if the WebView version meets the minimum required version specified by
+ * preference `AndroidMinimumWebViewVersion` in config.xml.
+ * If not, display an error dialog and block the app from loading further.
*/
private void checkWebViewVersion() {
String minimumWebViewVersion = preferences.getString("AndroidMinimumWebViewVersion", null);
@@ -608,6 +622,7 @@ public class CordovaActivity extends AppCompatActivity {
try {
String currentWebViewVersion = getWebViewVersion();
if (currentWebViewVersion != null && !isWebViewVersionSufficient(currentWebViewVersion, minimumWebViewVersion)) {
+ isWebViewVersionBlocked = true;
String title = getWebViewVersionTitle();
String message = getWebViewVersionMessage();
String button = getWebViewVersionButtonText();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
(cordova-android) 02/02: feat: improve web view detection on older android versions
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
manuelbeck pushed a commit to branch pr-add-preference-AndroidMinimumWebViewVersion
in repository https://gitbox.apache.org/repos/asf/cordova-android.git
commit bc2d92e3d8fde3590c3b7943a7f5b62666861714
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Thu Mar 12 12:38:22 2026 +0100
feat: improve web view detection on older android versions
- Generated-By: GPT-5.3-Codex, Visual Studio Code Copilot
---
.../src/org/apache/cordova/CordovaActivity.java | 30 ++++++++++++++--------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index c6898291..b9cd5e58 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -664,24 +664,34 @@ public class CordovaActivity extends AppCompatActivity {
private String getWebViewVersion() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
try {
- String webViewPackageName = WebViewCompat.getCurrentWebViewPackage(this).packageName;
- PackageManager pm = getPackageManager();
- PackageInfo pi = pm.getPackageInfo(webViewPackageName, 0);
- return pi.versionName;
+ PackageInfo webViewPackage = WebViewCompat.getCurrentWebViewPackage(this);
+ if (webViewPackage != null) {
+ return webViewPackage.versionName;
+ }
} catch (Exception e) {
LOG.d(TAG, "Could not get WebView version using WebViewCompat: " + e.getMessage());
}
}
// Fallback for older API levels
- try {
- PackageManager pm = getPackageManager();
- PackageInfo pi = pm.getPackageInfo("com.google.android.webview", 0);
- return pi.versionName;
- } catch (PackageManager.NameNotFoundException e) {
- LOG.d(TAG, "Could not find WebView package");
+ PackageManager pm = getPackageManager();
+ String[] fallbackPackages = new String[] {
+ "com.google.android.webview",
+ "com.android.webview",
+ "com.android.chrome"
+ };
+
+ for (String packageName : fallbackPackages) {
+ try {
+ PackageInfo pi = pm.getPackageInfo(packageName, 0);
+ return pi.versionName;
+ } catch (PackageManager.NameNotFoundException ignored) {
+ // Try next package
+ }
}
+ LOG.d(TAG, "Could not find WebView package");
+
return null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org