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

Commit 842fd2a0 authored by Lais Andrade's avatar Lais Andrade Committed by Android (Google) Code Review
Browse files

Merge "Small fixes to PWLE implementation" into sc-dev

parents c2d5b1bd 81bf87f2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ constexpr int32_t SINGLE_VIBRATOR_ID = 0;
const constexpr char* MISSING_VIBRATOR_MESSAGE_PREFIX = "No vibrator with id=";

HalResult<void> LegacyManagerHalWrapper::ping() {
    auto pingFn = [](std::shared_ptr<HalWrapper> hal) { return hal->ping(); };
    auto pingFn = [](HalWrapper* hal) { return hal->ping(); };
    return mController->doWithRetry<void>(pingFn, "ping");
}

+4 −5
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ namespace vibrator {
std::shared_ptr<HalWrapper> connectHal(std::shared_ptr<CallbackScheduler> scheduler);

template <typename T>
using HalFunction = std::function<T(std::shared_ptr<HalWrapper>)>;
using HalFunction = std::function<T(HalWrapper*)>;

// Controller for Vibrator HAL handle.
// This relies on a given Connector to connect to the underlying Vibrator HAL service and reconnects
@@ -64,8 +64,7 @@ public:
     */
    Info getInfo() {
        static Info sDefaultInfo = InfoCache().get();
        return apply<Info>([](std::shared_ptr<HalWrapper> hal) { return hal->getInfo(); },
                           sDefaultInfo, "getInfo");
        return apply<Info>([](HalWrapper* hal) { return hal->getInfo(); }, sDefaultInfo, "getInfo");
    }

    /* Calls given HAL function, applying automatic retries to reconnect with the HAL when the
@@ -103,7 +102,7 @@ private:
        }

        for (int i = 0; i < MAX_RETRIES; i++) {
            T result = halFn(hal);
            T result = halFn(hal.get());
            if (result.checkAndLogFailure(functionName)) {
                tryReconnect();
            } else {
@@ -111,7 +110,7 @@ private:
            }
        }

        return halFn(hal);
        return halFn(hal.get());
    }
};

+4 −6
Original line number Diff line number Diff line
@@ -40,11 +40,9 @@ using namespace android;
using namespace std::chrono_literals;
using namespace testing;

static const auto ON_FN = [](std::shared_ptr<vibrator::HalWrapper> hal) {
    return hal->on(10ms, []() {});
};
static const auto OFF_FN = [](std::shared_ptr<vibrator::HalWrapper> hal) { return hal->off(); };
static const auto PING_FN = [](std::shared_ptr<vibrator::HalWrapper> hal) { return hal->ping(); };
static const auto ON_FN = [](vibrator::HalWrapper* hal) { return hal->on(10ms, []() {}); };
static const auto OFF_FN = [](vibrator::HalWrapper* hal) { return hal->off(); };
static const auto PING_FN = [](vibrator::HalWrapper* hal) { return hal->ping(); };

// -------------------------------------------------------------------------------------------------

@@ -233,7 +231,7 @@ TEST_F(VibratorHalControllerTest, TestScheduledCallbackSurvivesReconnection) {
    std::unique_ptr<int32_t> callbackCounter = std::make_unique<int32_t>();
    auto callback = vibrator::TestFactory::createCountingCallback(callbackCounter.get());

    auto onFn = [&](std::shared_ptr<vibrator::HalWrapper> hal) { return hal->on(10ms, callback); };
    auto onFn = [&](vibrator::HalWrapper* hal) { return hal->on(10ms, callback); };
    ASSERT_TRUE(mController->doWithRetry<void>(onFn, "on").isOk());
    ASSERT_TRUE(mController->doWithRetry<void>(PING_FN, "ping").isFailed());
    mMockHal.reset();
+0 −1
Original line number Diff line number Diff line
@@ -644,7 +644,6 @@ TEST_F(VibratorHalWrapperAidlTest, TestPerformPwleEffect) {
                .Times(Exactly(2))
                .WillOnce(Return(Status::fromExceptionCode(Status::Exception::EX_SECURITY)))
                .WillRepeatedly(DoAll(TriggerCallbackInArg1(), Return(Status())));
        ;
    }

    std::unique_ptr<int32_t> callbackCounter = std::make_unique<int32_t>();
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ using android::hardware::vibrator::PrimitivePwle;
using namespace android;
using namespace testing;

static const auto OFF_FN = [](std::shared_ptr<vibrator::HalWrapper> hal) { return hal->off(); };
static const auto OFF_FN = [](vibrator::HalWrapper* hal) { return hal->off(); };

class MockBinder : public BBinder {
public: