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

Commit 15ded34b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix assert error on vibrator benchmarks"

parents e1a6f2f8 1cd65e88
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -302,11 +302,13 @@ public:
        }

        std::vector<hardware::vibrator::Effect> supported = effectsResult.value();
        b->ArgNames({"Effect", "Strength"});

        if (supported.empty()) {
            b->Args({static_cast<long>(-1), static_cast<long>(-1)});
            return;
        }

        b->ArgNames({"Effect", "Strength"});
        for (const auto& effect : enum_range<hardware::vibrator::Effect>()) {
            if (std::find(supported.begin(), supported.end(), effect) == supported.end()) {
                continue;
@@ -318,6 +320,8 @@ public:
    }

protected:
    bool hasArgs(const State& state) const { return this->getOtherArg(state, 0) >= 0; }

    auto getEffect(const State& state) const {
        return static_cast<hardware::vibrator::Effect>(this->getOtherArg(state, 0));
    }
@@ -333,6 +337,9 @@ BENCHMARK_WRAPPER(VibratorEffectsBench, alwaysOnEnable, {
    if (!hasCapabilities(result, vibrator::Capabilities::ALWAYS_ON_CONTROL, state)) {
        return;
    }
    if (!hasArgs(state)) {
        return;
    }

    int32_t id = 1;
    auto effect = getEffect(state);
@@ -354,6 +361,9 @@ BENCHMARK_WRAPPER(VibratorEffectsBench, alwaysOnDisable, {
    if (!hasCapabilities(result, vibrator::Capabilities::ALWAYS_ON_CONTROL, state)) {
        return;
    }
    if (!hasArgs(state)) {
        return;
    }

    int32_t id = 1;
    auto effect = getEffect(state);
@@ -370,6 +380,10 @@ BENCHMARK_WRAPPER(VibratorEffectsBench, alwaysOnDisable, {
});

BENCHMARK_WRAPPER(VibratorEffectsBench, performEffect, {
    if (!hasArgs(state)) {
        return;
    }

    auto effect = getEffect(state);
    auto strength = getStrength(state);
    auto callback = []() {};
@@ -394,11 +408,13 @@ public:
        }

        std::vector<hardware::vibrator::CompositePrimitive> supported = primitivesResult.value();
        b->ArgNames({"Primitive"});

        if (supported.empty()) {
            b->Args({static_cast<long>(-1)});
            return;
        }

        b->ArgNames({"Primitive"});
        for (const auto& primitive : enum_range<hardware::vibrator::CompositePrimitive>()) {
            if (std::find(supported.begin(), supported.end(), primitive) == supported.end()) {
                continue;
@@ -411,6 +427,8 @@ public:
    }

protected:
    bool hasArgs(const State& state) const { return this->getOtherArg(state, 0) >= 0; }

    auto getPrimitive(const State& state) const {
        return static_cast<hardware::vibrator::CompositePrimitive>(this->getOtherArg(state, 0));
    }
@@ -422,6 +440,9 @@ BENCHMARK_WRAPPER(VibratorPrimitivesBench, performComposedEffect, {
    if (!hasCapabilities(result, vibrator::Capabilities::COMPOSE_EFFECTS, state)) {
        return;
    }
    if (!hasArgs(state)) {
        return;
    }

    hardware::vibrator::CompositeEffect effect;
    effect.primitive = getPrimitive(state);