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

Commit 75f8b876 authored by Jonas Larsson's avatar Jonas Larsson
Browse files

Notification Power Widget: Fix silent mode detection

Recent upstream changes have broken detection of silent mode, so
when for example using the device vol keys to set silent mode the
wrong icon is displayed.
This is caused by a faulty assumption about vibration modes. When
ringer mode is set to silent, vibration mode is ignored by Android.
Thus, when comparing Ringers we can not compare vibration modes when
ringer mode is silent. This has been true since API level 1 but since
Google never can seem to decide how to handle silent/vibrate/ring
consistently it's understandable that bugs like this happen.

Change-Id: Ie3daddd51a7bba0dea86f3f58f6963d22e34cc6d
parent f9d6bed4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -233,6 +233,13 @@ public class SoundButton extends PowerButton {
            }

            Ringer r = (Ringer) o;
            // Silent mode docs: "Ringer mode that will be silent and will not
            // vibrate. (This overrides the vibrate setting.)" If silent mode is
            // set, don't bother checking vibrate since silent overrides. This
            // fixes cases where silent mode is not detected because of "wrong"
            // vibrate state.
            if (mRingerMode == AudioManager.RINGER_MODE_SILENT && (r.mRingerMode == mRingerMode))
                return true;
            return r.mVibrateInSilent == mVibrateInSilent && r.mVibrateSetting == mVibrateSetting
                    && r.mRingerMode == mRingerMode;
        }