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

Commit 1024fe20 authored by Anton Potapov's avatar Anton Potapov
Browse files

Filter irrelevant volume changes

We only care abour rounded volume levels, so we can distinct based on
this.

Flag: com.android.systemui.volume_redesign
Bug: 343930955
Test: manual on foldable. Check that volume adjustement is smooth
Change-Id: I7a2bb4eea4266c6d30a0513c604850a996260222
parent d6c0959f
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -41,11 +41,13 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.stateIn

/*
@@ -129,9 +131,10 @@ constructor(

    init {
        userVolumeUpdates
            .filterNotNull()
            .mapNotNull { it?.newVolumeLevel?.roundToInt() }
            .distinctUntilChanged()
            .mapLatest { volume ->
                interactor.setStreamVolume(volume.newVolumeLevel.roundToInt())
                interactor.setStreamVolume(volume)
                Events.writeEvent(Events.EVENT_TOUCH_LEVEL_CHANGED, model.first().stream, volume)
            }
            .launchIn(coroutineScope)