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

Commit 049981cb authored by Clyde Tan's avatar Clyde Tan Committed by Steve Kondik
Browse files

Keep quiet when volume keys are used to wake up device

- Userspace will make a 'beep' with it receives a key up, so
  consume that event as well.
- Removed wake key check in music control code as it will already
  be disabled here.

Change-Id: I93839acd39aec8a2ee40291f833a31f6b048c9f8
parent 05ffb482
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -403,6 +403,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mMenuWakeScreen;
    boolean mVolumeWakeScreen;

    // During wakeup by volume keys, we still need to capture subsequent events
    // until the key is released. This is required since the beep sound is produced
    // post keypressed.
    boolean mVolumeWakeTriggered;

    int mPointerLocationMode = 0; // guarded by mLock

    int mLongPressPoweronTime = DEFAULT_LONG_PRESS_POWERON_TIME;
@@ -4958,6 +4963,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_MUTE: {
                // Eat all down & up keys when using volume wake.
                // This disables volume control, music control, and "beep" on key up.
                if (isWakeKey && mVolumeWakeScreen) {
                    mVolumeWakeTriggered = true;
                    break;
                } else if (mVolumeWakeTriggered && !down) {
                    result &= ~ACTION_PASS_TO_USER;
                    mVolumeWakeTriggered = false;
                    break;
                }

                if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
                    if (down) {
                        if (interactive && !mVolumeDownKeyTriggered
@@ -5021,8 +5037,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    }
                }

                // Disable music and volume control when used as wake key
                if ((result & ACTION_PASS_TO_USER) == 0 && !mVolumeWakeScreen) {
                if ((result & ACTION_PASS_TO_USER) == 0) {
                    boolean mayChangeVolume = false;

                    if (isMusicActive()) {