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

Commit c109d81d authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Shift notifyConfigurationChanged policy call to InputReader

WM expects input devices to be updated on receiving notify
configuration changed callback, but currently the policy callback
for input devices changed is sent after configuration changed,
causing stale device info provided to WM.

Bug: 350416243
Test: atest inputflinger_tests
Flag: NONE bugfix
Change-Id: If6c9d50459c4b1d72d0a2774b4fc833d6522a095
parent f5d714c6
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -1652,12 +1652,6 @@ bool InputDispatcher::dispatchConfigurationChangedLocked(nsecs_t currentTime,
    // Reset key repeating in case a keyboard device was added or removed or something.
    resetKeyRepeatLocked();

    // Enqueue a command to run outside the lock to tell the policy that the configuration changed.
    auto command = [this, eventTime = entry.eventTime]() REQUIRES(mLock) {
        scoped_unlock unlock(mLock);
        mPolicy.notifyConfigurationChanged(eventTime);
    };
    postCommandLocked(std::move(command));
    return true;
}

+0 −3
Original line number Diff line number Diff line
@@ -43,9 +43,6 @@ public:
    InputDispatcherPolicyInterface() = default;
    virtual ~InputDispatcherPolicyInterface() = default;

    /* Notifies the system that a configuration change has occurred. */
    virtual void notifyConfigurationChanged(nsecs_t when) = 0;

    /* Notifies the system that an application does not have a focused window.
     */
    virtual void notifyNoFocusedWindowAnr(
+3 −0
Original line number Diff line number Diff line
@@ -451,6 +451,9 @@ public:
     */
    virtual void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) = 0;

    /* Notifies the system that a configuration change has occurred. */
    virtual void notifyConfigurationChanged(nsecs_t when) = 0;

    /* Gets the keyboard layout for a particular input device. */
    virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
            const InputDeviceIdentifier& identifier,
+9 −0
Original line number Diff line number Diff line
@@ -212,6 +212,15 @@ void InputReader::loopOnce() {
        mPolicy->notifyInputDevicesChanged(inputDevices);
    }

    // Notify the policy of configuration change. This must be after policy is notified about input
    // device changes so that policy can fetch newly added input devices on configuration change.
    for (const auto& args : notifyArgs) {
        const auto* configArgs = std::get_if<NotifyConfigurationChangedArgs>(&args);
        if (configArgs != nullptr) {
            mPolicy->notifyConfigurationChanged(configArgs->eventTime);
        }
    }

    // Notify the policy of the start of every new stylus gesture.
    for (const auto& args : notifyArgs) {
        const auto* motionArgs = std::get_if<NotifyMotionArgs>(&args);
+0 −12
Original line number Diff line number Diff line
@@ -54,13 +54,6 @@ void FakeInputDispatcherPolicy::assertFilterInputEventWasNotCalled() {
    ASSERT_EQ(nullptr, mFilteredEvent);
}

void FakeInputDispatcherPolicy::assertNotifyConfigurationChangedWasCalled(nsecs_t when) {
    std::scoped_lock lock(mLock);
    ASSERT_TRUE(mConfigurationChangedTime) << "Timed out waiting for configuration changed call";
    ASSERT_EQ(*mConfigurationChangedTime, when);
    mConfigurationChangedTime = std::nullopt;
}

void FakeInputDispatcherPolicy::assertNotifySwitchWasCalled(const NotifySwitchArgs& args) {
    std::scoped_lock lock(mLock);
    ASSERT_TRUE(mLastNotifySwitch);
@@ -342,11 +335,6 @@ std::optional<T> FakeInputDispatcherPolicy::getItemFromStorageLockedInterruptibl
    return std::make_optional(item);
}

void FakeInputDispatcherPolicy::notifyConfigurationChanged(nsecs_t when) {
    std::scoped_lock lock(mLock);
    mConfigurationChangedTime = when;
}

void FakeInputDispatcherPolicy::notifyWindowUnresponsive(const sp<IBinder>& connectionToken,
                                                         std::optional<gui::Pid> pid,
                                                         const std::string&) {
Loading