Update fallback policy for fast fallback.
[ Merge of http://go/wvgerrit/136329 ] CDM core has been updated to support very short fallback durations in the case of failures during OTA keybox provisioning. This is intended to be used during testing via specialized developer apps or GTS tests. Bug: 187646550 Test: Android unit tests Change-Id: I8a75d2e1c404d6caed535b087e8dd29da5c21b83
This commit is contained in:
@@ -16,11 +16,6 @@ namespace okp {
|
||||
using UniqueLock = std::unique_lock<std::mutex>;
|
||||
namespace {
|
||||
constexpr int64_t kErrorTime = -1;
|
||||
|
||||
int64_t GenerateInitialBackoffDuration() {
|
||||
return static_cast<int64_t>(CdmRandom::RandomInRange(
|
||||
kMinInitialBackoffDuration, kMaxInitialBackoffDuration));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
@@ -131,11 +126,11 @@ void SystemFallbackPolicy::TriggerFallback() {
|
||||
info_.SetFirstCheckedTime(current_time);
|
||||
}
|
||||
info_.SetBackoffStartTime(GetCurrentTime());
|
||||
if (info_.HasBackoffDuration()) {
|
||||
// Doubling backoff duration for exponential backoff.
|
||||
if (!fast_fallback_ && info_.HasBackoffDuration()) {
|
||||
// Doubling backoff duration for exponential backoff. Except when
|
||||
// performing fast fallback off.
|
||||
info_.DoubleBackoffDuration();
|
||||
} else {
|
||||
// Use a random backoff period to avoid server spam across all devices.
|
||||
info_.SetBackoffDuration(GenerateInitialBackoffDuration());
|
||||
}
|
||||
StoreInfo();
|
||||
@@ -185,6 +180,37 @@ bool SystemFallbackPolicy::IsInFallbackMode() {
|
||||
return false; // Only stored if previously in fallback and has ended.
|
||||
}
|
||||
|
||||
void SystemFallbackPolicy::SetDefaultBackoffDurationRules() {
|
||||
UniqueLock lock(mutex_);
|
||||
fast_fallback_ = false;
|
||||
if (state() == SystemState::kFallbackMode) {
|
||||
LOGI("Ending fallback");
|
||||
EndBackoffPeriod();
|
||||
}
|
||||
info_.ClearBackoffDuration();
|
||||
StoreInfo();
|
||||
}
|
||||
|
||||
void SystemFallbackPolicy::SetFastBackoffDurationRules() {
|
||||
UniqueLock lock(mutex_);
|
||||
fast_fallback_ = true;
|
||||
if (state() == SystemState::kFallbackMode) {
|
||||
LOGI("Ending fallback");
|
||||
EndBackoffPeriod();
|
||||
}
|
||||
info_.ClearBackoffDuration();
|
||||
StoreInfo();
|
||||
}
|
||||
|
||||
int64_t SystemFallbackPolicy::GenerateInitialBackoffDuration() {
|
||||
if (fast_fallback_) {
|
||||
return kFastBackoffDuration;
|
||||
}
|
||||
// Use a random backoff period to avoid server spam across all devices.
|
||||
return static_cast<int64_t>(CdmRandom::RandomInRange(
|
||||
kMinInitialBackoffDuration, kMaxInitialBackoffDuration));
|
||||
}
|
||||
|
||||
int64_t SystemFallbackPolicy::GetSecondsSinceBackoffStart() const {
|
||||
if (!info_.HasBackoffStartTime()) return 0;
|
||||
const int64_t backoff_start_time = info_.backoff_start_time();
|
||||
|
||||
Reference in New Issue
Block a user