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

Commit 0ffeb57a authored by Chen Bai's avatar Chen Bai
Browse files

clobber wom: implement onKeyUp for PowerKeyRule

- Apply the callback for power key. This is helpful for devices that
wish to trigger power key press behavior without waiting for
the delay needed to check for consecutive presses.

- Added a new config, `config_shortPressEarlyOnPower` to guard Power key's
usage of this callback. If this config is enabled, the single press
behavior for power key will run in response to the first key up event,
instead of using the `onPress` callback.

Test: atest WmTests:SingleKeyGestureTests
BUG: 305856148
Change-Id: I9f69c0352ecd8ee495dcbc0d9d5967635b02f69d
parent 2ff4cc3c
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1241,6 +1241,21 @@
   <!-- Activity name for the default target activity to be launched. [DO NOT TRANSLATE] -->
   <string name="config_primaryShortPressTargetActivity" translatable="false"></string>

    <!-- Whether a single short press on POWER should be launched without multi-press delay.
        When this value is set to true, POWER button's single short press behavior will execute
        immediately upon key-up regardless of whether this press will be part of a multi-press
        gesture in the future(therefore, not waiting for a multi-press detecting delay).

       For Example, let's say a power button single press launches the app menu and power button
       double press launches the camera. By configuring this variable to true, user will observe 2
       things in order upon a double press:
          1. App menu pops up immediately upon the first key up.
          2. Camera starts as the double press behavior.

        Note that this config has no effect on long press behavior.
    -->
    <bool name="config_shortPressEarlyOnPower">false</bool>

    <!-- Control the behavior of the search key.
            0 - Launch default search activity
            1 - Launch target activity defined by config_searchKeyTargetActivity
+1 −0
Original line number Diff line number Diff line
@@ -471,6 +471,7 @@
  <java-symbol type="string" name="config_primaryShortPressTargetActivity" />
  <java-symbol type="integer" name="config_doublePressOnStemPrimaryBehavior" />
  <java-symbol type="integer" name="config_triplePressOnStemPrimaryBehavior" />
  <java-symbol type="bool" name="config_shortPressEarlyOnPower" />
  <java-symbol type="string" name="config_doublePressOnPowerTargetActivity" />
  <java-symbol type="integer" name="config_searchKeyBehavior" />
  <java-symbol type="string" name="config_searchKeyTargetActivity" />
+14 −0
Original line number Diff line number Diff line
@@ -546,6 +546,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    int mLidKeyboardAccessibility;
    int mLidNavigationAccessibility;
    int mShortPressOnPowerBehavior;
    private boolean mShouldEarlyShortPressOnPower;
    int mLongPressOnPowerBehavior;
    long mLongPressOnPowerAssistantTimeoutMs;
    int mVeryLongPressOnPowerBehavior;
@@ -2651,6 +2652,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        @Override
        void onPress(long downTime) {
            if (mShouldEarlyShortPressOnPower) {
                return;
            }
            powerPress(downTime, 1 /*count*/);
        }

@@ -2684,6 +2688,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        void onMultiPress(long downTime, int count) {
            powerPress(downTime, count);
        }

        @Override
        void onKeyUp(long eventTime, int count) {
            if (mShouldEarlyShortPressOnPower && count == 1) {
                powerPress(eventTime, 1 /*pressCount*/);
            }
        }
    }

    /**
@@ -2913,6 +2924,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Settings.Global.STEM_PRIMARY_BUTTON_LONG_PRESS,
                    mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_longPressOnStemPrimaryBehavior));
            mShouldEarlyShortPressOnPower =
                    mContext.getResources()
                            .getBoolean(com.android.internal.R.bool.config_shortPressEarlyOnPower);

            mStylusButtonsEnabled = Settings.Secure.getIntForUser(resolver,
                    Secure.STYLUS_BUTTONS_ENABLED, 1, UserHandle.USER_CURRENT) == 1;