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

Commit d0ac1031 authored by Martin Brabham's avatar Martin Brabham Committed by Matt Garnes
Browse files

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

Change-Id: I2dfb1407738fe6a9af39c543a3a993879a2178f9
parent 2f076731
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -2142,6 +2142,13 @@ public final class Settings {
         */
         */
        public static final String VOLUME_MASTER_MUTE = "volume_master_mute";
        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).
         * Microphone mute (int 1 = mute, 0 = not muted).
         *
         *
+3 −0
Original line number Original line Diff line number Diff line
@@ -1809,6 +1809,9 @@ public class KeyEvent extends InputEvent implements Parcelable {
            case KeyEvent.KEYCODE_SLEEP:
            case KeyEvent.KEYCODE_SLEEP:
            case KeyEvent.KEYCODE_WAKEUP:
            case KeyEvent.KEYCODE_WAKEUP:
            case KeyEvent.KEYCODE_PAIRING:
            case KeyEvent.KEYCODE_PAIRING:
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE:
                return true;
                return true;
        }
        }
        return false;
        return false;
+12 −1
Original line number Original line Diff line number Diff line
@@ -387,6 +387,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    WindowState mFocusedWindow;
    WindowState mFocusedWindow;
    IApplicationToken mFocusedApp;
    IApplicationToken mFocusedApp;


    // Volume wake control flag
    boolean mVolumeWakeScreen;

    PointerLocationView mPointerLocationView;
    PointerLocationView mPointerLocationView;


    // The current size of the screen; really; extends into the overscan area of
    // The current size of the screen; really; extends into the overscan area of
@@ -697,6 +700,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.Global.getUriFor(
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.POLICY_CONTROL), false, this,
                    Settings.Global.POLICY_CONTROL), false, this,
                    UserHandle.USER_ALL);
                    UserHandle.USER_ALL);
           resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.VOLUME_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
            updateSettings();
            updateSettings();
        }
        }


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

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

            PolicyControl.reloadFromSetting(mContext);
            PolicyControl.reloadFromSetting(mContext);
        }
        }
        if (updateRotation) {
        if (updateRotation) {
@@ -4889,7 +4900,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE:
            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
            // ignore media and camera keys
            case KeyEvent.KEYCODE_MUTE:
            case KeyEvent.KEYCODE_MUTE: