Merge "Add manifest for IVehicle"
diff --git a/neuralnetworks/1.3/vts/functional/ValidateModel.cpp b/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
index 4c0100e..e590fda 100644
--- a/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
+++ b/neuralnetworks/1.3/vts/functional/ValidateModel.cpp
@@ -535,13 +535,18 @@
removeValueAndDecrementGreaterValues(&model->main.outputIndexes, index);
}
-static bool removeOperandSkip(size_t operand, const Model& model) {
+static bool removeOperandSkip(size_t operandIndex, const Model& model) {
+ const Operand& operand = model.main.operands[operandIndex];
+ if (operand.numberOfConsumers == 0) {
+ // Removing an unused operand has no effect.
+ return true;
+ }
for (const Operation& operation : model.main.operations) {
// Skip removeOperandTest for the following operations.
// - SPLIT's outputs are not checked during prepareModel.
if (operation.type == OperationType::SPLIT) {
- for (const size_t outOprand : operation.outputs) {
- if (operand == outOprand) {
+ for (const size_t index : operation.outputs) {
+ if (index == operandIndex) {
return true;
}
}
@@ -556,8 +561,8 @@
operation.type == OperationType::UNIDIRECTIONAL_SEQUENCE_RNN ||
operation.type == OperationType::BIDIRECTIONAL_SEQUENCE_LSTM ||
operation.type == OperationType::BIDIRECTIONAL_SEQUENCE_RNN) {
- for (const size_t outOprand : operation.outputs) {
- if (operand == outOprand) {
+ for (const size_t index : operation.outputs) {
+ if (index == operandIndex) {
return true;
}
}
diff --git a/vibrator/aidl/default/Vibrator.cpp b/vibrator/aidl/default/Vibrator.cpp
index 9236b95..1a8fd3b 100644
--- a/vibrator/aidl/default/Vibrator.cpp
+++ b/vibrator/aidl/default/Vibrator.cpp
@@ -163,6 +163,10 @@
}
LOG(INFO) << "triggering primitive " << static_cast<int>(e.primitive) << " @ scale "
<< e.scale;
+
+ int32_t durationMs;
+ getPrimitiveDuration(e.primitive, &durationMs);
+ usleep(durationMs * 1000);
}
if (callback != nullptr) {
diff --git a/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp b/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp
index 411fe7a..9a1b660 100644
--- a/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp
+++ b/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp
@@ -33,6 +33,7 @@
using android::hardware::vibrator::Effect;
using android::hardware::vibrator::EffectStrength;
using android::hardware::vibrator::IVibrator;
+using std::chrono::high_resolution_clock;
const std::vector<Effect> kEffects{android::enum_range<Effect>().begin(),
android::enum_range<Effect>().end()};
@@ -381,26 +382,52 @@
}
TEST_P(VibratorAidl, ComposeCallback) {
+ constexpr std::chrono::milliseconds allowedLatency{10};
+
if (capabilities & IVibrator::CAP_COMPOSE_EFFECTS) {
- std::promise<void> completionPromise;
- std::future<void> completionFuture{completionPromise.get_future()};
- sp<CompletionCallback> callback =
- new CompletionCallback([&completionPromise] { completionPromise.set_value(); });
- CompositePrimitive primitive = CompositePrimitive::CLICK;
- CompositeEffect effect;
- std::vector<CompositeEffect> composite;
- int32_t duration;
+ std::vector<CompositePrimitive> supported;
- effect.delayMs = 0;
- effect.primitive = primitive;
- effect.scale = 1.0f;
- composite.emplace_back(effect);
+ ASSERT_TRUE(vibrator->getSupportedPrimitives(&supported).isOk());
- EXPECT_EQ(Status::EX_NONE,
- vibrator->getPrimitiveDuration(primitive, &duration).exceptionCode());
- EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, callback).exceptionCode());
- EXPECT_EQ(completionFuture.wait_for(std::chrono::milliseconds(duration * 2)),
- std::future_status::ready);
+ for (auto primitive : supported) {
+ if (primitive == CompositePrimitive::NOOP) {
+ continue;
+ }
+
+ std::promise<void> completionPromise;
+ std::future<void> completionFuture{completionPromise.get_future()};
+ sp<CompletionCallback> callback =
+ new CompletionCallback([&completionPromise] { completionPromise.set_value(); });
+ CompositeEffect effect;
+ std::vector<CompositeEffect> composite;
+ int32_t durationMs;
+ std::chrono::milliseconds duration;
+ std::chrono::time_point<high_resolution_clock> start, end;
+ std::chrono::milliseconds elapsed;
+
+ effect.delayMs = 0;
+ effect.primitive = primitive;
+ effect.scale = 1.0f;
+ composite.emplace_back(effect);
+
+ EXPECT_EQ(Status::EX_NONE,
+ vibrator->getPrimitiveDuration(primitive, &durationMs).exceptionCode())
+ << toString(primitive);
+ duration = std::chrono::milliseconds(durationMs);
+
+ EXPECT_EQ(Status::EX_NONE, vibrator->compose(composite, callback).exceptionCode())
+ << toString(primitive);
+ start = high_resolution_clock::now();
+
+ EXPECT_EQ(completionFuture.wait_for(duration + allowedLatency),
+ std::future_status::ready)
+ << toString(primitive);
+ end = high_resolution_clock::now();
+
+ elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
+ EXPECT_LE(elapsed.count(), (duration + allowedLatency).count()) << toString(primitive);
+ EXPECT_GE(elapsed.count(), (duration - allowedLatency).count()) << toString(primitive);
+ }
}
}