Report on a reused crash dialog sends the older crash
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 73/100
Research direction
Start with AnkiDroid/src/test/java/com/ichi2/anki/analytics/CrashReportDialogReuseTest.kt and the AnkiDroidCrashReportDialog handling of EXTRA_REPORT_FILE when onNewIntent reuses the dialog. Run the reuse test and check which crash file is approved after the second intent; done means the newest crash is reported and the earlier one remains pending.
Written by the indexing model from the issue text.
Description
Assisted-by: Claude Fable 5.2 max
[EXISTING] Report on a reused crash dialog sends the older crash
Subject: [EXISTING] Report on a reused crash dialog sends the older crash
When a second crash reuses a crash dialog left open, Report approves the first crash with the typed comment and leaves the second pending.
⚠️ This issue existed before the PR and should likely be split off into a separate issue.
---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/analytics/CrashReportDialogReuseTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/analytics/CrashReportDialogReuseTest.kt
new file mode 100644
index 0000000000..e33e12eb1e
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/analytics/CrashReportDialogReuseTest.kt
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package com.ichi2.anki.analytics
+
+import android.app.Application
+import android.content.DialogInterface
+import android.content.Intent
+import androidx.test.core.app.ApplicationProvider
+import com.ichi2.anki.acraCoreConfigBuilder
+import com.ichi2.anki.common.crashreporting.CrashReportService
+import com.ichi2.anki.initializeAcraCrashReporter
+import com.ichi2.testutils.EmptyApplication
+import io.mockk.every
+import io.mockk.mockk
+import io.mockk.mockkConstructor
+import io.mockk.mockkStatic
+import io.mockk.unmockkAll
+import org.acra.ACRA
+import org.acra.config.CoreConfigurationBuilder
+import org.acra.file.ReportLocator
+import org.acra.interaction.DialogInteraction
+import org.acra.scheduler.DefaultSenderScheduler
+import org.junit.After
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.Robolectric
+import org.robolectric.RobolectricTestRunner
+import org.robolectric.annotation.Config
+import java.io.File
+import java.util.concurrent.TimeUnit
+import kotlin.test.assertFalse
+
+@RunWith(RobolectricTestRunner::class)
+@Config(application = EmptyApplication::class)
+class CrashReportDialogReuseTest {
+ @After
+ fun tearDown() {
+ unmockkAll()
+ }
+
+ @Test
+ fun `Report on a reused dialog sends the newest crash`() {
+ val application = ApplicationProvider.getApplicationContext<Application>()
+ mockkStatic(ACRA::class)
+ every { ACRA.init(any<Application>(), any<CoreConfigurationBuilder>(), any()) } returns Unit
+ with(application) { initializeAcraCrashReporter() }
+ mockkConstructor(DefaultSenderScheduler::class)
+ every { anyConstructed<DefaultSenderScheduler>().scheduleReportSending(any()) } returns Unit
+ val pending = ReportLocator(application).unapprovedFolder
+ val earlier = File(pending, "earlier.stacktrace").apply { writeText("{}") }
+ val newest = File(pending, "newest.stacktrace").apply { writeText("{}") }
+
+ Robolectric.buildActivity(AnkiDroidCrashReportDialog::class.java, dialogIntent(application, earlier)).setup().use { controller ->
+ // The dialog is singleInstance: a second crash reuses the one left open.
+ controller.newIntent(dialogIntent(application, newest))
+ controller.get().onClick(mockk<DialogInterface>(relaxed = true), DialogInterface.BUTTON_POSITIVE)
+ val deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5)
+ while (newest.exists() && System.nanoTime() < deadline) Thread.sleep(10)
+
+ assertFalse(newest.exists(), "Report must approve the crash the dialog was last opened for")
+ }
+ }
+
+ private fun dialogIntent(
+ application: Application,
+ report: File,
+ ) = Intent(application, AnkiDroidCrashReportDialog::class.java)
+ .putExtra(DialogInteraction.EXTRA_REPORT_CONFIG, CrashReportService.acraCoreConfigBuilder.build())
+ .putExtra(DialogInteraction.EXTRA_REPORT_FILE, report)
+}
Found while reviewing https://github.com/ankidroid/Anki-Android/pull/23337
- Dominant language
- Kotlin
- Stars
- 12.3k
- Forks
- 3.1k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 320
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ankidroid/Anki-Android
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ankidroid/Anki-Android#23797 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23786 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ankidroid/Anki-Android#23756 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ankidroid/Anki-Android#23755 ·
Maintainers usually reply within 1 day
-
code-scan Needs Triage
Difficulty 2/5 Half a day Newbie friendliness 65/100
ankidroid/Anki-Android#23686 ·
Maintainers usually reply within 1 day
All issues in ankidroid/Anki-Android
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sorsama/deepseek-harness-mobile#154 ·
Maintainers usually reply within 1 day
-
0. Needs triage enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
[Feature] 3D and AR on phones (Filament, ARCore, SceneView): current APIs instead of 2022-era codeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 4 days
-
unshaved-yak
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
accessibility agent-ready area:android bug fleet
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
level-98/mailcrane#412 · 1 comment ·
Maintainers usually reply within 1 day