diff options
| author | 2024-09-10 18:51:22 +0000 | |
|---|---|---|
| committer | 2024-09-10 18:51:22 +0000 | |
| commit | cb41c033704c2592aa40b63596ef03ea6558c2cf (patch) | |
| tree | eb097389039a302970104a8e0ca707276838c117 | |
| parent | 3c77aff57832af13033714298f09f3bf0d667eb8 (diff) | |
| parent | bf0074717d72d55df1e25a4736ad2c6650171cfc (diff) | |
Merge "Fix wrong suppression setting value" into main
3 files changed, 21 insertions, 4 deletions
| diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt index 0efd5f15cb09..ec0827b4c478 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt @@ -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      }  } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt index 2f8711a586ef..d4466f8771a6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt @@ -195,7 +195,8 @@ constructor(                      uiEventLogger,                      context,                      notificationManager, -                    logger +                    logger, +                    systemSettings                  )              )              avalancheProvider.register() diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt index ed99705b194e..b177e4a3e22e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt @@ -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          )      } |