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

Commit 4f8b0224 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Update equals and hashCode methods of NoMan.Policy

Test: atest AudioManagerTest#testPriorityOnlyChannelsCanBypassDnd
Bug: 142395610
Bug: 142643922
Change-Id: I15835f784ba73b40eccf92a0a430905d28647669
parent cabc32d2
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1772,7 +1772,7 @@ public class NotificationManager {
        @Override
        public int hashCode() {
            return Objects.hash(priorityCategories, priorityCallSenders, priorityMessageSenders,
                    suppressedVisualEffects);
                    suppressedVisualEffects, state);
        }

        @Override
@@ -1784,10 +1784,10 @@ public class NotificationManager {
                    && other.priorityCallSenders == priorityCallSenders
                    && other.priorityMessageSenders == priorityMessageSenders
                    && suppressedVisualEffectsEqual(suppressedVisualEffects,
                    other.suppressedVisualEffects);
                    other.suppressedVisualEffects)
                    && other.state == this.state;
        }


        private boolean suppressedVisualEffectsEqual(int suppressedEffects,
                int otherSuppressedVisualEffects) {
            if (suppressedEffects == otherSuppressedVisualEffects) {
+10 −5
Original line number Diff line number Diff line
@@ -3896,8 +3896,7 @@ public class AudioService extends IAudioService.Stub
        final boolean muteSystem = (zenPolicy.priorityCategories
                & NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM) == 0;
        final boolean muteNotificationAndRing = ZenModeConfig
                .areAllPriorityOnlyRingerSoundsMuted(
                        mNm.getConsolidatedNotificationPolicy());
                .areAllPriorityOnlyRingerSoundsMuted(zenPolicy);
        return muteAlarms && isAlarm(streamType)
                || muteMedia && isMedia(streamType)
                || muteSystem && isSystem(streamType)
@@ -3910,11 +3909,12 @@ public class AudioService extends IAudioService.Stub

    /**
     * Notifications, ringer and system sounds are controlled by the ringer:
     * {@link ZenModeHelper.RingerModeDelegate#getRingerModeAffectedStreams(int)}
     * {@link ZenModeHelper.RingerModeDelegate#getRingerModeAffectedStreams(int)} but can
     * also be muted by DND based on the DND mode:
     * DND total silence: media and alarms streams can be muted by DND
     * DND alarms only: no streams additionally controlled by DND
     * DND priority only: alarms, media, system streams can be muted by DND based on
     * zenPolicy (this method determines which streams)
     * DND priority only: alarms, media, system, ringer and notification streams can be muted by
     * DND.  The current applied zenPolicy determines which streams will be muted by DND.
     * @return true if changed, else false
     */
    private boolean updateZenModeAffectedStreams() {
@@ -3946,6 +3946,11 @@ public class AudioService extends IAudioService.Stub
                    & NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM) == 0) {
                zenModeAffectedStreams |= 1 << AudioManager.STREAM_SYSTEM;
            }

            if (ZenModeConfig.areAllPriorityOnlyRingerSoundsMuted(zenPolicy)) {
                zenModeAffectedStreams |= 1 << AudioManager.STREAM_NOTIFICATION;
                zenModeAffectedStreams |= 1 << AudioManager.STREAM_RING;
            }
        }

        if (mZenModeAffectedStreams != zenModeAffectedStreams) {
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ public class ZenModeConfigTest extends UiServiceTestCase {
        suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_AMBIENT;

        Policy expectedPolicy = new Policy(priorityCategories, priorityCallSenders,
                priorityMessageSenders, suppressedVisualEffects);
                priorityMessageSenders, suppressedVisualEffects, 0);

        assertEquals(expectedPolicy, config.toNotificationPolicy(zenPolicy));
    }