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

Commit 5e70e961 authored by Omar Abdelmonem's avatar Omar Abdelmonem
Browse files

Create Native getTouchpadHardwareProperties()

Create Native method to get the hardware properties of touchpad and
connected it to InputManagerService.java using JNI

Bug: 286551975

Test: Verified that the data flow works correctly and the method references are valid.
Flag: com.android.hardware.input.touchpad_visualizer
Change-Id: Ic6c32eabd3078ff2b50e3b3bb430abadd9dd752c
parent 826e9f05
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@

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

// Maximum supported size of a vibration pattern.
// Must be at least 2.
@@ -363,6 +364,8 @@ public:

    virtual std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) = 0;

    virtual std::optional<HardwareProperties> getTouchpadHardwareProperties(int32_t deviceId) = 0;

    /* Return true if the device can send input events to the specified display. */
    virtual bool canDispatchToDisplay(int32_t deviceId, ui::LogicalDisplayId displayId) = 0;

+9 −0
Original line number Diff line number Diff line
@@ -725,6 +725,15 @@ size_t InputDevice::getMapperCount() {
    return count;
}

std::optional<HardwareProperties> InputDevice::getTouchpadHardwareProperties() {
    std::optional<HardwareProperties> result = first_in_mappers<HardwareProperties>(
            [](InputMapper& mapper) -> std::optional<HardwareProperties> {
                return mapper.getTouchpadHardwareProperties();
            });

    return result;
}

void InputDevice::updateLedState(bool reset) {
    for_each_mapper([reset](InputMapper& mapper) { mapper.updateLedState(reset); });
}
+13 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <utils/Thread.h>

#include "InputDevice.h"
#include "include/gestures.h"

using android::base::StringPrintf;

@@ -817,6 +818,18 @@ std::vector<InputDeviceSensorInfo> InputReader::getSensors(int32_t deviceId) {
    return device->getDeviceInfo().getSensors();
}

std::optional<HardwareProperties> InputReader::getTouchpadHardwareProperties(int32_t deviceId) {
    std::scoped_lock _l(mLock);

    InputDevice* device = findInputDeviceLocked(deviceId);

    if (device == nullptr) {
        return {};
    }

    return device->getTouchpadHardwareProperties();
}

bool InputReader::setLightColor(int32_t deviceId, int32_t lightId, int32_t color) {
    std::scoped_lock _l(mLock);

+2 −0
Original line number Diff line number Diff line
@@ -141,6 +141,8 @@ public:

    size_t getMapperCount();

    std::optional<HardwareProperties> getTouchpadHardwareProperties();

    // construct and add a mapper to the input device
    template <class T, typename... Args>
    T& addMapper(int32_t eventHubId, Args... args) {
+2 −0
Original line number Diff line number Diff line
@@ -104,6 +104,8 @@ public:

    std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) override;

    std::optional<HardwareProperties> getTouchpadHardwareProperties(int32_t deviceId) override;

    bool setLightColor(int32_t deviceId, int32_t lightId, int32_t color) override;

    bool setLightPlayerId(int32_t deviceId, int32_t lightId, int32_t playerId) override;
Loading