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

Unverified Commit ee1cbd5c authored by Aaron Kling's avatar Aaron Kling Committed by Michael Bestas
Browse files

PhoneWindowManager: Support volume up/down to mute

For Android TV, some remotes don't have a mute button. Allow the two
button combo volume up and down to trigger mute. This mirros what Nvidia
does downstream.

Change-Id: If906bbda66689ffa5aefb9e64e7c542f8e82560f
parent f3184f45
Loading
Loading
Loading
Loading
+42 −16
Original line number Diff line number Diff line
@@ -699,6 +699,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    // Click volume down + power for partial screenshot
    boolean mClickPartialScreenshot;

    // Volume Up and Down to mute on Android TV
    boolean mVolUpAndDownMute;

    private boolean mPendingKeyguardOccluded;
    private boolean mKeyguardOccludedChanged;

@@ -1121,6 +1124,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(LineageSettings.System.getUriFor(
                    LineageSettings.System.VOLUME_ANSWER_CALL), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(LineageSettings.System.getUriFor(
                    LineageSettings.System.VOLUME_UP_AND_DOWN_MUTE), false, this,
                    UserHandle.USER_ALL);
            updateSettings();
        }

@@ -2927,6 +2933,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            }
        }

        if (mHasFeatureLeanback) {
            mKeyCombinationManager.addRule(
                    new TwoKeysCombinationRule(KEYCODE_VOLUME_DOWN, KEYCODE_VOLUME_UP) {
                        @Override
                        public boolean preCondition() {
                            return mVolUpAndDownMute;
                        }
                        @Override
                        public void execute() {
                            triggerVirtualKeypress(KeyEvent.KEYCODE_VOLUME_MUTE);
                        }
                        @Override
                        public void cancel() {
                        }
                    });
        } else {
            mKeyCombinationManager.addRule(
                    new TwoKeysCombinationRule(KEYCODE_VOLUME_DOWN, KEYCODE_VOLUME_UP) {
                        @Override
@@ -2943,6 +2965,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            cancelPendingAccessibilityShortcutAction();
                        }
                    });
        }

        // Volume up + power can either be the "ringer toggle chord" or as another way to
        // launch GlobalActions. This behavior can change at runtime so we must check behavior
@@ -3493,6 +3516,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mCameraLaunch = LineageSettings.System.getIntForUser(resolver,
                    LineageSettings.System.CAMERA_LAUNCH, 0,
                    UserHandle.USER_CURRENT) == 1;
            mVolUpAndDownMute = LineageSettings.System.getIntForUser(resolver,
                    LineageSettings.System.VOLUME_UP_AND_DOWN_MUTE, 0,
                    UserHandle.USER_CURRENT) == 1;

            // Configure wake gesture.
            boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver,