Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicyTest.kt +0 −11 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.statusbar.StatusBarIcon import com.android.settingslib.notification.modes.TestModeBuilder import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.display.domain.interactor.ConnectedDisplayInteractor Loading Loading @@ -480,8 +479,6 @@ class PhoneStatusBarPolicyTest : SysuiTestCase() { override fun getZen(): Int = zen override fun getManualRule(): ZenModeConfig.ZenRule = throw NotImplementedError() override fun getConfig(): ZenModeConfig = throw NotImplementedError() override fun getConsolidatedPolicy(): NotificationManager.Policy = consolidatedPolicy Loading @@ -490,14 +487,6 @@ class PhoneStatusBarPolicyTest : SysuiTestCase() { override fun isZenAvailable() = throw NotImplementedError() override fun getEffectsSuppressor() = throw NotImplementedError() override fun isCountdownConditionSupported() = throw NotImplementedError() override fun getCurrentUser() = throw NotImplementedError() override fun isVolumeRestricted() = throw NotImplementedError() override fun areNotificationsHiddenInShade() = throw NotImplementedError() } } packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/ZenModeControllerImplTest.kt +0 −39 Original line number Diff line number Diff line Loading @@ -90,45 +90,6 @@ class ZenModeControllerImplTest : SysuiTestCase() { Mockito.verify(mockCallback).onConfigChanged(ArgumentMatchers.eq(config)) } @Test fun testAreNotificationsHiddenInShade_zenOffShadeSuppressed() { config.suppressedVisualEffects = NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST controller.updateZenMode(Settings.Global.ZEN_MODE_OFF) controller.updateZenModeConfig() assertThat(controller.areNotificationsHiddenInShade()).isFalse() } @Test fun testAreNotificationsHiddenInShade_zenOnShadeNotSuppressed() { val policy = NotificationManager.Policy( 0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR, ) whenever(mNm.consolidatedNotificationPolicy).thenReturn(policy) controller.updateConsolidatedNotificationPolicy() controller.updateZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) assertThat(controller.areNotificationsHiddenInShade()).isFalse() } @Test fun testAreNotificationsHiddenInShade_zenOnShadeSuppressed() { val policy = NotificationManager.Policy( 0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST, ) whenever(mNm.consolidatedNotificationPolicy).thenReturn(policy) controller.updateConsolidatedNotificationPolicy() controller.updateZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) assertThat(controller.areNotificationsHiddenInShade()).isTrue() } @Test fun testModeChange() = testScope.runTest { Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java +0 −11 Original line number Diff line number Diff line Loading @@ -17,11 +17,8 @@ package com.android.systemui.statusbar.policy; import android.app.NotificationManager; import android.content.ComponentName; import android.net.Uri; import android.service.notification.Condition; import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig.ZenRule; import com.android.systemui.statusbar.policy.ZenModeController.Callback; import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor; Loading @@ -35,25 +32,17 @@ import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor public interface ZenModeController extends CallbackController<Callback> { void setZen(int zen, Uri conditionId, String reason); int getZen(); ZenRule getManualRule(); ZenModeConfig getConfig(); /** Gets consolidated zen policy that will apply when DND is on in priority only mode */ NotificationManager.Policy getConsolidatedPolicy(); long getNextAlarm(); boolean isZenAvailable(); ComponentName getEffectsSuppressor(); boolean isCountdownConditionSupported(); int getCurrentUser(); boolean isVolumeRestricted(); boolean areNotificationsHiddenInShade(); public static interface Callback { default void onZenChanged(int zen) {} default void onConditionsChanged(Condition[] conditions) {} default void onNextAlarmChanged() {} default void onZenAvailableChanged(boolean available) {} default void onEffectsSupressorChanged() {} default void onManualRuleChanged(ZenRule rule) {} default void onConfigChanged(ZenModeConfig config) {} /** Called when the consolidated zen policy changes */ default void onConsolidatedPolicyChanged(NotificationManager.Policy policy) {} Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java +0 −51 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.AlarmManager; import android.app.Flags; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; Loading @@ -35,7 +34,6 @@ import android.os.UserManager; import android.provider.Settings.Global; import android.provider.Settings.Secure; import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig.ZenRule; import android.text.format.DateFormat; import android.util.Log; Loading Loading @@ -92,7 +90,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { } final IntentFilter filter = new IntentFilter( AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED); filter.addAction(NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED); mBroadcastDispatcher.registerReceiver(mReceiver, filter, null, UserHandle.of(mUserId)); mRegistered = true; Loading Loading @@ -155,21 +152,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { return mGlobalSettings.getInt(Global.ZEN_MODE, /* default */ Global.ZEN_MODE_OFF); } @Override public boolean isVolumeRestricted() { return mUserManager.hasUserRestriction(UserManager.DISALLOW_ADJUST_VOLUME, UserHandle.of(mUserId)); } @Override public boolean areNotificationsHiddenInShade() { if (mZenMode != Global.ZEN_MODE_OFF) { return (mConsolidatedNotificationPolicy.suppressedVisualEffects & NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST) != 0; } return false; } @Override public void addCallback(@NonNull Callback callback) { synchronized (mCallbacksLock) { Loading Loading @@ -205,11 +187,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { return mSetupObserver.isDeviceProvisioned() && mSetupObserver.isUserSetup(); } @Override public ZenRule getManualRule() { return mConfig == null ? null : mConfig.manualRule; } @Override public ZenModeConfig getConfig() { return mConfig; Loading @@ -227,17 +204,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { return info != null ? info.getTriggerTime() : 0; } @Override public ComponentName getEffectsSuppressor() { return NotificationManager.from(mContext).getEffectsSuppressor(); } @Override public boolean isCountdownConditionSupported() { return NotificationManager.from(mContext) .isSystemConditionProviderEnabled(ZenModeConfig.COUNTDOWN_PATH); } @Override public int getCurrentUser() { return mUserTracker.getUserId(); Loading @@ -247,10 +213,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { fireSafeChange(Callback::onNextAlarmChanged); } private void fireEffectsSuppressorChanged() { fireSafeChange(Callback::onEffectsSupressorChanged); } private void fireZenChanged(int zen) { fireSafeChange(c -> c.onZenChanged(zen)); } Loading @@ -259,10 +221,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { fireSafeChange(c -> c.onZenAvailableChanged(available)); } private void fireManualRuleChanged(ZenRule rule) { fireSafeChange(c -> c.onManualRuleChanged(rule)); } private void fireConsolidatedPolicyChanged(NotificationManager.Policy policy) { fireSafeChange(c -> c.onConsolidatedPolicyChanged(policy)); } Loading Loading @@ -302,16 +260,10 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { protected void updateZenModeConfig() { final ZenModeConfig config = mNoMan.getZenModeConfig(); if (Objects.equals(config, mConfig)) return; final ZenRule oldRule = mConfig != null ? mConfig.manualRule : null; mConfig = config; mZenUpdateTime = System.currentTimeMillis(); fireConfigChanged(config); final ZenRule newRule = config != null ? config.manualRule : null; if (!Objects.equals(oldRule, newRule)) { fireManualRuleChanged(newRule); } final NotificationManager.Policy consolidatedPolicy = mNoMan.getConsolidatedNotificationPolicy(); if (!Objects.equals(consolidatedPolicy, mConsolidatedNotificationPolicy)) { Loading @@ -327,9 +279,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { if (AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED.equals(intent.getAction())) { fireNextAlarmChanged(); } if (NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED.equals(intent.getAction())) { fireEffectsSuppressorChanged(); } } }; Loading packages/SystemUI/tests/utils/src/com/android/systemui/utils/leaks/FakeZenModeController.java +0 −27 Original line number Diff line number Diff line Loading @@ -15,10 +15,8 @@ package com.android.systemui.utils.leaks; import android.app.NotificationManager; import android.content.ComponentName; import android.net.Uri; import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig.ZenRule; import android.testing.LeakCheck; import com.android.systemui.statusbar.policy.ZenModeController; Loading @@ -39,11 +37,6 @@ public class FakeZenModeController extends BaseLeakChecker<Callback> implements return 0; } @Override public ZenRule getManualRule() { return null; } @Override public ZenModeConfig getConfig() { return null; Loading @@ -64,28 +57,8 @@ public class FakeZenModeController extends BaseLeakChecker<Callback> implements return false; } @Override public ComponentName getEffectsSuppressor() { return null; } @Override public boolean isCountdownConditionSupported() { return false; } @Override public int getCurrentUser() { return 0; } @Override public boolean isVolumeRestricted() { return false; } @Override public boolean areNotificationsHiddenInShade() { return false; } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicyTest.kt +0 −11 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.statusbar.StatusBarIcon import com.android.settingslib.notification.modes.TestModeBuilder import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.display.domain.interactor.ConnectedDisplayInteractor Loading Loading @@ -480,8 +479,6 @@ class PhoneStatusBarPolicyTest : SysuiTestCase() { override fun getZen(): Int = zen override fun getManualRule(): ZenModeConfig.ZenRule = throw NotImplementedError() override fun getConfig(): ZenModeConfig = throw NotImplementedError() override fun getConsolidatedPolicy(): NotificationManager.Policy = consolidatedPolicy Loading @@ -490,14 +487,6 @@ class PhoneStatusBarPolicyTest : SysuiTestCase() { override fun isZenAvailable() = throw NotImplementedError() override fun getEffectsSuppressor() = throw NotImplementedError() override fun isCountdownConditionSupported() = throw NotImplementedError() override fun getCurrentUser() = throw NotImplementedError() override fun isVolumeRestricted() = throw NotImplementedError() override fun areNotificationsHiddenInShade() = throw NotImplementedError() } }
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/ZenModeControllerImplTest.kt +0 −39 Original line number Diff line number Diff line Loading @@ -90,45 +90,6 @@ class ZenModeControllerImplTest : SysuiTestCase() { Mockito.verify(mockCallback).onConfigChanged(ArgumentMatchers.eq(config)) } @Test fun testAreNotificationsHiddenInShade_zenOffShadeSuppressed() { config.suppressedVisualEffects = NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST controller.updateZenMode(Settings.Global.ZEN_MODE_OFF) controller.updateZenModeConfig() assertThat(controller.areNotificationsHiddenInShade()).isFalse() } @Test fun testAreNotificationsHiddenInShade_zenOnShadeNotSuppressed() { val policy = NotificationManager.Policy( 0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_STATUS_BAR, ) whenever(mNm.consolidatedNotificationPolicy).thenReturn(policy) controller.updateConsolidatedNotificationPolicy() controller.updateZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) assertThat(controller.areNotificationsHiddenInShade()).isFalse() } @Test fun testAreNotificationsHiddenInShade_zenOnShadeSuppressed() { val policy = NotificationManager.Policy( 0, 0, 0, NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST, ) whenever(mNm.consolidatedNotificationPolicy).thenReturn(policy) controller.updateConsolidatedNotificationPolicy() controller.updateZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) assertThat(controller.areNotificationsHiddenInShade()).isTrue() } @Test fun testModeChange() = testScope.runTest { Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java +0 −11 Original line number Diff line number Diff line Loading @@ -17,11 +17,8 @@ package com.android.systemui.statusbar.policy; import android.app.NotificationManager; import android.content.ComponentName; import android.net.Uri; import android.service.notification.Condition; import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig.ZenRule; import com.android.systemui.statusbar.policy.ZenModeController.Callback; import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor; Loading @@ -35,25 +32,17 @@ import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor public interface ZenModeController extends CallbackController<Callback> { void setZen(int zen, Uri conditionId, String reason); int getZen(); ZenRule getManualRule(); ZenModeConfig getConfig(); /** Gets consolidated zen policy that will apply when DND is on in priority only mode */ NotificationManager.Policy getConsolidatedPolicy(); long getNextAlarm(); boolean isZenAvailable(); ComponentName getEffectsSuppressor(); boolean isCountdownConditionSupported(); int getCurrentUser(); boolean isVolumeRestricted(); boolean areNotificationsHiddenInShade(); public static interface Callback { default void onZenChanged(int zen) {} default void onConditionsChanged(Condition[] conditions) {} default void onNextAlarmChanged() {} default void onZenAvailableChanged(boolean available) {} default void onEffectsSupressorChanged() {} default void onManualRuleChanged(ZenRule rule) {} default void onConfigChanged(ZenModeConfig config) {} /** Called when the consolidated zen policy changes */ default void onConsolidatedPolicyChanged(NotificationManager.Policy policy) {} Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java +0 −51 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.AlarmManager; import android.app.Flags; import android.app.NotificationManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; Loading @@ -35,7 +34,6 @@ import android.os.UserManager; import android.provider.Settings.Global; import android.provider.Settings.Secure; import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig.ZenRule; import android.text.format.DateFormat; import android.util.Log; Loading Loading @@ -92,7 +90,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { } final IntentFilter filter = new IntentFilter( AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED); filter.addAction(NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED); mBroadcastDispatcher.registerReceiver(mReceiver, filter, null, UserHandle.of(mUserId)); mRegistered = true; Loading Loading @@ -155,21 +152,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { return mGlobalSettings.getInt(Global.ZEN_MODE, /* default */ Global.ZEN_MODE_OFF); } @Override public boolean isVolumeRestricted() { return mUserManager.hasUserRestriction(UserManager.DISALLOW_ADJUST_VOLUME, UserHandle.of(mUserId)); } @Override public boolean areNotificationsHiddenInShade() { if (mZenMode != Global.ZEN_MODE_OFF) { return (mConsolidatedNotificationPolicy.suppressedVisualEffects & NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST) != 0; } return false; } @Override public void addCallback(@NonNull Callback callback) { synchronized (mCallbacksLock) { Loading Loading @@ -205,11 +187,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { return mSetupObserver.isDeviceProvisioned() && mSetupObserver.isUserSetup(); } @Override public ZenRule getManualRule() { return mConfig == null ? null : mConfig.manualRule; } @Override public ZenModeConfig getConfig() { return mConfig; Loading @@ -227,17 +204,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { return info != null ? info.getTriggerTime() : 0; } @Override public ComponentName getEffectsSuppressor() { return NotificationManager.from(mContext).getEffectsSuppressor(); } @Override public boolean isCountdownConditionSupported() { return NotificationManager.from(mContext) .isSystemConditionProviderEnabled(ZenModeConfig.COUNTDOWN_PATH); } @Override public int getCurrentUser() { return mUserTracker.getUserId(); Loading @@ -247,10 +213,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { fireSafeChange(Callback::onNextAlarmChanged); } private void fireEffectsSuppressorChanged() { fireSafeChange(Callback::onEffectsSupressorChanged); } private void fireZenChanged(int zen) { fireSafeChange(c -> c.onZenChanged(zen)); } Loading @@ -259,10 +221,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { fireSafeChange(c -> c.onZenAvailableChanged(available)); } private void fireManualRuleChanged(ZenRule rule) { fireSafeChange(c -> c.onManualRuleChanged(rule)); } private void fireConsolidatedPolicyChanged(NotificationManager.Policy policy) { fireSafeChange(c -> c.onConsolidatedPolicyChanged(policy)); } Loading Loading @@ -302,16 +260,10 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { protected void updateZenModeConfig() { final ZenModeConfig config = mNoMan.getZenModeConfig(); if (Objects.equals(config, mConfig)) return; final ZenRule oldRule = mConfig != null ? mConfig.manualRule : null; mConfig = config; mZenUpdateTime = System.currentTimeMillis(); fireConfigChanged(config); final ZenRule newRule = config != null ? config.manualRule : null; if (!Objects.equals(oldRule, newRule)) { fireManualRuleChanged(newRule); } final NotificationManager.Policy consolidatedPolicy = mNoMan.getConsolidatedNotificationPolicy(); if (!Objects.equals(consolidatedPolicy, mConsolidatedNotificationPolicy)) { Loading @@ -327,9 +279,6 @@ public class ZenModeControllerImpl implements ZenModeController, Dumpable { if (AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED.equals(intent.getAction())) { fireNextAlarmChanged(); } if (NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED.equals(intent.getAction())) { fireEffectsSuppressorChanged(); } } }; Loading
packages/SystemUI/tests/utils/src/com/android/systemui/utils/leaks/FakeZenModeController.java +0 −27 Original line number Diff line number Diff line Loading @@ -15,10 +15,8 @@ package com.android.systemui.utils.leaks; import android.app.NotificationManager; import android.content.ComponentName; import android.net.Uri; import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig.ZenRule; import android.testing.LeakCheck; import com.android.systemui.statusbar.policy.ZenModeController; Loading @@ -39,11 +37,6 @@ public class FakeZenModeController extends BaseLeakChecker<Callback> implements return 0; } @Override public ZenRule getManualRule() { return null; } @Override public ZenModeConfig getConfig() { return null; Loading @@ -64,28 +57,8 @@ public class FakeZenModeController extends BaseLeakChecker<Callback> implements return false; } @Override public ComponentName getEffectsSuppressor() { return null; } @Override public boolean isCountdownConditionSupported() { return false; } @Override public int getCurrentUser() { return 0; } @Override public boolean isVolumeRestricted() { return false; } @Override public boolean areNotificationsHiddenInShade() { return false; } }