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

Commit 2d1a1415 authored by Chen Bai's avatar Chen Bai
Browse files

clobber wom: implement onKeyUp for StemPrimaryKeyRule

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

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

Test: atest WmTests:SingleKeyGestureTests
BUG: 297121934
Change-Id: I7ab3ebf2a79b74fb47fb74da80cb6e8d9c04dc87
parent f4356a7a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1256,6 +1256,11 @@
    -->
    <bool name="config_shortPressEarlyOnPower">false</bool>

    <!-- Whether a single short press on STEM_PRIMARY should be launched without multi-press delay.
        This works similarly as config_shortPressEarlyOnPower but for STEM_PRIMARY.
    -->
    <bool name="config_shortPressEarlyOnStemPrimary">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
@@ -473,6 +473,7 @@
  <java-symbol type="integer" name="config_doublePressOnStemPrimaryBehavior" />
  <java-symbol type="integer" name="config_triplePressOnStemPrimaryBehavior" />
  <java-symbol type="bool" name="config_shortPressEarlyOnPower" />
  <java-symbol type="bool" name="config_shortPressEarlyOnStemPrimary" />
  <java-symbol type="string" name="config_doublePressOnPowerTargetActivity" />
  <java-symbol type="integer" name="config_searchKeyBehavior" />
  <java-symbol type="string" name="config_searchKeyTargetActivity" />
+13 −0
Original line number Diff line number Diff line
@@ -549,6 +549,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    int mLidNavigationAccessibility;
    int mShortPressOnPowerBehavior;
    private boolean mShouldEarlyShortPressOnPower;
    private boolean mShouldEarlyShortPressOnStemPrimary;
    int mLongPressOnPowerBehavior;
    long mLongPressOnPowerAssistantTimeoutMs;
    int mVeryLongPressOnPowerBehavior;
@@ -2748,6 +2749,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        @Override
        void onPress(long downTime) {
            if (mShouldEarlyShortPressOnStemPrimary) {
                return;
            }
            stemPrimaryPress(1 /*count*/);
        }

@@ -2760,6 +2764,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        void onMultiPress(long downTime, int count) {
            stemPrimaryPress(count);
        }

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

    private void initSingleKeyGestureRules(Looper looper) {
@@ -2929,6 +2940,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mShouldEarlyShortPressOnPower =
                    mContext.getResources()
                            .getBoolean(com.android.internal.R.bool.config_shortPressEarlyOnPower);
            mShouldEarlyShortPressOnStemPrimary = mContext.getResources().getBoolean(
                    com.android.internal.R.bool.config_shortPressEarlyOnStemPrimary);

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