From 1425920880059d392e5beffe3d14f600c223cede Mon Sep 17 00:00:00 2001 From: "Irene Siu (Apple)" Date: Thu, 26 May 2022 00:51:25 -0700 Subject: [PATCH] [OTA-R] Use delayedActionTime to delay QueryImage when supplied (#18832) * Fix for Issue #18432. * Remove debug code. --- .../ota-requestor/DefaultOTARequestorDriver.cpp | 10 +++++----- .../clusters/ota-requestor/DefaultOTARequestorDriver.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp index 85de14f13d0958..52d5ad0798be2e 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp @@ -186,17 +186,17 @@ CHIP_ERROR DefaultOTARequestorDriver::UpdateNotFound(UpdateNotFoundReason reason case UpdateNotFoundReason::kUpToDate: break; case UpdateNotFoundReason::kBusy: { - status = ScheduleQueryRetry(true); + status = ScheduleQueryRetry(true, chip::max(kDefaultDelayedActionTime, delay)); if (status == CHIP_ERROR_MAX_RETRY_EXCEEDED) { // If max retry exceeded with current provider, try a different provider - status = ScheduleQueryRetry(false); + status = ScheduleQueryRetry(false, chip::max(kDefaultDelayedActionTime, delay)); } break; } case UpdateNotFoundReason::kNotAvailable: { // Schedule a query only if a different provider is available - status = ScheduleQueryRetry(false); + status = ScheduleQueryRetry(false, chip::max(kDefaultDelayedActionTime, delay)); break; } } @@ -449,7 +449,7 @@ bool DefaultOTARequestorDriver::GetNextProviderLocation(ProviderLocationType & p return false; } -CHIP_ERROR DefaultOTARequestorDriver::ScheduleQueryRetry(bool trySameProvider) +CHIP_ERROR DefaultOTARequestorDriver::ScheduleQueryRetry(bool trySameProvider, System::Clock::Seconds32 delay) { CHIP_ERROR status = CHIP_NO_ERROR; @@ -483,7 +483,7 @@ CHIP_ERROR DefaultOTARequestorDriver::ScheduleQueryRetry(bool trySameProvider) if (status == CHIP_NO_ERROR) { ChipLogProgress(SoftwareUpdate, "Scheduling a retry"); - ScheduleDelayedAction(kDefaultDelayedActionTime, StartDelayTimerHandler, this); + ScheduleDelayedAction(delay, StartDelayTimerHandler, this); } return status; diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h index 2ff7e5d3526f26..1fa0ba07f8f780 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h @@ -97,7 +97,7 @@ class DefaultOTARequestorDriver : public OTARequestorDriver void CancelDelayedAction(System::TimerCompleteCallback action, void * aAppState); bool ProviderLocationsEqual(const ProviderLocationType & a, const ProviderLocationType & b); // Return value of CHIP_NO_ERROR indicates a query retry has been successfully scheduled. - CHIP_ERROR ScheduleQueryRetry(bool trySameProvider); + CHIP_ERROR ScheduleQueryRetry(bool trySameProvider, System::Clock::Seconds32 delay); OTARequestorInterface * mRequestor = nullptr; OTAImageProcessorInterface * mImageProcessor = nullptr;