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

Commit fedeb99f authored by Martin Brabham's avatar Martin Brabham Committed by Martin Brabham
Browse files

Android Policy: handle volume key event as wake key when preference is set

Change-Id: If9a61cd65553bf00f0efda1a75b1ab75b9129090
parent 5c25d5cc
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2183,6 +2183,13 @@ public final class Settings {
         */
        public static final String VOLUME_MASTER_MUTE = "volume_master_mute";

        /**
         * Whether to wake the screen with the volume keys, the value is boolean.
         *
         * @hide
         */
        public static final String VOLUME_WAKE_SCREEN = "volume_wake_screen";

        /**
         * Microphone mute (int 1 = mute, 0 = not muted).
         *
+3 −0
Original line number Diff line number Diff line
@@ -1809,6 +1809,9 @@ public class KeyEvent extends InputEvent implements Parcelable {
            case KeyEvent.KEYCODE_SLEEP:
            case KeyEvent.KEYCODE_WAKEUP:
            case KeyEvent.KEYCODE_PAIRING:
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE:
                return true;
        }
        return false;
+12 −2
Original line number Diff line number Diff line
@@ -406,6 +406,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    WindowState mFocusedWindow;
    IApplicationToken mFocusedApp;

    // Volume wake control flag
    boolean mVolumeWakeScreen;

    PointerLocationView mPointerLocationView;

    // The current size of the screen; really; extends into the overscan area of
@@ -734,7 +737,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.HOME_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);

            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.VOLUME_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
            updateSettings();
        }

@@ -1690,6 +1695,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            if (mImmersiveModeConfirmation != null) {
                mImmersiveModeConfirmation.loadSetting(mCurrentUserId);
            }

            // Volume wake
            mVolumeWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.VOLUME_WAKE_SCREEN, 0, UserHandle.USER_CURRENT) == 1);

            PolicyControl.reloadFromSetting(mContext);
        }
        if (updateRotation) {
@@ -5140,7 +5150,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE:
                return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED;
                return mVolumeWakeScreen || mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED;

            // ignore media and camera keys
            case KeyEvent.KEYCODE_MUTE: