Skip to content

Commit b6444a5

Browse files
david-allisonmikehardy
authored andcommitted
chore: stop logging 'MissingWebViewPackageException' to ACRA
Introduced in 175d961 Tested with `adb shell pm uninstall --user 0 com.google.android.webview` Fixes 18691
1 parent ecfe4b1 commit b6444a5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

AnkiDroid/src/main/java/com/ichi2/utils/WebViewUtils.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.ichi2.utils
1919
import android.content.Context
2020
import android.content.pm.PackageInfo
2121
import android.content.pm.PackageManager
22+
import android.util.AndroidRuntimeException
2223
import android.webkit.WebView
2324
import androidx.annotation.MainThread
2425
import androidx.annotation.StringRes
@@ -56,6 +57,13 @@ fun checkWebviewVersion(activity: AnkiActivity) {
5657
fun getWebviewUserAgent(context: Context): String? {
5758
try {
5859
return WebView(context).settings.userAgentString
60+
} catch (e: AndroidRuntimeException) {
61+
// MissingWebViewPackageException is not public
62+
if (e.cause.toString().contains("MissingWebViewPackageException")) {
63+
Timber.w(e, "MissingWebViewPackageException")
64+
return null // WebView not installed - don't log a crash report
65+
}
66+
CrashReportService.sendExceptionReport(e, "WebViewUtils", "some issue occurred while extracting webview user agent")
5967
} catch (e: Throwable) {
6068
CrashReportService.sendExceptionReport(e, "WebViewUtils", "some issue occurred while extracting webview user agent")
6169
}

0 commit comments

Comments
 (0)