Loading packages/SystemUI/src/com/android/systemui/media/SeekBarViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -91,9 +91,9 @@ class SeekBarViewModel @Inject constructor(@Background private val bgExecutor: R } private var playbackState: PlaybackState? = null private var callback = object : MediaController.Callback() { override fun onPlaybackStateChanged(state: PlaybackState) { override fun onPlaybackStateChanged(state: PlaybackState?) { playbackState = state if (PlaybackState.STATE_NONE.equals(playbackState)) { if (playbackState == null || PlaybackState.STATE_NONE.equals(playbackState)) { clearController() } else { checkIfPollingNeeded() Loading packages/SystemUI/tests/src/com/android/systemui/media/SeekBarViewModelTest.kt +17 −0 Original line number Diff line number Diff line Loading @@ -654,4 +654,21 @@ public class SeekBarViewModelTest : SysuiTestCase() { fakeExecutor.runAllReady() verify(mockController).unregisterCallback(any()) } @Test fun nullPlaybackStateUnregistersCallback() { viewModel.updateController(mockController) val captor = ArgumentCaptor.forClass(MediaController.Callback::class.java) verify(mockController).registerCallback(captor.capture()) val callback = captor.value // WHEN the callback receives a null state callback.onPlaybackStateChanged(null) with(fakeExecutor) { advanceClockToNext() runAllReady() } // THEN we unregister callback (as a result of clearing the controller) fakeExecutor.runAllReady() verify(mockController).unregisterCallback(any()) } } Loading
packages/SystemUI/src/com/android/systemui/media/SeekBarViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -91,9 +91,9 @@ class SeekBarViewModel @Inject constructor(@Background private val bgExecutor: R } private var playbackState: PlaybackState? = null private var callback = object : MediaController.Callback() { override fun onPlaybackStateChanged(state: PlaybackState) { override fun onPlaybackStateChanged(state: PlaybackState?) { playbackState = state if (PlaybackState.STATE_NONE.equals(playbackState)) { if (playbackState == null || PlaybackState.STATE_NONE.equals(playbackState)) { clearController() } else { checkIfPollingNeeded() Loading
packages/SystemUI/tests/src/com/android/systemui/media/SeekBarViewModelTest.kt +17 −0 Original line number Diff line number Diff line Loading @@ -654,4 +654,21 @@ public class SeekBarViewModelTest : SysuiTestCase() { fakeExecutor.runAllReady() verify(mockController).unregisterCallback(any()) } @Test fun nullPlaybackStateUnregistersCallback() { viewModel.updateController(mockController) val captor = ArgumentCaptor.forClass(MediaController.Callback::class.java) verify(mockController).registerCallback(captor.capture()) val callback = captor.value // WHEN the callback receives a null state callback.onPlaybackStateChanged(null) with(fakeExecutor) { advanceClockToNext() runAllReady() } // THEN we unregister callback (as a result of clearing the controller) fakeExecutor.runAllReady() verify(mockController).unregisterCallback(any()) } }