diff --git a/CHANGELOG.md b/CHANGELOG.md index 6be4255303..5002b24eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 6.0.0 (2023-11-16) +## 6.0.0 (2023-11-20) ### Breaking Changes diff --git a/bugsnag-android-core/src/main/java/com/bugsnag/android/internal/ForegroundDetector.kt b/bugsnag-android-core/src/main/java/com/bugsnag/android/internal/ForegroundDetector.kt index 174952080a..4308c8ee9a 100644 --- a/bugsnag-android-core/src/main/java/com/bugsnag/android/internal/ForegroundDetector.kt +++ b/bugsnag-android-core/src/main/java/com/bugsnag/android/internal/ForegroundDetector.kt @@ -163,6 +163,7 @@ internal object ForegroundDetector : ActivityLifecycleCallbacks, Handler.Callbac mainThreadHandler.sendMessageDelayed(backgroundMessage, BACKGROUND_TIMEOUT_MS) } else { notifyListeners { it.onForegroundStatus(false, stoppedTimestamp) } + isInForeground = false lastExitedForegroundMs = stoppedTimestamp } } diff --git a/features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/InForegroundScenario.kt b/features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/InForegroundScenario.kt index bd2924974c..9b07dee917 100644 --- a/features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/InForegroundScenario.kt +++ b/features/fixtures/mazerunner/jvm-scenarios/src/main/java/com/bugsnag/android/mazerunner/scenarios/InForegroundScenario.kt @@ -20,14 +20,20 @@ internal class InForegroundScenario( ) : Scenario(config, context, eventMetadata) { private var triggered = AtomicBoolean(false) + private val mainHandler = Handler(Looper.getMainLooper()) override fun startScenario() { super.startScenario() registerActivityLifecycleCallbacks() + + // make sure the app goes to the background + mainHandler.post { + (context as Activity).finish() + } } override fun onActivityStopped(activity: Activity) { - Handler(Looper.getMainLooper()).post { + mainHandler.post { // debounce so this can only ever occur once if (!triggered.getAndSet(true)) { log("onActivityStopped is finished, calling Bugsnag.notify in the background") diff --git a/features/full_tests/in_foreground.feature b/features/full_tests/in_foreground.feature index 54071890d7..882483a4b3 100644 --- a/features/full_tests/in_foreground.feature +++ b/features/full_tests/in_foreground.feature @@ -3,11 +3,8 @@ Feature: In foreground field populates correctly Background: Given I clear all persistent data - # TODO: Skipped pending PLAT-10634 - @skip Scenario: Test handled exception in background When I run "InForegroundScenario" - And I send the app to the background for 5 seconds Then I wait to receive an error And the error is valid for the error reporting API version "4.0" for the "Android Bugsnag Notifier" notifier # PLAT-9155 Flaky: the event "app.inForeground" is false