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

Commit 292fe730 authored by Michael Bestas's avatar Michael Bestas Committed by Steve Kondik
Browse files

Cleanup button wake settings (2/2)

Change-Id: Ie37136cbd57c4c334321abbfa4543727e940bc43

Keep quiet when volume keys are used to wake up device

- Userspace will make a 'beep' with it receives a key up, so
  consume that event as well.
- Removed wake key check in music control code as it will already
  be disabled here.

Change-Id: I93839acd39aec8a2ee40291f833a31f6b048c9f8

Wake Keys: enforce the wake keys overlay

* Keys disabled as wake keys by the overlay were
  still being allowed to wake the device. This change
  enforces the hardwareWakeKeys settings.

Change-Id: Ifde0491b2de64a7f61a101cf22f5589cb5e841e2

Allow disabling Search/Recents button wake (2/2)

Change-Id: I6a2ac064efc4fe85413bf0b935c28aa7bde5d672
parent 95edbdef
Loading
Loading
Loading
Loading
+31 −7
Original line number Original line Diff line number Diff line
@@ -2632,13 +2632,6 @@ public final class Settings {
         */
         */
        public static final String VOLBTN_MUSIC_CONTROLS = "volbtn_music_controls";
        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).
         * Microphone mute (int 1 = mute, 0 = not muted).
         *
         *
