File tree Expand file tree Collapse file tree
sentry-android-replay/src
main/java/io/sentry/android/replay
test/java/io/sentry/android/replay
sentry/src/main/java/io/sentry Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,10 +167,10 @@ public class ReplayIntegration(
167167 }
168168
169169 override fun onAppForegrounded (startNewSession : Boolean ) {
170+ if (! isEnabled.get()) {
171+ return
172+ }
170173 enqueueOnMainThread {
171- if (! isEnabled.get()) {
172- return @enqueueOnMainThread
173- }
174174 if (startNewSession) {
175175 val isFullSession = sample(options.sessionReplay.sessionSampleRate)
176176 if (! isFullSession && ! options.sessionReplay.isSessionReplayForErrorsEnabled) {
@@ -187,6 +187,9 @@ public class ReplayIntegration(
187187 }
188188
189189 override fun onAppBackgrounded () {
190+ if (! isEnabled.get()) {
191+ return
192+ }
190193 enqueueOnMainThread { pauseInternal() }
191194 }
192195
Original file line number Diff line number Diff line change @@ -226,12 +226,14 @@ class ReplayIntegrationTest {
226226 }
227227
228228 @Test
229- fun `foreground before register does nothing` () {
230- val replay = fixture.getSut(context)
229+ fun `lifecycle callbacks before register are not enqueued` () {
230+ val mainLooperHandler = mock<MainLooperHandler >()
231+ val replay = fixture.getSut(context, mainLooperHandler = mainLooperHandler)
231232
232233 replay.onAppForegrounded(true )
234+ replay.onAppBackgrounded()
233235
234- assertThat(replay.isRecording).isFalse( )
236+ verify(mainLooperHandler, never()).post(any() )
235237 }
236238
237239 @Test
Original file line number Diff line number Diff line change @@ -11,17 +11,20 @@ public interface IReplayApi {
1111
1212 /**
1313 * Starts replay buffering. The rolling buffer is sent when {@link #flush()} is called or an error
14- * is captured. After the buffer is sent, recording continues in session mode unless the process
15- * is terminating.
14+ * is captured and selected by {@link SentryReplayOptions#getOnErrorSampleRate()}. After the
15+ * buffer is sent, recording continues in session mode unless the process is terminating.
1616 */
1717 void startBuffering ();
1818
19- /** Stops the current replay. A subsequent {@link #start()} begins a new replay session. */
19+ /**
20+ * Stops the current replay in either session or buffer mode. A subsequent {@link #start()} begins
21+ * a new replay session.
22+ */
2023 void stop ();
2124
2225 /**
23- * Pauses the current replay until {@link #resume()} is called. This can be used to avoid
24- * recording sensitive screens, such as PIN entry.
26+ * Pauses the current replay in either session or buffer mode until {@link #resume()} is called.
27+ * This can be used to avoid recording sensitive screens, such as PIN entry.
2528 */
2629 void pause ();
2730
You can’t perform that action at this time.
0 commit comments