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

Commit 3b2dd309 authored by Matías Hernández's avatar Matías Hernández
Browse files

Initialize (and test) more defaults in AutomaticZenRule.Builder

Fixes: 333679535
Test: atest AutomaticZenRuleTest
Change-Id: I509c3eff2fb382b5160e6b0a75f689ebe95c9083
parent 29e478b0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -671,7 +671,7 @@ public final class AutomaticZenRule implements Parcelable {
        private String mName;
        private ComponentName mOwner;
        private Uri mConditionId;
        private int mInterruptionFilter;
        private int mInterruptionFilter = NotificationManager.INTERRUPTION_FILTER_PRIORITY;
        private boolean mEnabled = true;
        private ComponentName mConfigurationActivity = null;
        private ZenPolicy mPolicy = null;
+5 −1
Original line number Diff line number Diff line
@@ -189,12 +189,16 @@ public class AutomaticZenRuleTest {

    @Test
    @EnableFlags(Flags.FLAG_MODES_API)
    public void builder_defaultTypeUnknown() {
    public void builder_defaultsAreSensible() {
        AutomaticZenRule rule = new AutomaticZenRule.Builder("name",
                Uri.parse("conditionId")).build();

        assertThat(rule.getType()).isEqualTo(AutomaticZenRule.TYPE_UNKNOWN);
        assertThat(rule.getInterruptionFilter()).isEqualTo(
                NotificationManager.INTERRUPTION_FILTER_PRIORITY);
        assertThat(rule.isEnabled()).isTrue();
    }

    @Test
    @EnableFlags(Flags.FLAG_MODES_API)
    public void validate_builderWithValidType_succeeds() throws Exception {
+3 −1
Original line number Diff line number Diff line
@@ -3655,6 +3655,7 @@ public class ZenModeHelperTest extends UiServiceTestCase {
        // Create immersive rule
        AutomaticZenRule immersive = new AutomaticZenRule.Builder("Immersed", CONDITION_ID)
                .setType(TYPE_IMMERSIVE)
                .setZenPolicy(mZenModeHelper.mConfig.toZenPolicy()) // same as the manual rule
                .build();
        String immersiveId = mZenModeHelper.addAutomaticZenRule(mPkg, immersive, UPDATE_ORIGIN_APP,
                "reason", CUSTOM_PKG_UID);
@@ -4242,6 +4243,7 @@ public class ZenModeHelperTest extends UiServiceTestCase {
    public void updateAutomaticZenRule_fromUser_updatesBitmaskAndValue() {
        // Adds a starting rule with empty zen policies and device effects
        AutomaticZenRule azrBase = new AutomaticZenRule.Builder(NAME, CONDITION_ID)
                .setInterruptionFilter(INTERRUPTION_FILTER_ALARMS)
                .setZenPolicy(new ZenPolicy.Builder().build())
                .setDeviceEffects(new ZenDeviceEffects.Builder().build())
                .build();
@@ -4250,7 +4252,7 @@ public class ZenModeHelperTest extends UiServiceTestCase {
                azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID);
        AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId);

        // Modifies the zen policy and device effects
        // Modifies the filter, zen policy, and device effects
        ZenPolicy policy = new ZenPolicy.Builder(rule.getZenPolicy())
                .allowPriorityChannels(false)
                .build();