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

Commit 2808d7eb authored by Asmita Poddar's avatar Asmita Poddar
Browse files

Disable key repeat when it is switched off

Read whether key repeats are disabled via settings and disable
generation of key repeats if so.

Bug: 336585002
Test: atest InputDispatcherKeyRepeatTest
Test: atest InputManagerServiceTests
Flag: com.android.input.flags.keyboard_repeat_keys
Change-Id: I871bbfc0808bde4a6f85b7ea47ea92d4e80156c7
parent f8fcb069
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -201,3 +201,9 @@ flag {
  is_fixed_read_only: true
  is_fixed_read_only: true
}
}


flag {
  name: "keyboard_repeat_keys"
  namespace: "input"
  description: "Allow user to enable key repeats or configure timeout before key repeat and key repeat delay rates."
  bug: "336585002"
}
+7 −1
Original line number Original line Diff line number Diff line
@@ -4491,6 +4491,10 @@ void InputDispatcher::notifyKey(const NotifyKeyArgs& args) {
    { // acquire lock
    { // acquire lock
        mLock.lock();
        mLock.lock();


        if (input_flags::keyboard_repeat_keys() && !mConfig.keyRepeatEnabled) {
            policyFlags |= POLICY_FLAG_DISABLE_KEY_REPEAT;
        }

        if (shouldSendKeyToInputFilterLocked(args)) {
        if (shouldSendKeyToInputFilterLocked(args)) {
            mLock.unlock();
            mLock.unlock();


@@ -7209,11 +7213,13 @@ sp<WindowInfoHandle> InputDispatcher::findWallpaperWindowBelow(
}
}


void InputDispatcher::setKeyRepeatConfiguration(std::chrono::nanoseconds timeout,
void InputDispatcher::setKeyRepeatConfiguration(std::chrono::nanoseconds timeout,
                                                std::chrono::nanoseconds delay) {
                                                std::chrono::nanoseconds delay,
                                                bool keyRepeatEnabled) {
    std::scoped_lock _l(mLock);
    std::scoped_lock _l(mLock);


    mConfig.keyRepeatTimeout = timeout.count();
    mConfig.keyRepeatTimeout = timeout.count();
    mConfig.keyRepeatDelay = delay.count();
    mConfig.keyRepeatDelay = delay.count();
    mConfig.keyRepeatEnabled = keyRepeatEnabled;
}
}


bool InputDispatcher::isPointerInWindow(const sp<android::IBinder>& token,
bool InputDispatcher::isPointerInWindow(const sp<android::IBinder>& token,
+2 −2
Original line number Original line Diff line number Diff line
@@ -153,8 +153,8 @@ public:
    // Public to allow tests to verify that a Monitor can get ANR.
    // Public to allow tests to verify that a Monitor can get ANR.
    void setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout);
    void setMonitorDispatchingTimeoutForTest(std::chrono::nanoseconds timeout);


    void setKeyRepeatConfiguration(std::chrono::nanoseconds timeout,
    void setKeyRepeatConfiguration(std::chrono::nanoseconds timeout, std::chrono::nanoseconds delay,
                                   std::chrono::nanoseconds delay) override;
                                   bool keyRepeatEnabled) override;


    bool isPointerInWindow(const sp<IBinder>& token, ui::LogicalDisplayId displayId,
    bool isPointerInWindow(const sp<IBinder>& token, ui::LogicalDisplayId displayId,
                           DeviceId deviceId, int32_t pointerId) override;
                           DeviceId deviceId, int32_t pointerId) override;
+6 −1
Original line number Original line Diff line number Diff line
@@ -34,8 +34,13 @@ struct InputDispatcherConfiguration {
    // The key repeat inter-key delay.
    // The key repeat inter-key delay.
    nsecs_t keyRepeatDelay;
    nsecs_t keyRepeatDelay;


    // Whether key repeat is enabled.
    bool keyRepeatEnabled;

    InputDispatcherConfiguration()
    InputDispatcherConfiguration()
          : keyRepeatTimeout(500 * 1000000LL), keyRepeatDelay(50 * 1000000LL) {}
          : keyRepeatTimeout(500 * 1000000LL),
            keyRepeatDelay(50 * 1000000LL),
            keyRepeatEnabled(true) {}
};
};


} // namespace android
} // namespace android
+3 −2
Original line number Original line Diff line number Diff line
@@ -227,10 +227,11 @@ public:
    virtual void cancelCurrentTouch() = 0;
    virtual void cancelCurrentTouch() = 0;


    /*
    /*
     * Updates key repeat configuration timeout and delay.
     * Updates whether key repeat is enabled and key repeat configuration timeout and delay.
     */
     */
    virtual void setKeyRepeatConfiguration(std::chrono::nanoseconds timeout,
    virtual void setKeyRepeatConfiguration(std::chrono::nanoseconds timeout,
                                           std::chrono::nanoseconds delay) = 0;
                                           std::chrono::nanoseconds delay,
                                           bool keyRepeatEnabled) = 0;


    /*
    /*
     * Determine if a pointer from a device is being dispatched to the given window.
     * Determine if a pointer from a device is being dispatched to the given window.
Loading