Skip to content

Conversation

@Fandroid745
Copy link
Contributor

@Fandroid745 Fandroid745 commented Jan 5, 2026

Purpose / Description

This pr adds the webview provider and versioncode in the debug info which is necessary to solve #19914

Fixes

Approach

Updated the DebugInfoService::getDebugInfo to retreive the webview information

How Has This Been Tested?

Ran the app on my phone(redmi note 10 pro) and verified that the debug info includes the webview provider and version code.

AnkiDroid Version = 2.24.0alpha1-debug (84fa732f6563713a34cecaa2d5fd0d78f97546fa)  
Backend Version = 0.1.63-anki25.09.2 (25.09.2 3890e12c9e48c028c3f12aa58cb64bd9f8895e30)  
Android Version = 15 (SDK 35)  
ProductFlavor = play  
Device Info = Xiaomi | Xiaomi | sweetin | aosp_sweet | M2101K6P | qcom  
Webview User Agent = Mozilla/5.0 (Linux; Android 15; M2101K6P Build/BP1A.250505.005; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/143.0.7499.34 Mobile Safari/537.36 (com.google.android.webview (749903433))  
ACRA UUID = eceb0e0b-f556-459e-8c3f-9ce9e04cd33a  
FSRS = 5.1.0 (Enabled: false)  
Crash Reports Enabled = false

Learning (optional, can help others)

None

Links to blog posts, patterns, libraries or addons used to solve this problem

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch 2 times, most recently from 50b9231 to a7c29af Compare January 5, 2026 12:51
@Fandroid745 Fandroid745 changed the title Feat/debug info webview feat:Add webview provider name and versioncode in the debug info Jan 5, 2026
@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch from a7c29af to 84fa732 Compare January 5, 2026 13:08
@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch 2 times, most recently from bd24f34 to 15f0c75 Compare January 5, 2026 14:40
@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Jan 5, 2026
@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch from 15f0c75 to b65bc1c Compare January 5, 2026 21:43
binding.setDueDatePager,
) { tab: TabLayout.Tab, position: Int ->
SetDueDateViewModel.Tab.entries
Tab.entries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad

@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch from b65bc1c to 91e1580 Compare January 6, 2026 10:08
@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch from 91e1580 to edb5ee1 Compare January 6, 2026 17:06
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of unrelated changes

How about this: move the responsibility of formatting to the debug info

and just returning null should be OK

Subject: [PATCH] 
---
Index: AnkiDroid/src/main/java/com/ichi2/utils/WebViewUtils.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/java/com/ichi2/utils/WebViewUtils.kt b/AnkiDroid/src/main/java/com/ichi2/utils/WebViewUtils.kt
--- a/AnkiDroid/src/main/java/com/ichi2/utils/WebViewUtils.kt	(revision edb5ee19955e1e3706a1e315bbcbb91824f84938)
+++ b/AnkiDroid/src/main/java/com/ichi2/utils/WebViewUtils.kt	(date 1767738660183)
@@ -149,20 +149,21 @@
 
 data class WebViewInfo(
     val userAgent: String?,
-    val provider: String,
+    val packageName: String?,
+    val versionCode: Long?,
 )
 
 suspend fun getWebViewInfo(context: Context): WebViewInfo =
     withContext(Dispatchers.Main) {
-        val userAgentValue = getWebviewUserAgent(context)
-        val pkg = runCatching { WebViewCompat.getCurrentWebViewPackage(context) }.getOrNull()
-        val providerName = pkg?.packageName ?: "Unknown"
+        val packageInfo = runCatching { WebViewCompat.getCurrentWebViewPackage(context) }.getOrNull()
 
-        val version =
-            runCatching {
-                pkg?.let { PackageInfoCompat.getLongVersionCode(it) }
-            }.getOrNull() ?: "Unknown"
-        WebViewInfo(userAgentValue, "$providerName ($version)")
+        WebViewInfo(
+            userAgent = getWebviewUserAgent(context),
+            packageName = packageInfo?.packageName,
+            versionCode = runCatching {
+                packageInfo?.let { PackageInfoCompat.getLongVersionCode(it) }
+            }.getOrNull()
+        )
     }
 
 private fun showOutdatedWebViewDialog(
Index: AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt
--- a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt	(revision edb5ee19955e1e3706a1e315bbcbb91824f84938)
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt	(date 1767738606060)
@@ -43,7 +43,7 @@
             Android Version = ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT})
             ProductFlavor = ${BuildConfig.FLAVOR}
             Device Info = ${Build.MANUFACTURER} | ${Build.BRAND} | ${Build.DEVICE} | ${Build.PRODUCT} | ${Build.MODEL} | ${Build.HARDWARE}
-            Webview User Agent = ${webviewInfo.userAgent} (${webviewInfo.provider})
+            WebView Info = [${webviewInfo.packageName} | ${webviewInfo.versionCode}]: ${webviewInfo.userAgent}
             ACRA UUID = ${Installation.id(info)}
             FSRS = ${BackendBuildConfig.FSRS_VERSION} (Enabled: $isFSRSEnabled)
             Crash Reports Enabled = ${isSendingCrashReports(info)}

<option name="BLANK_LINES_AROUND_INITIALIZER" value="2" />
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="false" module="true" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch from edb5ee1 to 5a706c4 Compare January 7, 2026 13:29
@david-allison
Copy link
Member

please check the diff before pinging me, this isn't reviewable yet

@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch from 5a706c4 to 91f767a Compare January 7, 2026 15:30
@Fandroid745
Copy link
Contributor Author

I have fixed the diff now

private fun isSendingCrashReports(context: Context): Boolean = CrashReportService.isAcraEnabled(context, false)
}

private fun isSendingCrashReports(context: Context): Boolean = CrashReportService.isAcraEnabled(context, false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't have been moved, please revert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One required change, but it should be mechanical. Tentatively approving. Thanks!!

@david-allison david-allison added the Needs Second Approval Has one approval, one more approval to merge label Jan 7, 2026
@Fandroid745 Fandroid745 force-pushed the feat/debug-info-webview branch from 91f767a to 11af848 Compare January 7, 2026 20:06
@david-allison david-allison removed the Needs Author Reply Waiting for a reply from the original author label Jan 8, 2026
@Fandroid745
Copy link
Contributor Author

Pinging for second review

@mikehardy
Copy link
Member

@Fandroid745 please do not ping

If it is labeled for "Needs Second Review" it shows up in reviewers queues

Reviewer time (which could be used for reviews) is taken up processing notifications that come from pings, so they are negative progress by absorbing otherwise useful time

@BrayanDSO BrayanDSO added this pull request to the merge queue Jan 15, 2026
@BrayanDSO BrayanDSO added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Jan 15, 2026
Merged via the queue into ankidroid:main with commit ab4ec14 Jan 15, 2026
15 checks passed
@github-actions github-actions bot added this to the 2.24 release milestone Jan 15, 2026
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Jan 15, 2026
@Fandroid745 Fandroid745 deleted the feat/debug-info-webview branch January 16, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants