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

Commit c5c33031 authored by Sam Mortimer's avatar Sam Mortimer Committed by Gerrit Code Review
Browse files

[2/2] Permit home button wake to be configurable

Change-Id: Ie52247d5c23c8f840ababc880dd41992049cefd1
parent f90658c5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2812,6 +2812,12 @@ public final class Settings {
         */
        public static final String MENU_UNLOCK_SCREEN = "menu_unlock_screen";

        /**
         * Whether to wake the screen with the home key, the value is boolean.
         * @hide
         */
        public static final String HOME_WAKE_SCREEN = "home_wake_screen";

        /**
         * Whether to wake the screen with the volume keys, the value is boolean.
         * @hide
+23 −0
Original line number Diff line number Diff line
@@ -380,6 +380,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    WindowState mFocusedWindow;
    IApplicationToken mFocusedApp;

    // Behavior of home wake
    boolean mHomeWakeScreen;

    // Behavior of volume wake
    boolean mVolumeWakeScreen;

@@ -625,6 +628,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.Secure.getUriFor(
                    Settings.Secure.RING_HOME_BUTTON_BEHAVIOR), false, this,
                    UserHandle.USER_ALL);
            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);
@@ -1327,6 +1333,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Settings.Secure.RING_HOME_BUTTON_BEHAVIOR,
                    Settings.Secure.RING_HOME_BUTTON_BEHAVIOR_DEFAULT,
                    UserHandle.USER_CURRENT);
            mHomeWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.HOME_WAKE_SCREEN, 1, UserHandle.USER_CURRENT) == 1);
            mVolumeWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.VOLUME_WAKE_SCREEN, 0, UserHandle.USER_CURRENT) == 1);
            mVolBtnMusicControls = (Settings.System.getIntForUser(resolver,
@@ -3935,6 +3943,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                }
                break;
            }
            case KeyEvent.KEYCODE_HOME:
                if (down && !isScreenOn && mHomeWakeScreen) {
                    if (keyguardActive) {
                        // If the keyguard is showing, let it wake the device when ready.
                        mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode);
                    } else {
                        // Otherwise, wake the device ourselves.
                        result |= ACTION_WAKE_UP;
                    }
                }
                break;
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_MUTE: {
@@ -4180,6 +4199,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            case KeyEvent.KEYCODE_CAMERA:
                return false;

            // home wake can be configurable so default to no here
            case KeyEvent.KEYCODE_HOME:
                return false;
        }
        return true;
    }