tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 17b749e93fcf9ab5f85033d6ad3876c34dc9a8b7
parent 0b924e8dc732131e6068b76d0beba7e3f676b127
Author: fmasalha <fmasalha@mozilla.com>
Date:   Thu, 16 Oct 2025 17:08:52 +0000

Bug 1992494 - Moved Android `StartupCrashActivity` out-of-process r=android-reviewers,matt-tighe

Differential Revision: https://phabricator.services.mozilla.com/D268030

Diffstat:
Mmobile/android/fenix/app/src/main/AndroidManifest.xml | 1+
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt | 55+++++++------------------------------------------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt | 27+--------------------------
Dmobile/android/fenix/app/src/main/java/org/mozilla/fenix/crashes/StartupCrashCanary.kt | 77-----------------------------------------------------------------------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/debugsettings/crashtools/CrashTools.kt | 23+++++++++++------------
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/startupCrash/StartupCrashActivity.kt | 3---
Mmobile/android/fenix/app/src/main/java/org/mozilla/fenix/startupCrash/StartupCrashMiddleware.kt | 4----
Mmobile/android/fenix/app/src/main/res/values/static_strings.xml | 8++++----
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt | 40----------------------------------------
Dmobile/android/fenix/app/src/test/java/org/mozilla/fenix/crashes/FileBasedCrashCanaryTest.kt | 78------------------------------------------------------------------------------
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/helpers/FenixRobolectricTestApplication.kt | 5-----
Mmobile/android/fenix/app/src/test/java/org/mozilla/fenix/startupCrashStore/StartupCrashMiddlewareTest.kt | 6------
12 files changed, 24 insertions(+), 303 deletions(-)

diff --git a/mobile/android/fenix/app/src/main/AndroidManifest.xml b/mobile/android/fenix/app/src/main/AndroidManifest.xml @@ -491,6 +491,7 @@ <activity android:name=".startupCrash.StartupCrashActivity" android:exported="false" + android:process=":StartupCrashActivityProcess" > </activity> diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -7,6 +7,7 @@ package org.mozilla.fenix import android.annotation.SuppressLint import android.app.ActivityManager import android.content.Context +import android.content.Intent import android.os.Build import android.os.Build.VERSION.SDK_INT import android.os.StrictMode @@ -87,7 +88,6 @@ import org.mozilla.fenix.components.appstate.AppAction import org.mozilla.fenix.components.initializeGlean import org.mozilla.fenix.components.metrics.MozillaProductDetector import org.mozilla.fenix.components.startMetricsIfEnabled -import org.mozilla.fenix.crashes.StartupCrashCanary import org.mozilla.fenix.experiments.maybeFetchExperiments import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.containsQueryParameters @@ -111,6 +111,7 @@ import org.mozilla.fenix.push.WebPushEngineIntegration import org.mozilla.fenix.session.VisibilityLifecycleCallback import org.mozilla.fenix.settings.doh.DefaultDohSettingsProvider import org.mozilla.fenix.settings.doh.DohSettingsProvider +import org.mozilla.fenix.startupCrash.StartupCrashActivity import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.isLargeScreenSize import org.mozilla.fenix.wallpapers.Wallpaper @@ -143,39 +144,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider { var visibilityLifecycleCallback: VisibilityLifecycleCallback? = null private set - /* - * We need to avoid initializing any components while recovering from a startup crash, - * so we use this flag in any Android override hook to ensure that we exit early if we - * are actively recovering. Transitioning between the recovery flow and the normal flow - * does so by killing the active process, so this state should get reset as the startup - * flow completes. See the README in the startup crash package for more context. - */ - private enum class StartupCrashRecoveryState { - NotNeeded, - Recovering, - } - - private var recoveryState = StartupCrashRecoveryState.NotNeeded - override fun onCreate() { super.onCreate() - checkForStartupCrash() - } - - /** - * Initializes Fenix, unless a startup crash was detected on the previous launch, - * in which case returns early to allow for the [HomeActivity] to enter the startup crash - * flow. See [HomeActivity.onCreate] or the README in the startup crash package for more context. - */ - open fun checkForStartupCrash( - canary: StartupCrashCanary = StartupCrashCanary.build(applicationContext), - initialize: () -> Unit = ::initialize, - ) { - if (canary.startupCrashDetected) { - recoveryState = StartupCrashRecoveryState.Recovering - return - } - initialize() } @@ -188,7 +158,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider { setupInAllProcesses() - if (!isMainProcess() || recoveryState == StartupCrashRecoveryState.Recovering) { + if (!isMainProcess()) { // If this is not the main process then do not continue with the initialization here. Everything that // follows only needs to be done in our app's main process and should not be done in other processes like // a GeckoView child process or the crash handling process. Most importantly we never want to end up in a @@ -541,9 +511,10 @@ open class FenixApplication : LocaleAwareApplication(), Provider { private fun handleCaughtException() { if (isMainProcess() && !components.performance.visualCompletenessQueue.isReady()) { - CoroutineScope(IO).launch { - StartupCrashCanary.build(applicationContext).createCanary() - } + val intent = Intent(applicationContext, StartupCrashActivity::class.java) + + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + applicationContext.startActivity(intent) } } @@ -597,12 +568,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider { override fun onTrimMemory(level: Int) { super.onTrimMemory(level) - // Guard against platform hooks initializing components while we are recovering - // from a startup crash. See the README in the startup crash package for more context. - if (recoveryState == StartupCrashRecoveryState.Recovering) { - return - } - // Additional logging and breadcrumb to debug memory issues: // https://github.com/mozilla-mobile/fenix/issues/12731 @@ -1065,12 +1030,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider { } override fun onConfigurationChanged(config: android.content.res.Configuration) { - // Guard against platform hooks initializing components while we are recovering - // from a startup crash. See the README in the startup crash package for more context. - if (recoveryState == StartupCrashRecoveryState.Recovering) { - return - } - // Workaround for androidx appcompat issue where follow system day/night mode config changes // are not triggered when also using createConfigurationContext like we do in LocaleManager // https://issuetracker.google.com/issues/143570309#comment3 diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -9,13 +9,11 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.Intent.ACTION_MAIN -import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT import android.content.pm.PackageManager import android.content.res.Configuration import android.os.Build import android.os.Bundle -import android.os.Process import android.os.StrictMode import android.text.format.DateUtils import android.util.AttributeSet @@ -105,7 +103,6 @@ import org.mozilla.fenix.components.metrics.GrowthDataWorker import org.mozilla.fenix.components.metrics.MarketingAttributionService import org.mozilla.fenix.components.metrics.fonts.FontEnumerationWorker import org.mozilla.fenix.crashes.CrashReporterBinding -import org.mozilla.fenix.crashes.StartupCrashCanary import org.mozilla.fenix.crashes.UnsubmittedCrashDialog import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity import org.mozilla.fenix.databinding.ActivityHomeBinding @@ -162,7 +159,6 @@ import org.mozilla.fenix.splashscreen.DefaultExperimentsOperationStorage import org.mozilla.fenix.splashscreen.DefaultSplashScreenStorage import org.mozilla.fenix.splashscreen.FetchExperimentsOperation import org.mozilla.fenix.splashscreen.SplashScreenManager -import org.mozilla.fenix.startupCrash.StartupCrashActivity import org.mozilla.fenix.tabhistory.TabHistoryDialogFragment import org.mozilla.fenix.tabstray.TabsTrayFragment import org.mozilla.fenix.theme.DefaultThemeManager @@ -350,29 +346,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { } } - final override fun onCreate(savedInstanceState: Bundle?) { - if (StartupCrashCanary.build(applicationContext).startupCrashDetected) { - super.onCreate(savedInstanceState) - val startupCrashIntent = - Intent( - applicationContext, - StartupCrashActivity::class.java, - ) - startupCrashIntent.flags = FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS - startActivity(startupCrashIntent) - // We kill the process, because `finish` will cause `onDestroy` to run which would end up - // causing several components to be initialized and potentially cause the startup crash. - Process.killProcess(Process.myPid()) - } else { - initialize(savedInstanceState) - } - } - - /** - * Initializes [HomeActivity] and all required subsystems. - */ @Suppress("ComplexMethod") - fun initialize(savedInstanceState: Bundle?) { + final override fun onCreate(savedInstanceState: Bundle?) { // DO NOT MOVE ANYTHING ABOVE THIS getProfilerTime CALL. val startTimeProfiler = components.core.engine.profiler?.getProfilerTime() diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/crashes/StartupCrashCanary.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/crashes/StartupCrashCanary.kt @@ -1,77 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.fenix.crashes - -import android.content.Context -import androidx.annotation.VisibleForTesting -import org.mozilla.fenix.Config -import java.io.File - -/** - * Detects if the app experienced a startup crash by using a canary. - */ -interface StartupCrashCanary { - - /** - * True if a startup crash was detected. - */ - val startupCrashDetected: Boolean - - /** - * Creates a canary to detect potential crashes. - */ - suspend fun createCanary() - - /** - * Removes the canary after successful startup. - */ - suspend fun clearCanary() - - /** - * Factory for [StartupCrashCanary]. - */ - companion object { - private var instance: StartupCrashCanary? = null - - /** - * Builds a [StartupCrashCanary] or returns the singleton if it exists. - */ - fun build(context: Context): StartupCrashCanary = instance - ?: FileBasedCrashCanary( - canaryFile = File(context.filesDir, ".canary").startupCanary(), - ).also { instance = it } - } -} - -internal fun File.startupCanary() = - CanaryFile( - exists = { this.exists() }, - touch = { this.createNewFile() }, - remove = { this.delete() }, - ) - -internal data class CanaryFile(val exists: () -> Boolean, val touch: () -> Unit, val remove: () -> Unit) - -@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) -internal class FileBasedCrashCanary( - val canaryFile: CanaryFile, - val useNewCrashReporter: Boolean = Config.channel.isNightlyOrDebug, -) : StartupCrashCanary { - - override var startupCrashDetected = useNewCrashReporter && canaryFile.exists() - private set - - override suspend fun createCanary() { - if (useNewCrashReporter) { - canaryFile.touch() - startupCrashDetected = true - } - } - - override suspend fun clearCanary() { - canaryFile.remove() - startupCrashDetected = false - } -} diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/debugsettings/crashtools/CrashTools.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/debugsettings/crashtools/CrashTools.kt @@ -4,6 +4,8 @@ package org.mozilla.fenix.debugsettings.crashtools +import android.content.Intent +import android.os.Process import android.text.format.DateUtils import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth @@ -21,15 +23,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay -import kotlinx.coroutines.launch import mozilla.components.compose.base.annotation.FlexibleWindowLightDarkPreview import mozilla.components.compose.base.button.FilledButton import org.mozilla.fenix.R import org.mozilla.fenix.components.components -import org.mozilla.fenix.crashes.StartupCrashCanary +import org.mozilla.fenix.startupCrash.StartupCrashActivity import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.utils.Settings @@ -38,9 +37,9 @@ private const val SECOND_IN_MILLISECOND = 1000L @Composable internal fun CrashTools( settings: Settings = components.settings, - canary: StartupCrashCanary = - StartupCrashCanary.build(LocalContext.current.applicationContext), ) { + val appContext = LocalContext.current.applicationContext + var now = System.currentTimeMillis() var genericDeferPeriod by remember { mutableLongStateOf(settings.crashReportDeferredUntil - now) } LaunchedEffect(Unit) { @@ -88,14 +87,14 @@ internal fun CrashTools( style = FirefoxTheme.typography.subtitle2, ) FilledButton( - text = stringResource(R.string.crash_debug_crash_on_next_startup), + text = stringResource(R.string.crash_debug_show_startup_crash_screen), modifier = Modifier.fillMaxWidth(), onClick = { - CoroutineScope(Dispatchers.IO).launch { - canary.createCanary() - }.invokeOnCompletion { - throw ArithmeticException("Debug drawer triggered exception.") - } + val intent = Intent(appContext, StartupCrashActivity::class.java) + + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + appContext.startActivity(intent) + Process.killProcess(Process.myPid()) }, ) } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/startupCrash/StartupCrashActivity.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/startupCrash/StartupCrashActivity.kt @@ -14,7 +14,6 @@ import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import mozilla.components.lib.crash.CrashReporter import org.mozilla.fenix.R -import org.mozilla.fenix.crashes.StartupCrashCanary import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings import org.mozilla.fenix.theme.FirefoxTheme @@ -39,8 +38,6 @@ class StartupCrashActivity : AppCompatActivity() { settings = LocalContext.current.settings(), crashReporter = installCrashReporter(), restartHandler = ::restartFenix, - startupCrashCanaryCache = - StartupCrashCanary.build(applicationContext), ), ), ), diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/startupCrash/StartupCrashMiddleware.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/startupCrash/StartupCrashMiddleware.kt @@ -16,7 +16,6 @@ import mozilla.components.lib.state.Middleware import mozilla.components.lib.state.MiddlewareContext import mozilla.components.lib.state.Store import org.mozilla.fenix.crashes.SettingsCrashReportCache -import org.mozilla.fenix.crashes.StartupCrashCanary import org.mozilla.fenix.utils.Settings private const val FIVE_DAYS_IN_MILLIS = DateUtils.DAY_IN_MILLIS * 5 @@ -25,7 +24,6 @@ internal class StartupCrashMiddleware( settings: Settings, private val crashReporter: CrashReporter, private val restartHandler: () -> Unit, - private val startupCrashCanaryCache: StartupCrashCanary, private val currentTimeInMillis: () -> TimeInMillis = { System.currentTimeMillis() }, private val cache: CrashReportCache = SettingsCrashReportCache(settings), private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO), @@ -42,14 +40,12 @@ internal class StartupCrashMiddleware( ReportTapped -> { scope.launch { sendUnsentCrashReports(context.store) - startupCrashCanaryCache.clearCanary() } } ReopenTapped -> restartHandler() NoTapped -> { scope.launch { cache.setDeferredUntil(currentTimeInMillis() + FIVE_DAYS_IN_MILLIS) - startupCrashCanaryCache.clearCanary() } } CrashReportCompleted, diff --git a/mobile/android/fenix/app/src/main/res/values/static_strings.xml b/mobile/android/fenix/app/src/main/res/values/static_strings.xml @@ -255,10 +255,10 @@ <string name="crash_debug_deferral_button">Reset deferral settings</string> <!-- Subtitle warning text for crash button --> <string name="crash_debug_crash_app_warning">This will crash the app to start crash reporting flow. Please also ensure that the crash report option is set to "Ask before sending" in the data collections settings if you want the dialog to pop up.</string> - <!-- Subtitle warning text for crash button --> - <string name="crash_debug_startup_crash_warning">This will set the flag that a startup crash was detected and crash the app to enter the startup crash flow on next startup.</string> - <!-- Button text to set app to crash during next startup --> - <string name="crash_debug_crash_on_next_startup">Set startup crash flag and crash app</string> <!-- Timer text for deferral period %s is the timer string --> <string name="crash_debug_deferral_timer">Current deferral period: %s</string> + <!-- Button text to show startup crash screen --> + <string name="crash_debug_show_startup_crash_screen">Show startup crash screen</string> + <!-- Subtitle warning text for crash button --> + <string name="crash_debug_startup_crash_warning">This will start the startup crash activity in a new process and terminate the current process.</string> </resources> diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt @@ -37,7 +37,6 @@ import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine import org.mozilla.fenix.GleanMetrics.TopSites import org.mozilla.fenix.components.metrics.MozillaProductDetector import org.mozilla.fenix.components.toolbar.ToolbarPosition -import org.mozilla.fenix.crashes.StartupCrashCanary import org.mozilla.fenix.distributions.DefaultDistributionBrowserStoreProvider import org.mozilla.fenix.distributions.DistributionIdManager import org.mozilla.fenix.distributions.DistributionProviderChecker @@ -92,45 +91,6 @@ class FenixApplicationTest { } @Test - fun `GIVEN a startup crash canary THEN initialize is never called`() { - var called = false - val initialize = { called = true } - - val canary = object : StartupCrashCanary { - override val startupCrashDetected: Boolean - get() = true - - override suspend fun clearCanary() { TODO("Not yet implemented") } - - override suspend fun createCanary() { TODO("Not yet implemented") } - } - - val application = FenixApplication() - application.checkForStartupCrash(canary, initialize) - - assertFalse(called) - } - - @Test - fun `GIVEN no startup crash canary THEN initialize is called`() { - var called = false - val initialize = { called = true } - val canary = object : StartupCrashCanary { - override val startupCrashDetected: Boolean - get() = false - - override suspend fun clearCanary() { TODO("Not yet implemented") } - - override suspend fun createCanary() { TODO("Not yet implemented") } - } - - val application = FenixApplication() - application.checkForStartupCrash(canary, initialize) - - assertTrue(called) - } - - @Test fun `GIVEN there are unsupported addons installed WHEN subscribing for new add-ons checks THEN register for checks`() { val checker = mockk<DefaultSupportedAddonsChecker>(relaxed = true) val unSupportedExtension: WebExtension = mockk() diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/crashes/FileBasedCrashCanaryTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/crashes/FileBasedCrashCanaryTest.kt @@ -1,78 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package org.mozilla.fenix.crashes - -import kotlinx.coroutines.test.runTest -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test - -private class FakeCanary( - var existsState: Boolean = false, - var touched: Boolean = false, - var removed: Boolean = false, -) { - fun asCanaryFile() = CanaryFile( - exists = { existsState }, - touch = { - touched = true - existsState = true - }, - remove = { - removed = true - existsState = false - }, - ) -} - -class FileBasedCrashCanaryTest { - - @Test - fun `GIVEN canary exists WHEN initializing THEN startupCrashDetected is true only when flag enabled`() { - val fake = FakeCanary(existsState = true) - val enabled = FileBasedCrashCanary(fake.asCanaryFile(), useNewCrashReporter = true) - assertTrue(enabled.startupCrashDetected) - - val disabled = FileBasedCrashCanary(fake.asCanaryFile(), useNewCrashReporter = false) - assertFalse(disabled.startupCrashDetected) - } - - @Test - fun `GIVEN useNewCrashReporter is true AND canary does not exist WHEN createCanary THEN canary is touched AND detection is true`() = runTest { - val fake = FakeCanary(existsState = false) - val canary = FileBasedCrashCanary(fake.asCanaryFile(), useNewCrashReporter = true) - - canary.createCanary() - - assertEquals(true, fake.touched) - assertTrue(fake.existsState) - assertTrue(canary.startupCrashDetected) - } - - @Test - fun `GIVEN useNewCrashReporter is false AND canary does not exist WHEN createCanary THEN canary is not touched AND detection remains false`() = runTest { - val fake = FakeCanary(existsState = false) - val canary = FileBasedCrashCanary(fake.asCanaryFile(), useNewCrashReporter = false) - - canary.createCanary() - - assertEquals(false, fake.touched) - assertFalse(fake.existsState) - assertFalse(canary.startupCrashDetected) - } - - @Test - fun `GIVEN canary exists WHEN clearCanary THEN canary is removed AND detection is false`() = runTest { - val fake = FakeCanary(existsState = true) - val canary = FileBasedCrashCanary(fake.asCanaryFile(), useNewCrashReporter = true) - assertTrue(canary.startupCrashDetected) - - canary.clearCanary() - assertEquals(true, fake.removed) - assertFalse(fake.existsState) - assertFalse(canary.startupCrashDetected) - } -} diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/helpers/FenixRobolectricTestApplication.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/helpers/FenixRobolectricTestApplication.kt @@ -8,9 +8,6 @@ import io.mockk.mockk import org.mozilla.fenix.FenixApplication import org.mozilla.fenix.R import org.mozilla.fenix.components.Components -import org.mozilla.fenix.crashes.StartupCrashCanary -import org.mozilla.fenix.ext.settings -import org.mozilla.fenix.perf.runBlockingIncrement /** * An override of our application for use in Robolectric-based unit tests. We're forced to override @@ -26,8 +23,6 @@ class FenixRobolectricTestApplication : FenixApplication() { override val components = mockk<Components>() - override fun checkForStartupCrash(canary: StartupCrashCanary, initialize: () -> Unit) = Unit - override fun initializeNimbus() = Unit override fun initializeGlean() = Unit diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/startupCrashStore/StartupCrashMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/startupCrashStore/StartupCrashMiddlewareTest.kt @@ -19,7 +19,6 @@ import org.mockito.ArgumentMatchers.anyLong import org.mockito.Mockito.mock import org.mockito.Mockito.verify import org.mockito.Mockito.`when` -import org.mozilla.fenix.crashes.StartupCrashCanary import org.mozilla.fenix.startupCrash.NoTapped import org.mozilla.fenix.startupCrash.ReopenTapped import org.mozilla.fenix.startupCrash.ReportTapped @@ -37,13 +36,11 @@ class StartupCrashMiddlewareTest { private lateinit var settings: Settings private lateinit var crashReporter: CrashReporter - private lateinit var canaryRepo: StartupCrashCanary @Before fun setup() { settings = mock() crashReporter = mock() - canaryRepo = mock() } @Test @@ -71,7 +68,6 @@ class StartupCrashMiddlewareTest { verify(crashReporter).submitReport(crashCaptor.capture(), any()) assertEquals(crash, crashCaptor.value) - verify(canaryRepo).clearCanary() assertEquals(UiState.Finished, store.state.uiState) } @@ -84,7 +80,6 @@ class StartupCrashMiddlewareTest { store.dispatch(NoTapped) advanceUntilIdle() - verify(canaryRepo).clearCanary() verify(settings).crashReportDeferredUntil = currentTime + FIVE_DAYS_IN_MILLIS assertEquals(UiState.Finished, store.state.uiState) } @@ -113,7 +108,6 @@ class StartupCrashMiddlewareTest { settings = settings, crashReporter = crashReporter, restartHandler = { called = true }, - startupCrashCanaryCache = canaryRepo, currentTimeInMillis = currentTime, scope = scope, )