Loading sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,13 @@ constexpr typename std::underlying_type<EnumType>::type asBaseType(EnumType valu constexpr size_t SensorsHidlEnvironmentV2_0::MAX_RECEIVE_BUFFER_EVENT_COUNT; void SensorsHalDeathRecipient::serviceDied( uint64_t /* cookie */, const ::android::wp<::android::hidl::base::V1_0::IBase>& /* service */) { ALOGE("Sensors HAL died (likely crashed) during test"); FAIL() << "Sensors HAL died during test"; } struct SensorsCallback : ISensorsCallback { Return<void> onDynamicSensorsConnected(const hidl_vec<SensorInfo>& /* sensorInfos */) { return Return<void>(); Loading @@ -56,6 +63,7 @@ bool SensorsHidlEnvironmentV2_0::resetHal() { if (mSensors == nullptr) { break; } mSensors->linkToDeath(mDeathRecipient, 0 /* cookie */); // Initialize FMQs mEventQueue = std::make_unique<EventMessageQueue>(MAX_RECEIVE_BUFFER_EVENT_COUNT, Loading sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.h +12 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,13 @@ using ::android::sp; using ::android::hardware::MessageQueue; class SensorsHidlTest; class SensorsHalDeathRecipient : public ::android::hardware::hidl_death_recipient { virtual void serviceDied( uint64_t cookie, const ::android::wp<::android::hidl::base::V1_0::IBase>& service) override; }; class SensorsHidlEnvironmentV2_0 : public SensorsHidlEnvironmentBase { public: using Event = ::android::hardware::sensors::V1_0::Event; Loading Loading @@ -83,6 +90,11 @@ class SensorsHidlEnvironmentV2_0 : public SensorsHidlEnvironmentBase { */ sp<android::hardware::sensors::V2_0::ISensors> mSensors; /** * Monitors the HAL for crashes, triggering test failure if seen */ sp<SensorsHalDeathRecipient> mDeathRecipient = new SensorsHalDeathRecipient(); /** * Type used to simplify the creation of the Event FMQ */ Loading sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp +25 −7 Original line number Diff line number Diff line Loading @@ -115,6 +115,12 @@ class EventCallback : public IEventCallback { // The main test class for SENSORS HIDL HAL. class SensorsHidlTest : public SensorsHidlTestBase { public: virtual void SetUp() override { // Ensure that we have a valid environment before performing tests ASSERT_NE(getSensors(), nullptr); } protected: SensorInfo defaultSensorByType(SensorType type) override; std::vector<SensorInfo> getSensorsList(); Loading Loading @@ -612,6 +618,9 @@ TEST_F(SensorsHidlTest, CallInitializeTwice) { std::unique_ptr<SensorsHidlEnvironmentTest> newEnv = std::make_unique<SensorsHidlEnvironmentTest>(); newEnv->HidlSetUp(); if (HasFatalFailure()) { return; // Exit early if setting up the new environment failed } activateAllSensors(true); // Verify that the old environment does not receive any events Loading @@ -624,8 +633,11 @@ TEST_F(SensorsHidlTest, CallInitializeTwice) { newEnv->HidlTearDown(); // Restore the test environment for future tests SensorsHidlEnvironmentV2_0::Instance()->HidlTearDown(); SensorsHidlEnvironmentV2_0::Instance()->HidlSetUp(); getEnvironment()->HidlTearDown(); getEnvironment()->HidlSetUp(); if (HasFatalFailure()) { return; // Exit early if resetting the environment failed } // Ensure that the original environment is receiving events activateAllSensors(true); Loading @@ -644,8 +656,11 @@ TEST_F(SensorsHidlTest, CleanupConnectionsOnInitialize) { // Clear the active sensor handles so they are not disabled during TearDown auto handles = mSensorHandles; mSensorHandles.clear(); getEnvironment()->TearDown(); getEnvironment()->SetUp(); getEnvironment()->HidlTearDown(); getEnvironment()->HidlSetUp(); if (HasFatalFailure()) { return; // Exit early if resetting the environment failed } // Verify no events are received until sensors are re-activated ASSERT_EQ(collectEvents(kCollectionTimeoutUs, kNumEvents, getEnvironment()).size(), 0); Loading Loading @@ -1023,8 +1038,11 @@ TEST_F(SensorsHidlTest, CleanupDirectConnectionOnInitialize) { // Clear the active direct connections so they are not stopped during TearDown auto handles = mDirectChannelHandles; mDirectChannelHandles.clear(); getEnvironment()->TearDown(); getEnvironment()->SetUp(); getEnvironment()->HidlTearDown(); getEnvironment()->HidlSetUp(); if (HasFatalFailure()) { return; // Exit early if resetting the environment failed } // Attempt to configure the direct channel and expect it to fail configDirectReport( Loading Loading
sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,13 @@ constexpr typename std::underlying_type<EnumType>::type asBaseType(EnumType valu constexpr size_t SensorsHidlEnvironmentV2_0::MAX_RECEIVE_BUFFER_EVENT_COUNT; void SensorsHalDeathRecipient::serviceDied( uint64_t /* cookie */, const ::android::wp<::android::hidl::base::V1_0::IBase>& /* service */) { ALOGE("Sensors HAL died (likely crashed) during test"); FAIL() << "Sensors HAL died during test"; } struct SensorsCallback : ISensorsCallback { Return<void> onDynamicSensorsConnected(const hidl_vec<SensorInfo>& /* sensorInfos */) { return Return<void>(); Loading @@ -56,6 +63,7 @@ bool SensorsHidlEnvironmentV2_0::resetHal() { if (mSensors == nullptr) { break; } mSensors->linkToDeath(mDeathRecipient, 0 /* cookie */); // Initialize FMQs mEventQueue = std::make_unique<EventMessageQueue>(MAX_RECEIVE_BUFFER_EVENT_COUNT, Loading
sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.h +12 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,13 @@ using ::android::sp; using ::android::hardware::MessageQueue; class SensorsHidlTest; class SensorsHalDeathRecipient : public ::android::hardware::hidl_death_recipient { virtual void serviceDied( uint64_t cookie, const ::android::wp<::android::hidl::base::V1_0::IBase>& service) override; }; class SensorsHidlEnvironmentV2_0 : public SensorsHidlEnvironmentBase { public: using Event = ::android::hardware::sensors::V1_0::Event; Loading Loading @@ -83,6 +90,11 @@ class SensorsHidlEnvironmentV2_0 : public SensorsHidlEnvironmentBase { */ sp<android::hardware::sensors::V2_0::ISensors> mSensors; /** * Monitors the HAL for crashes, triggering test failure if seen */ sp<SensorsHalDeathRecipient> mDeathRecipient = new SensorsHalDeathRecipient(); /** * Type used to simplify the creation of the Event FMQ */ Loading
sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp +25 −7 Original line number Diff line number Diff line Loading @@ -115,6 +115,12 @@ class EventCallback : public IEventCallback { // The main test class for SENSORS HIDL HAL. class SensorsHidlTest : public SensorsHidlTestBase { public: virtual void SetUp() override { // Ensure that we have a valid environment before performing tests ASSERT_NE(getSensors(), nullptr); } protected: SensorInfo defaultSensorByType(SensorType type) override; std::vector<SensorInfo> getSensorsList(); Loading Loading @@ -612,6 +618,9 @@ TEST_F(SensorsHidlTest, CallInitializeTwice) { std::unique_ptr<SensorsHidlEnvironmentTest> newEnv = std::make_unique<SensorsHidlEnvironmentTest>(); newEnv->HidlSetUp(); if (HasFatalFailure()) { return; // Exit early if setting up the new environment failed } activateAllSensors(true); // Verify that the old environment does not receive any events Loading @@ -624,8 +633,11 @@ TEST_F(SensorsHidlTest, CallInitializeTwice) { newEnv->HidlTearDown(); // Restore the test environment for future tests SensorsHidlEnvironmentV2_0::Instance()->HidlTearDown(); SensorsHidlEnvironmentV2_0::Instance()->HidlSetUp(); getEnvironment()->HidlTearDown(); getEnvironment()->HidlSetUp(); if (HasFatalFailure()) { return; // Exit early if resetting the environment failed } // Ensure that the original environment is receiving events activateAllSensors(true); Loading @@ -644,8 +656,11 @@ TEST_F(SensorsHidlTest, CleanupConnectionsOnInitialize) { // Clear the active sensor handles so they are not disabled during TearDown auto handles = mSensorHandles; mSensorHandles.clear(); getEnvironment()->TearDown(); getEnvironment()->SetUp(); getEnvironment()->HidlTearDown(); getEnvironment()->HidlSetUp(); if (HasFatalFailure()) { return; // Exit early if resetting the environment failed } // Verify no events are received until sensors are re-activated ASSERT_EQ(collectEvents(kCollectionTimeoutUs, kNumEvents, getEnvironment()).size(), 0); Loading Loading @@ -1023,8 +1038,11 @@ TEST_F(SensorsHidlTest, CleanupDirectConnectionOnInitialize) { // Clear the active direct connections so they are not stopped during TearDown auto handles = mDirectChannelHandles; mDirectChannelHandles.clear(); getEnvironment()->TearDown(); getEnvironment()->SetUp(); getEnvironment()->HidlTearDown(); getEnvironment()->HidlSetUp(); if (HasFatalFailure()) { return; // Exit early if resetting the environment failed } // Attempt to configure the direct channel and expect it to fail configDirectReport( Loading