From d70fbf8e917fc02a2cd814ff7e2a0432806c53ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Hern=C3=A1ndez?= Date: Wed, 7 Aug 2024 19:08:50 +0200 Subject: [PATCH] Filter out disabled modes from the "can activate automatically" count Bug: 355615361 Test: atest ZenModeSummaryHelperTest Flag: android.app.modes_ui Change-Id: Id54f08bfc253e69db0efb4e330813e89c28058d9 --- .../settings/notification/modes/ZenModeSummaryHelper.java | 2 +- ...mmaryHelperTest.java => ZenModeSummaryHelperTest.java} | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) rename tests/robotests/src/com/android/settings/notification/modes/{ZenModesSummaryHelperTest.java => ZenModeSummaryHelperTest.java} (98%) diff --git a/src/com/android/settings/notification/modes/ZenModeSummaryHelper.java b/src/com/android/settings/notification/modes/ZenModeSummaryHelper.java index eec6808478f..c5300da0cee 100644 --- a/src/com/android/settings/notification/modes/ZenModeSummaryHelper.java +++ b/src/com/android/settings/notification/modes/ZenModeSummaryHelper.java @@ -514,7 +514,7 @@ class ZenModeSummaryHelper { return msgFormat.format(args); } else { int automaticModeCount = (int) modes.stream() - .filter(m -> !m.isManualDnd() && !m.isCustomManual()) + .filter(m -> m.isEnabled() && !m.isManualDnd() && !m.isCustomManual()) .count(); MessageFormat msgFormat = new MessageFormat( diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModesSummaryHelperTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeSummaryHelperTest.java similarity index 98% rename from tests/robotests/src/com/android/settings/notification/modes/ZenModesSummaryHelperTest.java rename to tests/robotests/src/com/android/settings/notification/modes/ZenModeSummaryHelperTest.java index 7ad7abc0934..a0e1d38f24d 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModesSummaryHelperTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeSummaryHelperTest.java @@ -61,7 +61,7 @@ import java.util.Random; @RunWith(RobolectricTestRunner.class) @EnableFlags(Flags.FLAG_MODES_UI) -public class ZenModesSummaryHelperTest { +public class ZenModeSummaryHelperTest { private static final int WORK_PROFILE_ID = 3; private Context mContext; @@ -489,7 +489,7 @@ public class ZenModesSummaryHelperTest { } @Test - public void getModesSummary_noRulesActive_countsOnlyAutomaticModes() { + public void getModesSummary_noRulesActive_countsOnlyEnabledAutomaticModes() { ImmutableList modes = ImmutableList.of( TestModeBuilder.MANUAL_DND_INACTIVE, // Not automatic new TestModeBuilder().setName("Auto 1").build(), // App provided automatic @@ -499,6 +499,10 @@ public class ZenModesSummaryHelperTest { .setType(AutomaticZenRule.TYPE_OTHER) .setConditionId(ZenModeConfig.toCustomManualConditionId()) .build(), // Custom manual, not automatic + new TestModeBuilder() + .setName("Disabled 1") + .setEnabled(false) + .build(), // Would be automatic, but it's disabled. new TestModeBuilder() .setName("Sleep") .setPackage(SystemZenRules.PACKAGE_ANDROID)