@@ -3624,6 +3617,19 @@ public final class Settings {
         */
         */
        public static final String HOME_WAKE_SCREEN = "home_wake_screen";
        public static final String HOME_WAKE_SCREEN = "home_wake_screen";


        /**
         * Whether to wake the screen with the assist key, the value is boolean.
         * @hide
         */
        public static final String ASSIST_WAKE_SCREEN = "assist_wake_screen";

        /**
         * Whether to wake the screen with the app switch key, the value is boolean.
         * @hide
         */
        public static final String APP_SWITCH_WAKE_SCREEN = "app_switch_wake_screen";


        /**
        /**
         * Color temperature of the display during the day
         * Color temperature of the display during the day
         * @hide
         * @hide
@@ -3707,6 +3713,24 @@ public final class Settings {
         */
         */
        public static final String VOICE_LAUNCH_INTENT = "voice_launch_intent";
        public static final String VOICE_LAUNCH_INTENT = "voice_launch_intent";


        /**
         * Whether to wake the screen with the back key, the value is boolean.
         * @hide
         */
        public static final String BACK_WAKE_SCREEN = "back_wake_screen";

        /**
         * Whether to wake the screen with the menu key, the value is boolean.
         * @hide
         */
        public static final String MENU_WAKE_SCREEN = "menu_wake_screen";

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

        /**
        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
         * keys and easy to update.
+17 −2
Original line number Original line Diff line number Diff line
@@ -958,7 +958,7 @@
    -->
    -->
    <integer name="config_longPressOnMenuBehavior">3</integer>
    <integer name="config_longPressOnMenuBehavior">3</integer>


    <!-- Hardware 'face' keys present on the device, stored as a bit field.
    <!-- Hardware keys present on the device, stored as a bit field.
         This integer should equal the sum of the corresponding value for each
         This integer should equal the sum of the corresponding value for each
         of the following keys present:
         of the following keys present:
             1 - Home
             1 - Home
@@ -967,9 +967,24 @@
             8 - Assistant (search)
             8 - Assistant (search)
            16 - App switch
            16 - App switch
            32 - Camera
            32 - Camera
            64 - Volume rocker
         For example, a device with Home, Back and Menu keys would set this
         For example, a device with Home, Back and Menu keys would set this
         config to 7. -->
         config to 7. -->
    <integer name="config_deviceHardwareKeys">15</integer>
    <integer name="config_deviceHardwareKeys">79</integer>

    <!-- Hardware keys present on the device with the ability to wake, stored as a bit field.
         This integer should equal the sum of the corresponding value for each
         of the following keys present:
             1 - Home
             2 - Back
             4 - Menu
             8 - Assistant (search)
            16 - App switch
            32 - Camera
            64 - Volume rocker
         For example, a device with Home, Back and Menu keys would set this
         config to 7. -->
    <integer name="config_deviceHardwareWakeKeys">79</integer>


    <!-- Minimum screen brightness setting allowed by the power manager.
    <!-- Minimum screen brightness setting allowed by the power manager.
         The user is forbidden from setting the brightness below this level. -->
         The user is forbidden from setting the brightness below this level. -->
+1 −0
Original line number Original line Diff line number Diff line
@@ -1532,6 +1532,7 @@
  <java-symbol type="integer" name="config_defaultUiModeType" />
  <java-symbol type="integer" name="config_defaultUiModeType" />
  <java-symbol type="integer" name="config_deskDockRotation" />
  <java-symbol type="integer" name="config_deskDockRotation" />
  <java-symbol type="integer" name="config_deviceHardwareKeys" />
  <java-symbol type="integer" name="config_deviceHardwareKeys" />
  <java-symbol type="integer" name="config_deviceHardwareWakeKeys" />
  <java-symbol type="integer" name="config_doubleTapOnHomeBehavior" />
  <java-symbol type="integer" name="config_doubleTapOnHomeBehavior" />
  <java-symbol type="integer" name="config_lidKeyboardAccessibility" />
  <java-symbol type="integer" name="config_lidKeyboardAccessibility" />
  <java-symbol type="integer" name="config_lidNavigationAccessibility" />
  <java-symbol type="integer" name="config_lidNavigationAccessibility" />
+68 −12
Original line number Original line Diff line number Diff line
@@ -234,6 +234,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private static final int KEY_MASK_ASSIST = 0x08;
    private static final int KEY_MASK_ASSIST = 0x08;
    private static final int KEY_MASK_APP_SWITCH = 0x10;
    private static final int KEY_MASK_APP_SWITCH = 0x10;
    private static final int KEY_MASK_CAMERA = 0x20;
    private static final int KEY_MASK_CAMERA = 0x20;
    private static final int KEY_MASK_VOLUME = 0x40;




    /**
    /**
@@ -461,10 +462,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mUseTvRouting;
    boolean mUseTvRouting;
    int mBackKillTimeout;
    int mBackKillTimeout;


    // Behavior of home wake
    int mDeviceHardwareKeys;

    // Button wake control flags
    boolean mHomeWakeScreen;
    boolean mHomeWakeScreen;
    boolean mBackWakeScreen;
    boolean mMenuWakeScreen;
    boolean mAssistWakeScreen;
    boolean mAppSwitchWakeScreen;
    boolean mVolumeWakeScreen;


    int mDeviceHardwareKeys;
    // During wakeup by volume keys, we still need to capture subsequent events
    // until the key is released. This is required since the beep sound is produced
    // post keypressed.
    boolean mVolumeWakeTriggered;


    int mPointerLocationMode = 0; // guarded by mLock
    int mPointerLocationMode = 0; // guarded by mLock


@@ -476,9 +487,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mVolBtnMusicControls;
    boolean mVolBtnMusicControls;
    boolean mIsLongPress;
    boolean mIsLongPress;


    // 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
@@ -856,6 +864,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.System.getUriFor(
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.USE_EDGE_SERVICE_FOR_GESTURES), false, this,
                    Settings.System.USE_EDGE_SERVICE_FOR_GESTURES), false, this,
                    UserHandle.USER_ALL);
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.BACK_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.MENU_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.ASSIST_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.APP_SWITCH_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.VOLUME_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.HOME_WAKE_SCREEN), false, this,
                    Settings.System.HOME_WAKE_SCREEN), false, this,
                    UserHandle.USER_ALL);
                    UserHandle.USER_ALL);
@@ -2023,6 +2046,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    public void updateSettings() {
    public void updateSettings() {
        ContentResolver resolver = mContext.getContentResolver();
        ContentResolver resolver = mContext.getContentResolver();
        boolean updateRotation = false;
        boolean updateRotation = false;
        int mDeviceHardwareWakeKeys = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_deviceHardwareWakeKeys);
        synchronized (mLock) {
        synchronized (mLock) {
            mEndcallBehavior = Settings.System.getIntForUser(resolver,
            mEndcallBehavior = Settings.System.getIntForUser(resolver,
                    Settings.System.END_BUTTON_BEHAVIOR,
                    Settings.System.END_BUTTON_BEHAVIOR,
@@ -2032,10 +2057,26 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT,
                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT,
                    UserHandle.USER_CURRENT);
                    UserHandle.USER_CURRENT);
            mHomeWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.HOME_WAKE_SCREEN, 1, UserHandle.USER_CURRENT) == 1) &&
                    ((mDeviceHardwareWakeKeys & KEY_MASK_HOME) != 0);
            mBackWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.BACK_WAKE_SCREEN, 0, UserHandle.USER_CURRENT) == 1) &&
                    ((mDeviceHardwareWakeKeys & KEY_MASK_BACK) != 0);
            mMenuWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.MENU_WAKE_SCREEN, 0, UserHandle.USER_CURRENT) == 1) &&
                    ((mDeviceHardwareWakeKeys & KEY_MASK_MENU) != 0);
            mAssistWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.ASSIST_WAKE_SCREEN, 0, UserHandle.USER_CURRENT) == 1) &&
                    ((mDeviceHardwareWakeKeys & KEY_MASK_ASSIST) != 0);
            mAppSwitchWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.APP_SWITCH_WAKE_SCREEN, 0, UserHandle.USER_CURRENT) == 1) &&
                    ((mDeviceHardwareWakeKeys & KEY_MASK_APP_SWITCH) != 0);
            mVolumeWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.VOLUME_WAKE_SCREEN, 0, UserHandle.USER_CURRENT) == 1) &&
                    ((mDeviceHardwareWakeKeys & KEY_MASK_VOLUME) != 0);
            mVolBtnMusicControls = (Settings.System.getIntForUser(resolver,
            mVolBtnMusicControls = (Settings.System.getIntForUser(resolver,
                    Settings.System.VOLBTN_MUSIC_CONTROLS, 1, UserHandle.USER_CURRENT) == 1);
                    Settings.System.VOLBTN_MUSIC_CONTROLS, 1, UserHandle.USER_CURRENT) == 1);
            mHomeWakeScreen = (Settings.System.getIntForUser(resolver,
                    Settings.System.HOME_WAKE_SCREEN, 1, UserHandle.USER_CURRENT) == 1);


            // Configure wake gesture.
            // Configure wake gesture.
            boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver,
            boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver,
@@ -2110,11 +2151,6 @@ 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);

        }
        }
        synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
        synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
            PolicyControl.reloadFromSetting(mContext);
            PolicyControl.reloadFromSetting(mContext);
@@ -5433,6 +5469,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    // On TVs volume keys never go to the foreground app
                    // On TVs volume keys never go to the foreground app
                    result &= ~ACTION_PASS_TO_USER;
                    result &= ~ACTION_PASS_TO_USER;
                }
                }
                // Eat all down & up keys when using volume wake.
                // This disables volume control, music control, and "beep" on key up.
                if (isWakeKey && mVolumeWakeScreen) {
                    mVolumeWakeTriggered = true;
                    break;
                } else if (mVolumeWakeTriggered && !down) {
                    result &= ~ACTION_PASS_TO_USER;
                    mVolumeWakeTriggered = false;
                    break;
                }

                if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
                if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
                    if (down) {
                    if (down) {
                        if (interactive && !mScreenshotChordVolumeDownKeyTriggered
                        if (interactive && !mScreenshotChordVolumeDownKeyTriggered
@@ -5729,6 +5776,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
            case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
            case KeyEvent.KEYCODE_CAMERA:
            case KeyEvent.KEYCODE_CAMERA:
                return false;
                return false;

            case KeyEvent.KEYCODE_BACK:
                return mBackWakeScreen;
            case KeyEvent.KEYCODE_MENU:
                return mMenuWakeScreen;
            case KeyEvent.KEYCODE_ASSIST:
                return mAssistWakeScreen;
            case KeyEvent.KEYCODE_APP_SWITCH:
                return mAppSwitchWakeScreen;
        }
        }
        return true;
        return true;
    }
    }