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

Commit bf007471 authored by Lyn's avatar Lyn Committed by Lyn Han
Browse files

Fix wrong suppression setting value

Fixes: 356768397
Test: manual - check that cooldown setting is on,
      turn airplane mode on and off, sending high priority notif
      => notif is suppressed
Flag: com.android.systemui.notification_avalanche_suppression
Change-Id: I6a54e83b1ab0ccd96ebb8fbf9a06d264922fd4db
parent 00f16abc
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.HeadsUpManager
import com.android.systemui.util.NotificationChannels
import com.android.systemui.util.settings.GlobalSettings
import com.android.systemui.util.settings.SystemSettings
import com.android.systemui.util.time.SystemClock
import com.android.wm.shell.bubbles.Bubbles
import java.util.Optional
@@ -279,7 +280,8 @@ class AvalancheSuppressor(
    private val uiEventLogger: UiEventLogger,
    private val context: Context,
    private val notificationManager: NotificationManager,
    private val logger: VisualInterruptionDecisionLogger
    private val logger: VisualInterruptionDecisionLogger,
    private val systemSettings: SystemSettings,
) :
    VisualInterruptionFilter(
        types = setOf(PEEK, PULSE),
@@ -300,6 +302,11 @@ class AvalancheSuppressor(
    // education HUNs.
    private var hasShownOnceForDebug = false

    // Sometimes the kotlin flow value is false even when the cooldown setting is true (b/356768397)
    // so let's directly check settings until we confirm that the flow is initialized and in sync
    // with the real settings value.
    private var isCooldownFlowInSync = false

    private fun shouldShowEdu(): Boolean {
        val forceShowOnce = SystemProperties.get(FORCE_SHOW_AVALANCHE_EDU_ONCE, "").equals("1")
        return !hasSeenEdu || (forceShowOnce && !hasShownOnceForDebug)
@@ -479,6 +486,15 @@ class AvalancheSuppressor(
    }

    private fun isCooldownEnabled(): Boolean {
        return settingsInteractor.isCooldownEnabled.value
        val isEnabledFromFlow = settingsInteractor.isCooldownEnabled.value
        if (isCooldownFlowInSync) {
            return isEnabledFromFlow
        }
        val isEnabled =
            systemSettings.getInt(Settings.System.NOTIFICATION_COOLDOWN_ENABLED, /* def */ 1) == 1
        if (isEnabled == isEnabledFromFlow) {
            isCooldownFlowInSync = true
        }
        return isEnabled
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -195,7 +195,8 @@ constructor(
                    uiEventLogger,
                    context,
                    notificationManager,
                    logger
                    logger,
                    systemSettings
                )
            )
            avalancheProvider.register()
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
    private fun getAvalancheSuppressor() : AvalancheSuppressor {
        return AvalancheSuppressor(
            avalancheProvider, systemClock, settingsInteractor, packageManager,
            uiEventLogger, context, notificationManager, logger
            uiEventLogger, context, notificationManager, logger, systemSettings
        )
    }