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

Commit 6fa97d3d authored by Martin Brabham's avatar Martin Brabham Committed by Steve Kondik
Browse files

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

Change-Id: If9a61cd65553bf00f0efda1a75b1ab75b9129090
parent 7992da0d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2627,6 +2627,13 @@ public final class Settings {
         */
        public static final String VOLBTN_MUSIC_CONTROLS = "volbtn_music_controls";

        /**
         * 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
@@ -1831,6 +1831,9 @@ public class KeyEvent extends InputEvent implements Parcelable {
            case KeyEvent.KEYCODE_HOME:
            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
@@ -476,6 +476,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mVolBtnMusicControls;
    boolean mIsLongPress;

    // Volume wake control flag
    boolean mVolumeWakeScreen;

    PointerLocationView mPointerLocationView;

    // The current size of the screen; really; extends into the overscan area of
@@ -856,7 +859,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();
        }

@@ -2137,6 +2142,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);

        }
        synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
            PolicyControl.reloadFromSetting(mContext);
@@ -5731,7 +5741,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: