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

Commit e3da4bbc authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Notify InputListener when there an changes to input devices

There are now more than one input listener stages that need to know when
the devices change. Notify listeners directly instead of routing it
through the policy.

Bug: 275726706
Test: atest inputflinger_tests
Change-Id: I37019f8069bad3bbc585805f792beb514faa8cb1
parent 71660f18
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

#include <android-base/stringprintf.h>
#include <android/log.h>
#include <math.h>
#include <utils/Trace.h>

using android::base::StringPrintf;
@@ -47,6 +46,7 @@ Visitor(V...) -> Visitor<V...>;

void InputListenerInterface::notify(const NotifyArgs& generalArgs) {
    Visitor v{
            [&](const NotifyInputDevicesChangedArgs& args) { notifyInputDevicesChanged(args); },
            [&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(&args); },
            [&](const NotifyKeyArgs& args) { notifyKey(&args); },
            [&](const NotifyMotionArgs& args) { notifyMotion(&args); },
@@ -73,6 +73,11 @@ static inline void traceEvent(const char* functionName, int32_t id) {
QueuedInputListener::QueuedInputListener(InputListenerInterface& innerListener)
      : mInnerListener(innerListener) {}

void QueuedInputListener::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
    traceEvent(__func__, args.id);
    mArgsQueue.emplace_back(args);
}

void QueuedInputListener::notifyConfigurationChanged(
        const NotifyConfigurationChangedArgs* args) {
    traceEvent(__func__, args->id);
+6 −0
Original line number Diff line number Diff line
@@ -413,6 +413,12 @@ void InputProcessor::setMotionClassifierEnabled(bool enabled) {
    }
}

void InputProcessor::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
    // pass through
    mQueuedListener.notify(args);
    mQueuedListener.flush();
}

void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
    // pass through
    mQueuedListener.notifyConfigurationChanged(args);
+1 −0
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ class InputProcessor : public InputProcessorInterface {
public:
    explicit InputProcessor(InputListenerInterface& listener);

    void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
    void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
    void notifyKey(const NotifyKeyArgs* args) override;
    void notifyMotion(const NotifyMotionArgs* args) override;
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,12 @@ using android::base::StringPrintf;

namespace android {

// --- NotifyInputDevicesChangedArgs ---

NotifyInputDevicesChangedArgs::NotifyInputDevicesChangedArgs(int32_t id,
                                                             std::vector<InputDeviceInfo> infos)
      : id(id), inputDeviceInfos(std::move(infos)) {}

// --- NotifyConfigurationChangedArgs ---

NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(int32_t id, nsecs_t eventTime)
@@ -234,6 +240,7 @@ Visitor(V...) -> Visitor<V...>;

const char* toString(const NotifyArgs& args) {
    Visitor toStringVisitor{
            [&](const NotifyInputDevicesChangedArgs&) { return "NotifyInputDevicesChangedArgs"; },
            [&](const NotifyConfigurationChangedArgs&) { return "NotifyConfigurationChangedArgs"; },
            [&](const NotifyKeyArgs&) { return "NotifyKeyArgs"; },
            [&](const NotifyMotionArgs&) { return "NotifyMotionArgs"; },
+7 −0
Original line number Diff line number Diff line
@@ -411,6 +411,13 @@ void UnwantedInteractionBlocker::notifyPointerCaptureChanged(
}

void UnwantedInteractionBlocker::notifyInputDevicesChanged(
        const NotifyInputDevicesChangedArgs& args) {
    onInputDevicesChanged(args.inputDeviceInfos);
    mQueuedListener.notify(args);
    mQueuedListener.flush();
}

void UnwantedInteractionBlocker::onInputDevicesChanged(
        const std::vector<InputDeviceInfo>& inputDevices) {
    std::scoped_lock lock(mLock);
    if (!mEnablePalmRejection) {
Loading