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

Commit 9e4214db authored by Beverly's avatar Beverly
Browse files

Priority only dnd doesn't change ringer

Streams are muted in AudioService#muteRingerModeStreams,
so there's no need to change the ringer when entering
priority only dnd.  Note: total silence and alarms only will
still change the ringer to silent.

Fixes: 76152626
Test: ZenModeHelperTest
Test: manual (toggle dnd on when ringer set to vibrate/normal
and observe the ringer icon remains the same with dnd badge)

Change-Id: I56cb90928362c18f8bae60c17f313a8a2621dd28
parent b133cbfd
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.volume;

import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_ALL_MASK;
import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_GENERIC;
import static android.media.AudioManager.RINGER_MODE_MAX;
import static android.media.AudioManager.RINGER_MODE_NORMAL;
import static android.media.AudioManager.RINGER_MODE_SILENT;
import static android.media.AudioManager.RINGER_MODE_VIBRATE;
@@ -570,7 +569,11 @@ public class VolumeDialogImpl implements VolumeDialog {
                return;
            }

            enableRingerViewsH(mState.zenMode == Global.ZEN_MODE_OFF || !mState.disallowRinger);
            boolean isZenMuted = mState.zenMode == Global.ZEN_MODE_ALARMS
                    || mState.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS
                    || (mState.zenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
                        && mState.disallowRinger);
            enableRingerViewsH(!isZenMuted);
            switch (mState.ringerModeInternal) {
                case AudioManager.RINGER_MODE_VIBRATE:
                    mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_vibrate);
@@ -586,7 +589,7 @@ public class VolumeDialogImpl implements VolumeDialog {
                case AudioManager.RINGER_MODE_NORMAL:
                default:
                    boolean muted = (mAutomute && ss.level == 0) || ss.muted;
                    if (muted) {
                    if (!isZenMuted && muted) {
                        mRingerIcon.setImageResource(R.drawable.ic_volume_ringer_mute);
                        mRingerIcon.setContentDescription(mContext.getString(
                                R.string.volume_stream_content_description_unmute,
+1 −5
Original line number Diff line number Diff line
@@ -933,11 +933,7 @@ public class ZenModeHelper {
                }
                break;
            case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
                if (ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(mConfig)
                        && ringerModeInternal != AudioManager.RINGER_MODE_SILENT) {
                    setPreviousRingerModeSetting(ringerModeInternal);
                    newRingerModeInternal = AudioManager.RINGER_MODE_SILENT;
                }
                // do not apply zen to ringer, streams zen muted in AudioService
                break;
            case Global.ZEN_MODE_OFF:
                if (ringerModeInternal == AudioManager.RINGER_MODE_SILENT) {
+3 −3
Original line number Diff line number Diff line
@@ -329,12 +329,12 @@ public class ZenModeHelperTest extends UiServiceTestCase {
        mZenModeHelperSpy.mConfig.allowEvents = false;
        mZenModeHelperSpy.mConfig.allowRepeatCallers= false;

        // 2. apply priority only zen - verify ringer is set to silent
        // 2. apply priority only zen - verify ringer is unchanged
        mZenModeHelperSpy.applyZenToRingerMode();
        verify(mAudioManager, atLeastOnce()).setRingerModeInternal(AudioManager.RINGER_MODE_SILENT,
        verify(mAudioManager, never()).setRingerModeInternal(AudioManager.RINGER_MODE_SILENT,
                mZenModeHelperSpy.TAG);

        // 3. apply zen off - verify zen is set to prevoius ringer (normal)
        // 3. apply zen off - verify zen is set to previous ringer (normal)
        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
        mZenModeHelperSpy.mZenMode = Global.ZEN_MODE_OFF;
        mZenModeHelperSpy.applyZenToRingerMode();