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

Commit 8ede1d12 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Notify MetricsCollector of device interaction from Dispatcher

InputDispatcher will notify the metrics collector whenever an
interaction occurs between an input device and a UID through its policy.

Bug: 275726706
Test: atest inputflinger_tests
Test: statsd_testdrive
Change-Id: Ic62b351263542577328db00c7feb5ff6042f6fe0
parent 30f0d321
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -246,6 +246,11 @@ void InputDeviceMetricsCollector::notifyPointerCaptureChanged(
    mNextListener.notify(args);
}

void InputDeviceMetricsCollector::notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp,
                                                          const std::set<int32_t>& uids) {
    // TODO: Implement.
}

void InputDeviceMetricsCollector::dump(std::string& dump) {
    dump += "InputDeviceMetricsCollector:\n";

+9 −1
Original line number Diff line number Diff line
@@ -33,10 +33,16 @@ namespace android {
/**
 * Logs metrics about registered input devices and their usages.
 *
 * Not thread safe. Must be called from a single thread.
 * All methods in the InputListenerInterface must be called from a single thread.
 */
class InputDeviceMetricsCollectorInterface : public InputListenerInterface {
public:
    /**
     * Notify the metrics collector that there was an input device interaction with apps.
     * Called from the InputDispatcher thread.
     */
    virtual void notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp,
                                         const std::set<int32_t>& uids) = 0;
    /**
     * Dump the state of the interaction blocker.
     * This method may be called on any thread (usually by the input manager on a binder thread).
@@ -121,6 +127,8 @@ public:
    void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
    void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;

    void notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp,
                                 const std::set<int32_t>& uids) override;
    void dump(std::string& dump) override;

private:
+4 −0
Original line number Diff line number Diff line
@@ -127,6 +127,10 @@ InputProcessorInterface& InputManager::getProcessor() {
    return *mProcessor;
}

InputDeviceMetricsCollectorInterface& InputManager::getMetricsCollector() {
    return *mCollector;
}

InputDispatcherInterface& InputManager::getDispatcher() {
    return *mDispatcher;
}
+4 −0
Original line number Diff line number Diff line
@@ -86,6 +86,9 @@ public:
    /* Gets the input processor. */
    virtual InputProcessorInterface& getProcessor() = 0;

    /* Gets the metrics collector. */
    virtual InputDeviceMetricsCollectorInterface& getMetricsCollector() = 0;

    /* Gets the input dispatcher. */
    virtual InputDispatcherInterface& getDispatcher() = 0;

@@ -109,6 +112,7 @@ public:

    InputReaderInterface& getReader() override;
    InputProcessorInterface& getProcessor() override;
    InputDeviceMetricsCollectorInterface& getMetricsCollector() override;
    InputDispatcherInterface& getDispatcher() override;
    void monitor() override;
    void dump(std::string& dump) override;
+3 −0
Original line number Diff line number Diff line
@@ -111,6 +111,9 @@ private:

    void notifyDropWindow(const sp<IBinder>&, float x, float y) override {}

    void notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp,
                                 const std::set<int32_t>& uids) override {}

    InputDispatcherConfiguration mConfig;
};

Loading