Merge "Expose timestats.proto to the java host library"
diff --git a/services/vibratorservice/benchmarks/VibratorHalControllerBenchmarks.cpp b/services/vibratorservice/benchmarks/VibratorHalControllerBenchmarks.cpp
index 6589f74..0acff06 100644
--- a/services/vibratorservice/benchmarks/VibratorHalControllerBenchmarks.cpp
+++ b/services/vibratorservice/benchmarks/VibratorHalControllerBenchmarks.cpp
@@ -302,11 +302,13 @@
}
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 @@
}
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 @@
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 @@
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, performEffect, {
+ if (!hasArgs(state)) {
+ return;
+ }
+
auto effect = getEffect(state);
auto strength = getStrength(state);
auto callback = []() {};
@@ -394,11 +408,13 @@
}
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 @@
}
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 @@
if (!hasCapabilities(result, vibrator::Capabilities::COMPOSE_EFFECTS, state)) {
return;
}
+ if (!hasArgs(state)) {
+ return;
+ }
hardware::vibrator::CompositeEffect effect;
effect.primitive = getPrimitive(state);