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

Commit cadce9d7 authored by Arthur Hung's avatar Arthur Hung
Browse files

Fix potential block in InputReader

The 'dispatchExternalStylusState' is a callback function for
'ExternalStylusInputMapper' when the stylus device state is changed,
it's unnecessary to hold the lock again because it already hold when
processing the raw event.

Bug: 187253236
Test: atest inputflinger_tests
Change-Id: I19a2ef5f4c7a5afb622691ef7ec532f8d4dbb7ed
parent b8e9586d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -413,8 +413,7 @@ void InputReader::getExternalStylusDevicesLocked(std::vector<InputDeviceInfo>& o
    }
}

void InputReader::dispatchExternalStylusState(const StylusState& state) {
    std::scoped_lock _l(mLock);
void InputReader::dispatchExternalStylusStateLocked(const StylusState& state) {
    for (auto& devicePair : mDevices) {
        std::shared_ptr<InputDevice>& device = devicePair.second;
        device->updateExternalStylusState(state);
@@ -945,7 +944,7 @@ void InputReader::ContextImpl::getExternalStylusDevices(std::vector<InputDeviceI
}

void InputReader::ContextImpl::dispatchExternalStylusState(const StylusState& state) {
    mReader->dispatchExternalStylusState(state);
    mReader->dispatchExternalStylusStateLocked(state);
}

InputReaderPolicyInterface* InputReader::ContextImpl::getPolicy() {
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ private:

    void notifyExternalStylusPresenceChangedLocked() REQUIRES(mLock);
    void getExternalStylusDevicesLocked(std::vector<InputDeviceInfo>& outDevices) REQUIRES(mLock);
    void dispatchExternalStylusState(const StylusState& state);
    void dispatchExternalStylusStateLocked(const StylusState& state) REQUIRES(mLock);

    // The PointerController that is shared among all the input devices that need it.
    std::weak_ptr<PointerControllerInterface> mPointerController;