Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59d537b9 authored by Michael Mikhail's avatar Michael Mikhail
Browse files

Fix media removal issue when media is updated

ag/27975075 added a new field (updateTime) to MediaCommonViewModel. This field change when we get updates of media controls from the pipeline. Therefore, comparing view-models data classes can return false even if view-models are of the same instanceId.

This CL only compares ID field of MediaCommonViewModels, not all fields.

Flag: com.android.systemui.scene_container
Bug: 326408371
Test: atest MediaCarouselControllerTest
Change-Id: Ie0413d0a8470ed7ac1cf0625e3dcaa82b2f014d0
parent 4395f03a
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -849,8 +849,25 @@ constructor(
        commonViewModels.addAll(viewModels)

        // Ensure we only show the needed UMOs in media carousel.
        val viewSet = viewModels.toHashSet()
        controllerByViewModel.filter { !viewSet.contains(it.key) }.forEach { onRemoved(it.key) }
        val viewIds =
            viewModels
                .map { mediaCommonViewModel ->
                    when (mediaCommonViewModel) {
                        is MediaCommonViewModel.MediaControl ->
                            mediaCommonViewModel.instanceId.toString()
                        is MediaCommonViewModel.MediaRecommendations -> mediaCommonViewModel.key
                    }
                }
                .toHashSet()
        controllerByViewModel
            .filter {
                when (val viewModel = it.key) {
                    is MediaCommonViewModel.MediaControl ->
                        !viewIds.contains(viewModel.instanceId.toString())
                    is MediaCommonViewModel.MediaRecommendations -> !viewIds.contains(viewModel.key)
                }
            }
            .forEach { onRemoved(it.key) }
    }

    private suspend fun getMediaLockScreenSetting(): Boolean {