diff options
author | Anthony Stange <stange@google.com> | 2019-07-12 17:55:30 -0400 |
---|---|---|
committer | Anthony Stange <stange@google.com> | 2019-07-15 19:17:25 +0000 |
commit | 65945cfb150ee6f046daa472b4ce71729ee69f1b (patch) | |
tree | 85acf91546c9ec3b070d9827bd90d020547f917d /sensors | |
parent | c69700441e8d48607ab186e427da18fe094ed7e6 (diff) | |
download | android_hardware_interfaces-65945cfb150ee6f046daa472b4ce71729ee69f1b.tar.gz android_hardware_interfaces-65945cfb150ee6f046daa472b4ce71729ee69f1b.tar.bz2 android_hardware_interfaces-65945cfb150ee6f046daa472b4ce71729ee69f1b.zip |
Verify mPollThread is joinable before detaching
If HidlSetUp() bails before startPollingThread() is called (which can
happen if the HAL isn't implemented on the given device), mPollThread
will initialize with the default constructor resulting in joinable()
returning false which means calling detach() throws an exception.
Checking joinable() before detaching allows the test suite to be skipped
successfully.
Fixes: 136736906
Test: Run vts-tradefed on VtsHalSensorsV1_0Target and verify that it is
skipped successfully on a device that doesn't support HAL 1.0
Change-Id: Ie685ae2dc314edb8df2f3cc7112141a2f5e46008
Diffstat (limited to 'sensors')
-rw-r--r-- | sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp b/sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp index affdf8b6b..fa0e2e9bf 100644 --- a/sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp +++ b/sensors/common/vts/utils/SensorsHidlEnvironmentBase.cpp @@ -29,7 +29,9 @@ void SensorsHidlEnvironmentBase::HidlSetUp() { void SensorsHidlEnvironmentBase::HidlTearDown() { mStopThread = true; - mPollThread.detach(); + if (mPollThread.joinable()) { + mPollThread.detach(); + } } void SensorsHidlEnvironmentBase::catEvents(std::vector<Event>* output) { |