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

Commit 26f53639 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

notificationBroadcasts shouldn't be a StateFlow

As a stateflow, it doesn't function correctly because we actually do expect duplicate emissions to be meaningful, so we need to keep them. I think it also doesn't need to be a SharedFlow, since I'm not sure the flowOn does anything in that case...

Bug: 346519570
Bug: 347707024
Change-Id: I64da785532d748a27173fda35bcb1f8c21cc42e6
Test: manually logged emissions to test
Flag: com.android.settingslib.flags.volume_panel_broadcast_fix
parent 07fd96ad
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settingslib.notification.data.repository

import android.annotation.SuppressLint
import android.app.NotificationManager
import android.content.BroadcastReceiver
import android.content.ContentResolver
@@ -57,6 +58,7 @@ interface ZenModeRepository {
    val modes: Flow<List<ZenMode>>
}

@SuppressLint("SharedFlowCreation")
class ZenModeRepositoryImpl(
    private val context: Context,
    private val notificationManager: NotificationManager,
@@ -99,12 +101,11 @@ class ZenModeRepositoryImpl(
            }
            .let {
                if (Flags.volumePanelBroadcastFix()) {
                    // Share the flow to avoid having multiple broadcasts.
                    it.flowOn(backgroundCoroutineContext)
                        .shareIn(started = SharingStarted.WhileSubscribed(), scope = scope)
                } else {
                    it.shareIn(
                        started = SharingStarted.WhileSubscribed(),
                        scope = scope,
                    )
                    it.shareIn(started = SharingStarted.WhileSubscribed(), scope = scope)
                }
            }
    }