File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
AnkiDroid/src/main/java/com/ichi2/utils Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package com.ichi2.utils
1919import android.content.Context
2020import android.content.pm.PackageInfo
2121import android.content.pm.PackageManager
22+ import android.util.AndroidRuntimeException
2223import android.webkit.WebView
2324import androidx.annotation.MainThread
2425import androidx.annotation.StringRes
@@ -56,6 +57,13 @@ fun checkWebviewVersion(activity: AnkiActivity) {
5657fun 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 }
You can’t perform that action at this time.
0 commit comments