Loading services/core/java/com/android/server/notification/ZenAdapters.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.notification; import android.app.Flags; import android.app.NotificationManager.Policy; import android.service.notification.ZenModeConfig; import android.service.notification.ZenPolicy; Loading Loading @@ -57,6 +58,12 @@ class ZenAdapters { .showStatusBarIcons(policy.showStatusBarIcons()); } if (Flags.modesApi()) { zenPolicyBuilder.allowChannels( policy.allowPriorityChannels() ? ZenPolicy.CHANNEL_TYPE_PRIORITY : ZenPolicy.CHANNEL_TYPE_NONE); } return zenPolicyBuilder.build(); } Loading services/tests/uiservicestests/src/com/android/server/notification/ZenAdaptersTest.java +39 −0 Original line number Diff line number Diff line Loading @@ -20,7 +20,11 @@ import static com.android.server.notification.ZenAdapters.notificationPolicyToZe import static com.google.common.truth.Truth.assertThat; import android.app.Flags; import android.app.NotificationManager.Policy; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.service.notification.ZenPolicy; import androidx.test.filters.SmallTest; Loading @@ -28,6 +32,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.server.UiServiceTestCase; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -35,6 +40,9 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class ZenAdaptersTest extends UiServiceTestCase { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Test public void notificationPolicyToZenPolicy_allCallers() { Policy policy = new Policy(Policy.PRIORITY_CATEGORY_CALLS, Policy.PRIORITY_SENDERS_ANY, 0); Loading Loading @@ -127,4 +135,35 @@ public class ZenAdaptersTest extends UiServiceTestCase { assertThat(zenPolicy.getVisualEffectPeek()).isEqualTo(ZenPolicy.STATE_UNSET); assertThat(zenPolicy.getVisualEffectStatusBar()).isEqualTo(ZenPolicy.STATE_UNSET); } @Test @EnableFlags(Flags.FLAG_MODES_API) public void notificationPolicyToZenPolicy_modesApi_priorityChannels() { Policy policy = new Policy(0, 0, 0, 0, Policy.policyState(false, true), 0); ZenPolicy zenPolicy = notificationPolicyToZenPolicy(policy); assertThat(zenPolicy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_PRIORITY); Policy notAllowed = new Policy(0, 0, 0, 0, Policy.policyState(false, false), 0); ZenPolicy zenPolicyNotAllowed = notificationPolicyToZenPolicy(notAllowed); assertThat(zenPolicyNotAllowed.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_NONE); } @Test @DisableFlags(Flags.FLAG_MODES_API) public void notificationPolicyToZenPolicy_noModesApi_priorityChannelsUnset() { Policy policy = new Policy(0, 0, 0, 0, Policy.policyState(false, true), 0); ZenPolicy zenPolicy = notificationPolicyToZenPolicy(policy); assertThat(zenPolicy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_UNSET); Policy notAllowed = new Policy(0, 0, 0, 0, Policy.policyState(false, false), 0); ZenPolicy zenPolicyNotAllowed = notificationPolicyToZenPolicy(notAllowed); assertThat(zenPolicyNotAllowed.getAllowedChannels()) .isEqualTo(ZenPolicy.CHANNEL_TYPE_UNSET); } } services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -3876,6 +3876,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { .allowCalls(PEOPLE_TYPE_CONTACTS) .allowConversations(CONVERSATION_SENDERS_IMPORTANT) .hideAllVisualEffects() .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY) .build(); assertThat(mZenModeHelper.mConfig.automaticRules.values()) .comparingElementsUsing(IGNORE_TIMESTAMPS) Loading Loading @@ -3907,6 +3908,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { .allowCalls(PEOPLE_TYPE_STARRED) .allowConversations(CONVERSATION_SENDERS_IMPORTANT) .hideAllVisualEffects() .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY) .build(); assertThat(mZenModeHelper.mConfig.automaticRules.values()) .comparingElementsUsing(IGNORE_TIMESTAMPS) Loading Loading
services/core/java/com/android/server/notification/ZenAdapters.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.notification; import android.app.Flags; import android.app.NotificationManager.Policy; import android.service.notification.ZenModeConfig; import android.service.notification.ZenPolicy; Loading Loading @@ -57,6 +58,12 @@ class ZenAdapters { .showStatusBarIcons(policy.showStatusBarIcons()); } if (Flags.modesApi()) { zenPolicyBuilder.allowChannels( policy.allowPriorityChannels() ? ZenPolicy.CHANNEL_TYPE_PRIORITY : ZenPolicy.CHANNEL_TYPE_NONE); } return zenPolicyBuilder.build(); } Loading
services/tests/uiservicestests/src/com/android/server/notification/ZenAdaptersTest.java +39 −0 Original line number Diff line number Diff line Loading @@ -20,7 +20,11 @@ import static com.android.server.notification.ZenAdapters.notificationPolicyToZe import static com.google.common.truth.Truth.assertThat; import android.app.Flags; import android.app.NotificationManager.Policy; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.service.notification.ZenPolicy; import androidx.test.filters.SmallTest; Loading @@ -28,6 +32,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.server.UiServiceTestCase; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -35,6 +40,9 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class ZenAdaptersTest extends UiServiceTestCase { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Test public void notificationPolicyToZenPolicy_allCallers() { Policy policy = new Policy(Policy.PRIORITY_CATEGORY_CALLS, Policy.PRIORITY_SENDERS_ANY, 0); Loading Loading @@ -127,4 +135,35 @@ public class ZenAdaptersTest extends UiServiceTestCase { assertThat(zenPolicy.getVisualEffectPeek()).isEqualTo(ZenPolicy.STATE_UNSET); assertThat(zenPolicy.getVisualEffectStatusBar()).isEqualTo(ZenPolicy.STATE_UNSET); } @Test @EnableFlags(Flags.FLAG_MODES_API) public void notificationPolicyToZenPolicy_modesApi_priorityChannels() { Policy policy = new Policy(0, 0, 0, 0, Policy.policyState(false, true), 0); ZenPolicy zenPolicy = notificationPolicyToZenPolicy(policy); assertThat(zenPolicy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_PRIORITY); Policy notAllowed = new Policy(0, 0, 0, 0, Policy.policyState(false, false), 0); ZenPolicy zenPolicyNotAllowed = notificationPolicyToZenPolicy(notAllowed); assertThat(zenPolicyNotAllowed.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_NONE); } @Test @DisableFlags(Flags.FLAG_MODES_API) public void notificationPolicyToZenPolicy_noModesApi_priorityChannelsUnset() { Policy policy = new Policy(0, 0, 0, 0, Policy.policyState(false, true), 0); ZenPolicy zenPolicy = notificationPolicyToZenPolicy(policy); assertThat(zenPolicy.getAllowedChannels()).isEqualTo(ZenPolicy.CHANNEL_TYPE_UNSET); Policy notAllowed = new Policy(0, 0, 0, 0, Policy.policyState(false, false), 0); ZenPolicy zenPolicyNotAllowed = notificationPolicyToZenPolicy(notAllowed); assertThat(zenPolicyNotAllowed.getAllowedChannels()) .isEqualTo(ZenPolicy.CHANNEL_TYPE_UNSET); } }
services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -3876,6 +3876,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { .allowCalls(PEOPLE_TYPE_CONTACTS) .allowConversations(CONVERSATION_SENDERS_IMPORTANT) .hideAllVisualEffects() .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY) .build(); assertThat(mZenModeHelper.mConfig.automaticRules.values()) .comparingElementsUsing(IGNORE_TIMESTAMPS) Loading Loading @@ -3907,6 +3908,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { .allowCalls(PEOPLE_TYPE_STARRED) .allowConversations(CONVERSATION_SENDERS_IMPORTANT) .hideAllVisualEffects() .allowChannels(ZenPolicy.CHANNEL_TYPE_PRIORITY) .build(); assertThat(mZenModeHelper.mConfig.automaticRules.values()) .comparingElementsUsing(IGNORE_TIMESTAMPS) Loading