Create a new link preference for priority modes entry

Test: ZenModesSummaryHelperTest
Test: manual. Successfully search for both 'event' and 'priority'
Flag: android.app.modes_ui
Bug: 341726633
Change-Id: Ib7bd1a5c2f7b06b1728a66f7a9cef53cd45acc0b
This commit is contained in:
Julia Reynolds
2024-07-03 16:19:18 -04:00
parent bb10c9f4df
commit 4fd34aa386
6 changed files with 269 additions and 15 deletions

View File

@@ -16,6 +16,10 @@
package com.android.settings.notification.modes;
import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
import static android.provider.Settings.Global.ZEN_MODE_OFF;
import static android.service.notification.Condition.SOURCE_UNKNOWN;
import static android.service.notification.Condition.STATE_TRUE;
import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_ANYONE;
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_ANYONE;
import static android.service.notification.ZenPolicy.PEOPLE_TYPE_CONTACTS;
@@ -24,13 +28,21 @@ import static android.service.notification.ZenPolicy.VISUAL_EFFECT_LIGHTS;
import static com.google.common.truth.Truth.assertThat;
import android.app.Flags;
import android.content.ComponentName;
import android.content.Context;
import android.net.Uri;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.service.notification.Condition;
import android.service.notification.ZenDeviceEffects;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenPolicy;
import com.android.settingslib.notification.modes.ZenMode;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -46,6 +58,10 @@ public class ZenModesSummaryHelperTest {
private ZenModeSummaryHelper mSummaryHelper;
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(
SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT);
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
@@ -351,4 +367,87 @@ public class ZenModesSummaryHelperTest {
assertThat(mSummaryHelper.getAppsSummary(zenMode, apps)).isEqualTo("FifthApp, FourthApp, "
+ "and 4 more can interrupt");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getSoundSummary_off_noRules() {
ZenModeConfig config = new ZenModeConfig();
assertThat(mSummaryHelper.getSoundSummary(ZEN_MODE_OFF, config)).isEqualTo("Off");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getSoundSummary_off_oneRule() {
ZenModeConfig config = new ZenModeConfig();
ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule();
rule.enabled = true;
config.automaticRules.put("key", rule);
assertThat(mSummaryHelper.getSoundSummary(ZEN_MODE_OFF, config))
.isEqualTo("Off / 1 mode can turn on automatically");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getSoundSummary_off_twoRules() {
ZenModeConfig config = new ZenModeConfig();
ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule();
rule.enabled = true;
ZenModeConfig.ZenRule rule2 = new ZenModeConfig.ZenRule();
rule2.enabled = true;
config.automaticRules.put("key", rule);
config.automaticRules.put("key2", rule2);
assertThat(mSummaryHelper.getSoundSummary(ZEN_MODE_OFF, config))
.isEqualTo("Off / 2 modes can turn on automatically");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getSoundSummary_on_noDescription() {
ZenModeConfig config = new ZenModeConfig();
config.manualRule.conditionId = Uri.EMPTY;
config.manualRule.pkg = "android";
config.manualRule.zenMode = ZEN_MODE_IMPORTANT_INTERRUPTIONS;
config.manualRule.condition = new Condition(Uri.EMPTY, "", STATE_TRUE, SOURCE_UNKNOWN);
assertThat(mSummaryHelper.getSoundSummary(ZEN_MODE_IMPORTANT_INTERRUPTIONS, config))
.isEqualTo("On");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getSoundSummary_on_manualDescription() {
ZenModeConfig config = new ZenModeConfig();
config.manualRule.conditionId = ZenModeConfig.toCountdownConditionId(
System.currentTimeMillis() + 10000, false);
config.manualRule.pkg = "android";
config.manualRule.zenMode = ZEN_MODE_IMPORTANT_INTERRUPTIONS;
config.manualRule.condition = new Condition(Uri.EMPTY, "", STATE_TRUE, SOURCE_UNKNOWN);
assertThat(mSummaryHelper.getSoundSummary(ZEN_MODE_IMPORTANT_INTERRUPTIONS, config))
.startsWith("On /");
}
@Test
@EnableFlags(Flags.FLAG_MODES_UI)
public void getSoundSummary_on_automatic() {
ZenModeConfig config = new ZenModeConfig();
ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule();
rule.configurationActivity = new ComponentName("a", "a");
rule.component = new ComponentName("b", "b");
rule.conditionId = new Uri.Builder().scheme("hello").build();
rule.condition = new Condition(rule.conditionId, "", STATE_TRUE);
rule.enabled = true;
rule.creationTime = 123;
rule.id = "id";
rule.zenMode = ZEN_MODE_IMPORTANT_INTERRUPTIONS;
rule.modified = true;
rule.name = "name";
rule.snoozing = false;
rule.pkg = "b";
config.automaticRules.put("key", rule);
assertThat(mSummaryHelper.getSoundSummary(ZEN_MODE_IMPORTANT_INTERRUPTIONS, config))
.startsWith("On /");
}
}