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

Commit 34aae680 authored by Arpit Singh's avatar Arpit Singh Committed by Automerger Merge Worker
Browse files

Merge "InputMapper refactor: VibratorInputMapper" into udc-dev am: 315eb8c9

parents cb8cf535 315eb8c9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -456,7 +456,7 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(

    // Vibrator-like devices.
    if (classes.test(InputDeviceClass::VIBRATOR)) {
        mappers.push_back(std::make_unique<VibratorInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<VibratorInputMapper>(contextPtr, readerConfig));
    }

    // Battery-like devices or light-containing devices.
+6 −2
Original line number Diff line number Diff line
@@ -22,8 +22,10 @@ namespace android {

class VibratorInputMapper : public InputMapper {
public:
    explicit VibratorInputMapper(InputDeviceContext& deviceContext,
                                 const InputReaderConfiguration& readerConfig);
    template <class T, class... Args>
    friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext,
                                                const InputReaderConfiguration& readerConfig,
                                                Args... args);
    virtual ~VibratorInputMapper();

    virtual uint32_t getSources() const override;
@@ -46,6 +48,8 @@ private:
    ssize_t mIndex;
    nsecs_t mNextStepTime;

    explicit VibratorInputMapper(InputDeviceContext& deviceContext,
                                 const InputReaderConfiguration& readerConfig);
    [[nodiscard]] std::list<NotifyArgs> nextStep();
    [[nodiscard]] NotifyVibratorStateArgs stopVibrating();
};
+3 −3
Original line number Diff line number Diff line
@@ -2645,13 +2645,13 @@ protected:
};
TEST_F(VibratorInputMapperTest, GetSources) {
    VibratorInputMapper& mapper = addMapperAndConfigure<VibratorInputMapper>();
    VibratorInputMapper& mapper = constructAndAddMapper<VibratorInputMapper>();
    ASSERT_EQ(AINPUT_SOURCE_UNKNOWN, mapper.getSources());
}
TEST_F(VibratorInputMapperTest, GetVibratorIds) {
    VibratorInputMapper& mapper = addMapperAndConfigure<VibratorInputMapper>();
    VibratorInputMapper& mapper = constructAndAddMapper<VibratorInputMapper>();
    ASSERT_EQ(mapper.getVibratorIds().size(), 2U);
}
@@ -2659,7 +2659,7 @@ TEST_F(VibratorInputMapperTest, GetVibratorIds) {
TEST_F(VibratorInputMapperTest, Vibrate) {
    constexpr uint8_t DEFAULT_AMPLITUDE = 192;
    constexpr int32_t VIBRATION_TOKEN = 100;
    VibratorInputMapper& mapper = addMapperAndConfigure<VibratorInputMapper>();
    VibratorInputMapper& mapper = constructAndAddMapper<VibratorInputMapper>();
    VibrationElement pattern(2);
    VibrationSequence sequence(2);