From 226761ce9d060de51a9583a20ff796e2f6a4d406 Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Tue, 14 Apr 2020 23:27:24 -0700 Subject: [PATCH] Add the missing unregisterCallback call The sensor reading thread continues producing event and refers to the already destroyed callback object which causes a crash in SensorsHidlEnvironmentBase::addEvent. Bug: 153754380 Test: atest VtsHalSensorsV2_0TargetTest Signed-off-by: Roman Kiryanov Change-Id: I3017afe670e5a53d0d7444b3d5b34ba34f3567e3 Merged-In: Id7fb72c42dc67f89ceef93d937241e1584b853e7 --- sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp index 540529d8eb..d0ebe4d36f 100644 --- a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp +++ b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp @@ -898,6 +898,8 @@ TEST_P(SensorsHidlTest, NoStaleEvents) { callback.waitForEvents(sensors, kFiveHundredMs + (5 * maxMinDelay)); activateAllSensors(false); + getEnvironment()->unregisterCallback(); + for (const SensorInfo& sensor : sensors) { // Skip sensors that did not previously report an event if (lastEventTimestampMap.find(sensor.sensorHandle) == lastEventTimestampMap.end()) {