From 25cd9d67d5080f5f53cce715f679d923ca85c262 Mon Sep 17 00:00:00 2001 From: Yu-Han Yang Date: Thu, 13 Oct 2022 23:06:31 +0000 Subject: [PATCH] Call close() in TearDown() Bug: 251580081 Test: atest VtsHalGnssTargetTest Change-Id: Ieb02205f434899f7e9c5db32cfa7172788c39fa6 --- gnss/aidl/android/hardware/gnss/IGnss.aidl | 2 +- gnss/aidl/vts/gnss_hal_test.cpp | 11 +++++++++++ gnss/aidl/vts/gnss_hal_test.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gnss/aidl/android/hardware/gnss/IGnss.aidl b/gnss/aidl/android/hardware/gnss/IGnss.aidl index f0b583d164..aaafe7f583 100644 --- a/gnss/aidl/android/hardware/gnss/IGnss.aidl +++ b/gnss/aidl/android/hardware/gnss/IGnss.aidl @@ -104,7 +104,7 @@ interface IGnss { * * The framework calls this method to instruct the GPS engine to prepare for serving requests * from the framework. The GNSS HAL implementation must respond to all GNSS requests from the - * framework upon successful return from this method until cleanup() method is called to + * framework upon successful return from this method until close() method is called to * close this interface. * * @param callback Callback interface for IGnss. diff --git a/gnss/aidl/vts/gnss_hal_test.cpp b/gnss/aidl/vts/gnss_hal_test.cpp index 0e1218e40c..3907f57dc7 100644 --- a/gnss/aidl/vts/gnss_hal_test.cpp +++ b/gnss/aidl/vts/gnss_hal_test.cpp @@ -107,6 +107,17 @@ void GnssHalTest::SetUpGnssCallback() { } } +void GnssHalTest::TearDown() { + GnssHalTestTemplate::TearDown(); + if (aidl_gnss_hal_ != nullptr) { + aidl_gnss_hal_->close(); + aidl_gnss_hal_ = nullptr; + } + + // Set to nullptr to destruct the callback event queues and warn of any unprocessed events. + aidl_gnss_cb_ = nullptr; +} + void GnssHalTest::CheckLocation(const GnssLocation& location, bool check_speed) { Utils::checkLocation(location, check_speed, /* check_more_accuracies= */ true); } diff --git a/gnss/aidl/vts/gnss_hal_test.h b/gnss/aidl/vts/gnss_hal_test.h index 645fc824e0..c49c1b9204 100644 --- a/gnss/aidl/vts/gnss_hal_test.h +++ b/gnss/aidl/vts/gnss_hal_test.h @@ -64,6 +64,7 @@ class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate< virtual void SetUp() override; virtual void SetUpGnssCallback() override; + virtual void TearDown() override; void CheckLocation(const android::hardware::gnss::GnssLocation& location, const bool check_speed);