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

Commit 0ab1fca5 authored by Abdelrahman Awadalla's avatar Abdelrahman Awadalla Committed by Android (Google) Code Review
Browse files

Merge "Notify TouchpadDebugActivity on finger/hardware state changes" into main

parents e3b1bed7 8c4160d3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include <vector>

#include "PointerControllerInterface.h"
#include "TouchpadHardwareState.h"
#include "VibrationElement.h"
#include "include/gestures.h"

@@ -461,6 +462,10 @@ public:
     */
    virtual void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) = 0;

    /* Sends the hardware state of a connected touchpad */
    virtual void notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
                                             int32_t deviceId) = 0;

    /* Gets the keyboard layout for a particular input device. */
    virtual std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
            const InputDeviceIdentifier& identifier,
+2 −3
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <log/log_main.h>
#include <stats_pull_atom_callback.h>
#include <statslog.h>
#include "InputReaderBase.h"
#include "TouchCursorInputMapperCommon.h"
#include "TouchpadInputMapper.h"
#include "gestures/HardwareProperties.h"
@@ -424,10 +425,8 @@ std::list<NotifyArgs> TouchpadInputMapper::process(const RawEvent& rawEvent) {
    std::optional<SelfContainedHardwareState> state = mStateConverter.processRawEvent(rawEvent);
    if (state) {
        if (mTouchpadHardwareStateNotificationsEnabled) {
            // TODO(b/286551975): Notify policy of the touchpad hardware state.
            LOG(DEBUG) << "Notify touchpad hardware state here!";
            getPolicy()->notifyTouchpadHardwareState(*state, rawEvent.deviceId);
        }

        updatePalmDetectionMetrics();
        return sendHardwareState(rawEvent.when, rawEvent.readTime, *state);
    } else {
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "accumulator/TouchButtonAccumulator.h"
#include "include/TouchpadHardwareState.h"

#include "TouchpadHardwareState.h"
#include "include/gestures.h"

namespace android {
+18 −0
Original line number Diff line number Diff line
@@ -65,6 +65,17 @@ void FakeInputReaderPolicy::assertStylusGestureNotNotified() {
    ASSERT_FALSE(mDeviceIdOfNotifiedStylusGesture);
}

void FakeInputReaderPolicy::assertTouchpadHardwareStateNotified() {
    std::unique_lock lock(mLock);
    base::ScopedLockAssertion assumeLocked(mLock);

    const bool success =
            mTouchpadHardwareStateNotified.wait_for(lock, WAIT_TIMEOUT, [this]() REQUIRES(mLock) {
                return mTouchpadHardwareState.has_value();
            });
    ASSERT_TRUE(success) << "Timed out waiting for hardware state to be notified";
}

void FakeInputReaderPolicy::clearViewports() {
    mViewports.clear();
    mConfig.setDisplayViewports(mViewports);
@@ -234,6 +245,13 @@ void FakeInputReaderPolicy::notifyInputDevicesChanged(
    mDevicesChangedCondition.notify_all();
}

void FakeInputReaderPolicy::notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
                                                        int32_t deviceId) {
    std::scoped_lock lock(mLock);
    mTouchpadHardwareState = schs;
    mTouchpadHardwareStateNotified.notify_all();
}

std::shared_ptr<KeyCharacterMap> FakeInputReaderPolicy::getKeyboardLayoutOverlay(
        const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) {
    return nullptr;
+6 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public:
    void assertInputDevicesNotChanged();
    void assertStylusGestureNotified(int32_t deviceId);
    void assertStylusGestureNotNotified();
    void assertTouchpadHardwareStateNotified();

    virtual void clearViewports();
    std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueId) const;
@@ -82,6 +83,8 @@ public:
private:
    void getReaderConfiguration(InputReaderConfiguration* outConfig) override;
    void notifyInputDevicesChanged(const std::vector<InputDeviceInfo>& inputDevices) override;
    void notifyTouchpadHardwareState(const SelfContainedHardwareState& schs,
                                     int32_t deviceId) override;
    std::shared_ptr<KeyCharacterMap> getKeyboardLayoutOverlay(
            const InputDeviceIdentifier&, const std::optional<KeyboardLayoutInfo>) override;
    std::string getDeviceAlias(const InputDeviceIdentifier&) override;
@@ -101,6 +104,9 @@ private:
    std::condition_variable mStylusGestureNotifiedCondition;
    std::optional<DeviceId> mDeviceIdOfNotifiedStylusGesture GUARDED_BY(mLock){};

    std::condition_variable mTouchpadHardwareStateNotified;
    std::optional<SelfContainedHardwareState> mTouchpadHardwareState GUARDED_BY(mLock){};

    uint32_t mNextPointerCaptureSequenceNumber{0};
};

Loading