Loading packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt +0 −4 Original line number Diff line number Diff line Loading @@ -74,10 +74,6 @@ class FakeZenModeRepository : ZenModeRepository { mutableModesFlow.value = mutableModesFlow.value.filter { it.id != id } } fun replaceMode(modeId: String, mode: ZenMode) { mutableModesFlow.value = (mutableModesFlow.value.filter { it.id != modeId }) + mode } fun clearModes() { mutableModesFlow.value = listOf() } Loading packages/SettingsLib/src/com/android/settingslib/notification/modes/TestModeBuilder.java +31 −17 Original line number Diff line number Diff line Loading @@ -41,32 +41,24 @@ public class TestModeBuilder { private String mId; private AutomaticZenRule mRule; private ZenModeConfig.ZenRule mConfigZenRule; private boolean mIsManualDnd; public static final ZenMode EXAMPLE = new TestModeBuilder().build(); public static final ZenMode MANUAL_DND_ACTIVE = manualDnd(Uri.EMPTY, public static final ZenMode MANUAL_DND_ACTIVE = manualDnd( INTERRUPTION_FILTER_PRIORITY, true); public static final ZenMode MANUAL_DND_INACTIVE = manualDnd(Uri.EMPTY, public static final ZenMode MANUAL_DND_INACTIVE = manualDnd( INTERRUPTION_FILTER_PRIORITY, false); @NonNull public static ZenMode manualDnd(@NotificationManager.InterruptionFilter int filter, boolean isActive) { return manualDnd(Uri.EMPTY, filter, isActive); } private static ZenMode manualDnd(Uri conditionId, @NotificationManager.InterruptionFilter int filter, boolean isActive) { return ZenMode.manualDndMode( new AutomaticZenRule.Builder("Do Not Disturb", conditionId) return new TestModeBuilder() .makeManualDnd() .setInterruptionFilter(filter) .setType(AutomaticZenRule.TYPE_OTHER) .setManualInvocationAllowed(true) .setPackage(SystemZenRules.PACKAGE_ANDROID) .setZenPolicy(new ZenPolicy.Builder().disallowAllSounds().build()) .build(), isActive); .setActive(isActive) .build(); } public TestModeBuilder() { Loading @@ -91,6 +83,10 @@ public class TestModeBuilder { mConfigZenRule.enabled = previous.getRule().isEnabled(); mConfigZenRule.pkg = previous.getRule().getPackageName(); setActive(previous.isActive()); if (previous.isManualDnd()) { makeManualDnd(); } } public TestModeBuilder setId(String id) { Loading Loading @@ -222,7 +218,25 @@ public class TestModeBuilder { return this; } public TestModeBuilder makeManualDnd() { mIsManualDnd = true; // Set the "fixed" properties of a DND mode. Other things, such as policy/filter may be set // separately or copied from a preexisting DND, so they are not overwritten here. setId(ZenMode.MANUAL_DND_MODE_ID); setName("Do Not Disturb"); setType(AutomaticZenRule.TYPE_OTHER); setManualInvocationAllowed(true); setPackage(SystemZenRules.PACKAGE_ANDROID); setConditionId(Uri.EMPTY); return this; } public ZenMode build() { if (mIsManualDnd) { return ZenMode.manualDndMode(mRule, mConfigZenRule.condition != null && mConfigZenRule.condition.state == Condition.STATE_TRUE); } else { return new ZenMode(mId, mRule, mConfigZenRule); } } } packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/quickaffordance/DoNotDisturbQuickAffordanceConfigTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -405,7 +405,8 @@ class DoNotDisturbQuickAffordanceConfigTest : SysuiTestCase() { testScope.runTest { val lockScreenState by collectLastValue(underTest.lockScreenState) zenModeRepository.addMode(TestModeBuilder.MANUAL_DND_INACTIVE) val manualDnd = TestModeBuilder.MANUAL_DND_INACTIVE zenModeRepository.addMode(manualDnd) runCurrent() assertThat(lockScreenState) Loading @@ -419,8 +420,7 @@ class DoNotDisturbQuickAffordanceConfigTest : SysuiTestCase() { ) ) zenModeRepository.removeMode(TestModeBuilder.MANUAL_DND_INACTIVE.id) zenModeRepository.addMode(TestModeBuilder.MANUAL_DND_ACTIVE) zenModeRepository.activateMode(manualDnd) runCurrent() assertThat(lockScreenState) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractorTest.kt +1 −2 Original line number Diff line number Diff line Loading @@ -378,8 +378,7 @@ class ZenModeInteractorTest : SysuiTestCase() { assertThat(dndMode!!.isActive).isFalse() zenModeRepository.removeMode(TestModeBuilder.MANUAL_DND_INACTIVE.id) zenModeRepository.addMode(TestModeBuilder.MANUAL_DND_ACTIVE) zenModeRepository.activateMode(TestModeBuilder.MANUAL_DND_INACTIVE.id) runCurrent() assertThat(dndMode!!.isActive).isTrue() Loading packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +4 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.view.ViewTreeObserver import android.widget.FrameLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.settingslib.notification.modes.TestModeBuilder.MANUAL_DND_ACTIVE import com.android.settingslib.notification.modes.TestModeBuilder.MANUAL_DND_INACTIVE import com.android.systemui.Flags as AConfigFlags import com.android.systemui.SysuiTestCase Loading Loading @@ -107,6 +106,7 @@ class ClockEventControllerTest : SysuiTestCase() { private lateinit var repository: FakeKeyguardRepository private val clockBuffers = ClockMessageBuffers(LogcatOnlyMessageBuffer(LogLevel.DEBUG)) private lateinit var underTest: ClockEventController private lateinit var dndModeId: String @Mock private lateinit var broadcastDispatcher: BroadcastDispatcher @Mock private lateinit var batteryController: BatteryController Loading Loading @@ -156,6 +156,7 @@ class ClockEventControllerTest : SysuiTestCase() { whenever(largeClockController.theme).thenReturn(ThemeConfig(true, null)) whenever(userTracker.userId).thenReturn(1) dndModeId = MANUAL_DND_INACTIVE.id zenModeRepository.addMode(MANUAL_DND_INACTIVE) repository = FakeKeyguardRepository() Loading Loading @@ -528,7 +529,7 @@ class ClockEventControllerTest : SysuiTestCase() { testScope.runTest { underTest.listenForDnd(testScope.backgroundScope) zenModeRepository.replaceMode(MANUAL_DND_INACTIVE.id, MANUAL_DND_ACTIVE) zenModeRepository.activateMode(dndModeId) runCurrent() verify(events) Loading @@ -536,7 +537,7 @@ class ClockEventControllerTest : SysuiTestCase() { eq(ZenData(ZenMode.IMPORTANT_INTERRUPTIONS, R.string::dnd_is_on.name)) ) zenModeRepository.replaceMode(MANUAL_DND_ACTIVE.id, MANUAL_DND_INACTIVE) zenModeRepository.deactivateMode(dndModeId) runCurrent() verify(events).onZenDataChanged(eq(ZenData(ZenMode.OFF, R.string::dnd_is_off.name))) Loading Loading
packages/SettingsLib/src/com/android/settingslib/notification/data/repository/FakeZenModeRepository.kt +0 −4 Original line number Diff line number Diff line Loading @@ -74,10 +74,6 @@ class FakeZenModeRepository : ZenModeRepository { mutableModesFlow.value = mutableModesFlow.value.filter { it.id != id } } fun replaceMode(modeId: String, mode: ZenMode) { mutableModesFlow.value = (mutableModesFlow.value.filter { it.id != modeId }) + mode } fun clearModes() { mutableModesFlow.value = listOf() } Loading
packages/SettingsLib/src/com/android/settingslib/notification/modes/TestModeBuilder.java +31 −17 Original line number Diff line number Diff line Loading @@ -41,32 +41,24 @@ public class TestModeBuilder { private String mId; private AutomaticZenRule mRule; private ZenModeConfig.ZenRule mConfigZenRule; private boolean mIsManualDnd; public static final ZenMode EXAMPLE = new TestModeBuilder().build(); public static final ZenMode MANUAL_DND_ACTIVE = manualDnd(Uri.EMPTY, public static final ZenMode MANUAL_DND_ACTIVE = manualDnd( INTERRUPTION_FILTER_PRIORITY, true); public static final ZenMode MANUAL_DND_INACTIVE = manualDnd(Uri.EMPTY, public static final ZenMode MANUAL_DND_INACTIVE = manualDnd( INTERRUPTION_FILTER_PRIORITY, false); @NonNull public static ZenMode manualDnd(@NotificationManager.InterruptionFilter int filter, boolean isActive) { return manualDnd(Uri.EMPTY, filter, isActive); } private static ZenMode manualDnd(Uri conditionId, @NotificationManager.InterruptionFilter int filter, boolean isActive) { return ZenMode.manualDndMode( new AutomaticZenRule.Builder("Do Not Disturb", conditionId) return new TestModeBuilder() .makeManualDnd() .setInterruptionFilter(filter) .setType(AutomaticZenRule.TYPE_OTHER) .setManualInvocationAllowed(true) .setPackage(SystemZenRules.PACKAGE_ANDROID) .setZenPolicy(new ZenPolicy.Builder().disallowAllSounds().build()) .build(), isActive); .setActive(isActive) .build(); } public TestModeBuilder() { Loading @@ -91,6 +83,10 @@ public class TestModeBuilder { mConfigZenRule.enabled = previous.getRule().isEnabled(); mConfigZenRule.pkg = previous.getRule().getPackageName(); setActive(previous.isActive()); if (previous.isManualDnd()) { makeManualDnd(); } } public TestModeBuilder setId(String id) { Loading Loading @@ -222,7 +218,25 @@ public class TestModeBuilder { return this; } public TestModeBuilder makeManualDnd() { mIsManualDnd = true; // Set the "fixed" properties of a DND mode. Other things, such as policy/filter may be set // separately or copied from a preexisting DND, so they are not overwritten here. setId(ZenMode.MANUAL_DND_MODE_ID); setName("Do Not Disturb"); setType(AutomaticZenRule.TYPE_OTHER); setManualInvocationAllowed(true); setPackage(SystemZenRules.PACKAGE_ANDROID); setConditionId(Uri.EMPTY); return this; } public ZenMode build() { if (mIsManualDnd) { return ZenMode.manualDndMode(mRule, mConfigZenRule.condition != null && mConfigZenRule.condition.state == Condition.STATE_TRUE); } else { return new ZenMode(mId, mRule, mConfigZenRule); } } }
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/quickaffordance/DoNotDisturbQuickAffordanceConfigTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -405,7 +405,8 @@ class DoNotDisturbQuickAffordanceConfigTest : SysuiTestCase() { testScope.runTest { val lockScreenState by collectLastValue(underTest.lockScreenState) zenModeRepository.addMode(TestModeBuilder.MANUAL_DND_INACTIVE) val manualDnd = TestModeBuilder.MANUAL_DND_INACTIVE zenModeRepository.addMode(manualDnd) runCurrent() assertThat(lockScreenState) Loading @@ -419,8 +420,7 @@ class DoNotDisturbQuickAffordanceConfigTest : SysuiTestCase() { ) ) zenModeRepository.removeMode(TestModeBuilder.MANUAL_DND_INACTIVE.id) zenModeRepository.addMode(TestModeBuilder.MANUAL_DND_ACTIVE) zenModeRepository.activateMode(manualDnd) runCurrent() assertThat(lockScreenState) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/domain/interactor/ZenModeInteractorTest.kt +1 −2 Original line number Diff line number Diff line Loading @@ -378,8 +378,7 @@ class ZenModeInteractorTest : SysuiTestCase() { assertThat(dndMode!!.isActive).isFalse() zenModeRepository.removeMode(TestModeBuilder.MANUAL_DND_INACTIVE.id) zenModeRepository.addMode(TestModeBuilder.MANUAL_DND_ACTIVE) zenModeRepository.activateMode(TestModeBuilder.MANUAL_DND_INACTIVE.id) runCurrent() assertThat(dndMode!!.isActive).isTrue() Loading
packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +4 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.view.ViewTreeObserver import android.widget.FrameLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.settingslib.notification.modes.TestModeBuilder.MANUAL_DND_ACTIVE import com.android.settingslib.notification.modes.TestModeBuilder.MANUAL_DND_INACTIVE import com.android.systemui.Flags as AConfigFlags import com.android.systemui.SysuiTestCase Loading Loading @@ -107,6 +106,7 @@ class ClockEventControllerTest : SysuiTestCase() { private lateinit var repository: FakeKeyguardRepository private val clockBuffers = ClockMessageBuffers(LogcatOnlyMessageBuffer(LogLevel.DEBUG)) private lateinit var underTest: ClockEventController private lateinit var dndModeId: String @Mock private lateinit var broadcastDispatcher: BroadcastDispatcher @Mock private lateinit var batteryController: BatteryController Loading Loading @@ -156,6 +156,7 @@ class ClockEventControllerTest : SysuiTestCase() { whenever(largeClockController.theme).thenReturn(ThemeConfig(true, null)) whenever(userTracker.userId).thenReturn(1) dndModeId = MANUAL_DND_INACTIVE.id zenModeRepository.addMode(MANUAL_DND_INACTIVE) repository = FakeKeyguardRepository() Loading Loading @@ -528,7 +529,7 @@ class ClockEventControllerTest : SysuiTestCase() { testScope.runTest { underTest.listenForDnd(testScope.backgroundScope) zenModeRepository.replaceMode(MANUAL_DND_INACTIVE.id, MANUAL_DND_ACTIVE) zenModeRepository.activateMode(dndModeId) runCurrent() verify(events) Loading @@ -536,7 +537,7 @@ class ClockEventControllerTest : SysuiTestCase() { eq(ZenData(ZenMode.IMPORTANT_INTERRUPTIONS, R.string::dnd_is_on.name)) ) zenModeRepository.replaceMode(MANUAL_DND_ACTIVE.id, MANUAL_DND_INACTIVE) zenModeRepository.deactivateMode(dndModeId) runCurrent() verify(events).onZenDataChanged(eq(ZenData(ZenMode.OFF, R.string::dnd_is_off.name))) Loading