Loading core/java/android/service/notification/ZenModeConfig.java +6 −8 Original line number Diff line number Diff line Loading @@ -2658,10 +2658,9 @@ public class ZenModeConfig implements Parcelable { public Instant lastActivation; /** * Last time at which the rule was manually activated (whether as a user action in * Settings or SystemUI, or from the owner package with * {@link Condition#SOURCE_USER_ACTION}). If {@code null}, the rule has never been manually * activated since its creation. * Last time at which the rule was manually activated (as a user action in Settings or * SystemUI). If {@code null}, the rule has never been manually activated since its * creation. * * <p>Note that this was previously untracked, so it will also be {@code null} for rules * created before we started tracking and never activated since. Loading @@ -2680,10 +2679,9 @@ public class ZenModeConfig implements Parcelable { public Instant lastDeactivation; /** * Last time at which the rule was manually deactivated (whether as a user action in * Settings or SystemUI, or from the owner package with * {@link Condition#SOURCE_USER_ACTION}). If {@code null}, the rule has never been manually * deactivated since its creation. * Last time at which the rule was manually deactivated (as a user action in Settings or * SystemUI). If {@code null}, the rule has never been manually deactivated since its * creation. * * <p>Note that this was previously untracked, so it will also be {@code null} for rules * created before we started tracking and never deactivated since. Loading services/core/java/com/android/server/notification/ZenModeHelper.java +1 −2 Original line number Diff line number Diff line Loading @@ -2115,8 +2115,7 @@ public class ZenModeHelper { // Update last activation for rules that are being activated. Instant now = mClock.instant(); boolean isManualOrigin = origin == ORIGIN_USER_IN_SYSTEMUI || origin == ORIGIN_USER_IN_APP; boolean isManualOrigin = origin == ORIGIN_USER_IN_SYSTEMUI; if (Flags.modesUi() && (Flags.modesCleanupImplicit() || Flags.modesUiTileReactivatesLast())) { if (!mConfig.isManualActive() && config.isManualActive()) { Loading services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +0 −49 Original line number Diff line number Diff line Loading @@ -7453,55 +7453,6 @@ public class ZenModeHelperTest extends UiServiceTestCase { assertThat(getZenRule(ruleTwo).lastManualDeactivation).isNull(); } @Test @EnableFlags({FLAG_MODES_UI, FLAG_MODES_CLEANUP_IMPLICIT, FLAG_MODES_UI_TILE_REACTIVATES_LAST}) public void setAutomaticZenRuleState_manualFromApp_updatesLastManualActivation() { String rule = mZenModeHelper.addAutomaticZenRule(UserHandle.CURRENT, mPkg, new AutomaticZenRule.Builder("rule", CONDITION_ID) .setConfigurationActivity(new ComponentName(mPkg, "cls")) .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) .build(), ORIGIN_APP, "reason", CUSTOM_PKG_UID); assertThat(getZenRule(rule).lastManualActivation).isNull(); assertThat(getZenRule(rule).lastManualDeactivation).isNull(); Instant manualOn = Instant.ofEpochMilli(100); mTestClock.setNow(manualOn); mZenModeHelper.setAutomaticZenRuleState(UserHandle.CURRENT, rule, new Condition(CONDITION_ID, "on", STATE_TRUE, SOURCE_USER_ACTION), ORIGIN_USER_IN_APP, CUSTOM_PKG_UID); assertThat(getZenRule(rule).lastManualActivation).isEqualTo(manualOn); assertThat(getZenRule(rule).lastManualDeactivation).isNull(); Instant manualOff = Instant.ofEpochMilli(200); mTestClock.setNow(manualOff); mZenModeHelper.setAutomaticZenRuleState(UserHandle.CURRENT, rule, new Condition(CONDITION_ID, "off", STATE_FALSE, SOURCE_USER_ACTION), ORIGIN_USER_IN_APP, CUSTOM_PKG_UID); assertThat(getZenRule(rule).lastManualActivation).isEqualTo(manualOn); assertThat(getZenRule(rule).lastManualDeactivation).isEqualTo(manualOff); Instant autoOn = Instant.ofEpochMilli(300); mTestClock.setNow(autoOn); mZenModeHelper.setAutomaticZenRuleState(UserHandle.CURRENT, rule, new Condition(CONDITION_ID, "auto on", STATE_TRUE, SOURCE_CONTEXT), ORIGIN_APP, CUSTOM_PKG_UID); Instant autoOff = Instant.ofEpochMilli(400); mTestClock.setNow(autoOff); mZenModeHelper.setAutomaticZenRuleState(UserHandle.CURRENT, rule, new Condition(CONDITION_ID, "auto off", STATE_FALSE, SOURCE_CONTEXT), ORIGIN_APP, CUSTOM_PKG_UID); assertThat(getZenRule(rule).lastManualActivation).isEqualTo(manualOn); assertThat(getZenRule(rule).lastManualDeactivation).isEqualTo(manualOff); assertThat(getZenRule(rule).lastActivation).isEqualTo(autoOn); assertThat(getZenRule(rule).lastDeactivation).isEqualTo(autoOff); } @Test @EnableFlags({FLAG_MODES_UI, FLAG_MODES_CLEANUP_IMPLICIT, FLAG_MODES_UI_TILE_REACTIVATES_LAST}) public void setManualZenMode_updatesLastActivation() { Loading Loading
core/java/android/service/notification/ZenModeConfig.java +6 −8 Original line number Diff line number Diff line Loading @@ -2658,10 +2658,9 @@ public class ZenModeConfig implements Parcelable { public Instant lastActivation; /** * Last time at which the rule was manually activated (whether as a user action in * Settings or SystemUI, or from the owner package with * {@link Condition#SOURCE_USER_ACTION}). If {@code null}, the rule has never been manually * activated since its creation. * Last time at which the rule was manually activated (as a user action in Settings or * SystemUI). If {@code null}, the rule has never been manually activated since its * creation. * * <p>Note that this was previously untracked, so it will also be {@code null} for rules * created before we started tracking and never activated since. Loading @@ -2680,10 +2679,9 @@ public class ZenModeConfig implements Parcelable { public Instant lastDeactivation; /** * Last time at which the rule was manually deactivated (whether as a user action in * Settings or SystemUI, or from the owner package with * {@link Condition#SOURCE_USER_ACTION}). If {@code null}, the rule has never been manually * deactivated since its creation. * Last time at which the rule was manually deactivated (as a user action in Settings or * SystemUI). If {@code null}, the rule has never been manually deactivated since its * creation. * * <p>Note that this was previously untracked, so it will also be {@code null} for rules * created before we started tracking and never deactivated since. Loading
services/core/java/com/android/server/notification/ZenModeHelper.java +1 −2 Original line number Diff line number Diff line Loading @@ -2115,8 +2115,7 @@ public class ZenModeHelper { // Update last activation for rules that are being activated. Instant now = mClock.instant(); boolean isManualOrigin = origin == ORIGIN_USER_IN_SYSTEMUI || origin == ORIGIN_USER_IN_APP; boolean isManualOrigin = origin == ORIGIN_USER_IN_SYSTEMUI; if (Flags.modesUi() && (Flags.modesCleanupImplicit() || Flags.modesUiTileReactivatesLast())) { if (!mConfig.isManualActive() && config.isManualActive()) { Loading
services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +0 −49 Original line number Diff line number Diff line Loading @@ -7453,55 +7453,6 @@ public class ZenModeHelperTest extends UiServiceTestCase { assertThat(getZenRule(ruleTwo).lastManualDeactivation).isNull(); } @Test @EnableFlags({FLAG_MODES_UI, FLAG_MODES_CLEANUP_IMPLICIT, FLAG_MODES_UI_TILE_REACTIVATES_LAST}) public void setAutomaticZenRuleState_manualFromApp_updatesLastManualActivation() { String rule = mZenModeHelper.addAutomaticZenRule(UserHandle.CURRENT, mPkg, new AutomaticZenRule.Builder("rule", CONDITION_ID) .setConfigurationActivity(new ComponentName(mPkg, "cls")) .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) .build(), ORIGIN_APP, "reason", CUSTOM_PKG_UID); assertThat(getZenRule(rule).lastManualActivation).isNull(); assertThat(getZenRule(rule).lastManualDeactivation).isNull(); Instant manualOn = Instant.ofEpochMilli(100); mTestClock.setNow(manualOn); mZenModeHelper.setAutomaticZenRuleState(UserHandle.CURRENT, rule, new Condition(CONDITION_ID, "on", STATE_TRUE, SOURCE_USER_ACTION), ORIGIN_USER_IN_APP, CUSTOM_PKG_UID); assertThat(getZenRule(rule).lastManualActivation).isEqualTo(manualOn); assertThat(getZenRule(rule).lastManualDeactivation).isNull(); Instant manualOff = Instant.ofEpochMilli(200); mTestClock.setNow(manualOff); mZenModeHelper.setAutomaticZenRuleState(UserHandle.CURRENT, rule, new Condition(CONDITION_ID, "off", STATE_FALSE, SOURCE_USER_ACTION), ORIGIN_USER_IN_APP, CUSTOM_PKG_UID); assertThat(getZenRule(rule).lastManualActivation).isEqualTo(manualOn); assertThat(getZenRule(rule).lastManualDeactivation).isEqualTo(manualOff); Instant autoOn = Instant.ofEpochMilli(300); mTestClock.setNow(autoOn); mZenModeHelper.setAutomaticZenRuleState(UserHandle.CURRENT, rule, new Condition(CONDITION_ID, "auto on", STATE_TRUE, SOURCE_CONTEXT), ORIGIN_APP, CUSTOM_PKG_UID); Instant autoOff = Instant.ofEpochMilli(400); mTestClock.setNow(autoOff); mZenModeHelper.setAutomaticZenRuleState(UserHandle.CURRENT, rule, new Condition(CONDITION_ID, "auto off", STATE_FALSE, SOURCE_CONTEXT), ORIGIN_APP, CUSTOM_PKG_UID); assertThat(getZenRule(rule).lastManualActivation).isEqualTo(manualOn); assertThat(getZenRule(rule).lastManualDeactivation).isEqualTo(manualOff); assertThat(getZenRule(rule).lastActivation).isEqualTo(autoOn); assertThat(getZenRule(rule).lastDeactivation).isEqualTo(autoOff); } @Test @EnableFlags({FLAG_MODES_UI, FLAG_MODES_CLEANUP_IMPLICIT, FLAG_MODES_UI_TILE_REACTIVATES_LAST}) public void setManualZenMode_updatesLastActivation() { Loading