Skip to content

Commit

Permalink
Defined a constant for default delayedActionTime
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamdp committed Jan 21, 2022
1 parent 4f66507 commit 01fa17d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/platform/GenericOTARequestorDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ GenericOTARequestorDriver * ToDriver(void * context)
return static_cast<GenericOTARequestorDriver *>(context);
}

constexpr System::Clock::Seconds32 kDefaultDelayedActionTime = System::Clock::Seconds32(120);

} // namespace

bool GenericOTARequestorDriver::CanConsent()
Expand Down Expand Up @@ -60,13 +62,12 @@ void GenericOTARequestorDriver::UpdateNotFound(UpdateNotFoundReason reason, Syst
{
VerifyOrDie(mRequestor != nullptr);

System::Clock::Seconds32 delayedActionTime = System::Clock::Seconds32(120);
if (delay > delayedActionTime)
if (delay < kDefaultDelayedActionTime)
{
delayedActionTime = delay;
delay = kDefaultDelayedActionTime;
}

ScheduleDelayedAction(UpdateFailureState::kQuerying, delayedActionTime,
ScheduleDelayedAction(UpdateFailureState::kQuerying, delay,
[](System::Layer *, void * context) { ToDriver(context)->mRequestor->TriggerImmediateQuery(); });
}

Expand All @@ -87,13 +88,12 @@ void GenericOTARequestorDriver::UpdateSuspended(System::Clock::Seconds32 delay)
{
VerifyOrDie(mRequestor != nullptr);

System::Clock::Seconds32 delayedActionTime = System::Clock::Seconds32(120);
if (delay > delayedActionTime)
if (delay < kDefaultDelayedActionTime)
{
delayedActionTime = delay;
delay = kDefaultDelayedActionTime;
}

ScheduleDelayedAction(UpdateFailureState::kAwaitingNextAction, delayedActionTime,
ScheduleDelayedAction(UpdateFailureState::kAwaitingNextAction, delay,
[](System::Layer *, void * context) { ToDriver(context)->mRequestor->ApplyUpdate(); });
}

Expand Down

0 comments on commit 01fa17d

Please sign in to comment.