Merge changes I5cbfcc73,I3070b3f3 into udc-dev am: 75c1b88603 am: 486c57f783 am: a7bf01ce2c

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/23094536

Change-Id: I6b5f5a4b958c58ab5de8653dfaa238deafee9058
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Rahul Frias
2023-05-13 06:00:07 +00:00
committed by Automerger Merge Worker
8 changed files with 2446 additions and 13 deletions

View File

@@ -119,7 +119,7 @@ class PolicyTimers {
// started playing. This takes into account GetHardLicenseExpiryTime.
virtual int64_t GetExpiryTime(int64_t current_time,
bool ignore_soft_enforce_playback_duration);
virtual int64_t GetRentalExpiryTime(int64_t current_time);
virtual int64_t GetRenewalStartTime() { return renewal_start_time_; }
// This is the current policy information for this license. This gets updated
@@ -139,7 +139,6 @@ class PolicyTimers {
private:
// Gets the clock time that the rental duration or playback will expire.
virtual int64_t GetRentalExpiryTime(int64_t current_time);
virtual int64_t GetPlaybackExpiryTime(
int64_t current_time, bool ignore_soft_enforce_playback_duration);
bool HasRentalOrPlaybackDurationExpired(int64_t current_time);

View File

@@ -47,6 +47,7 @@ class PolicyTimersV18 : public PolicyTimers {
// Indicates whether this is an initial license or a renewal
bool license_renewal_ = false;
bool renew_on_first_decrypt_ = false;
bool can_renew_ = false;
CORE_DISALLOW_COPY_AND_ASSIGN(PolicyTimersV18);
};

View File

@@ -52,6 +52,8 @@ constexpr uint32_t RESOURCE_RATING_TIER_MAX = RESOURCE_RATING_TIER_VERY_HIGH;
// OEMCrypto features by version
constexpr uint32_t OEM_CRYPTO_API_VERSION_SUPPORTS_RESOURCE_RATING_TIER = 15;
constexpr uint32_t OEM_CRYPTO_API_VERSION_SUPPORTS_PROV40_CORE_MESSAGE = 18;
constexpr uint32_t OEM_CRYPTO_API_VERSION_SUPPORTS_INITIAL_RENEWAL_DELAY_BASE =
18;
constexpr char SESSION_ID_PREFIX[] = "sid";
constexpr char ATSC_KEY_SET_ID_PREFIX[] = "atscksid";

View File

@@ -364,6 +364,11 @@ CdmResponseType ClientIdentification::Prepare(
}
}
if (api_version >=
OEM_CRYPTO_API_VERSION_SUPPORTS_INITIAL_RENEWAL_DELAY_BASE) {
client_capabilities->set_initial_renewal_delay_base(true);
}
return CdmResponseType(NO_ERROR);
}

View File

@@ -1149,6 +1149,9 @@ message ClientIdentification {
// Support is optional.
// Value is only required to be set for license requests.
optional WatermarkingSupport watermarking_support = 13;
// Indicate whether or not `initial_renewal_delay_base` is supported by the
// client.
optional bool initial_renewal_delay_base = 14 [default = false];
}
message ClientCredentials {

View File

@@ -9,6 +9,7 @@
#include "clock.h"
#include "log.h"
#include "policy_timers_v16.h"
#include "policy_timers_v18.h"
#include "properties.h"
#include "string_conversions.h"
#include "wv_cdm_constants.h"
@@ -21,7 +22,7 @@ namespace {
const int kCdmPolicyTimerDurationSeconds = 1;
const int kClockSkewDelta = 5; // seconds
const int64_t kLicenseStateUpdateDelay = 20; // seconds
const uint32_t kMinOemCryptoApiVersionSupportsRenewalDelayBase = 18;
} // namespace
namespace wvcdm {
@@ -32,8 +33,17 @@ PolicyEngine::PolicyEngine(CdmSessionId session_id,
: session_id_(session_id),
event_listener_(event_listener),
license_keys_(new LicenseKeys(crypto_session->GetSecurityLevel())),
policy_timers_(new PolicyTimersV16()),
clock_(new wvutil::Clock()) {
uint32_t version = 0;
if (crypto_session->GetApiVersion(&version)) {
if (version >= kMinOemCryptoApiVersionSupportsRenewalDelayBase) {
policy_timers_.reset(new PolicyTimersV18());
}
}
if (policy_timers_ == nullptr) {
policy_timers_.reset(new PolicyTimersV16());
}
InitDevice(crypto_session);
}
@@ -121,7 +131,8 @@ void PolicyEngine::OnTimerEvent() {
// Test to determine if renewal should be attempted.
switch (license_state_) {
case kLicenseStateCanPlay: {
if (policy_timers_->HasRenewalDelayExpired(current_time)) {
if (policy_timers_->HasRenewalDelayExpired(current_time) &&
policy_timers_->get_policy().can_renew()) {
renewal_needed = true;
}
// HDCP may change, so force a check.
@@ -130,12 +141,15 @@ void PolicyEngine::OnTimerEvent() {
}
case kLicenseStateNeedRenewal: {
if (policy_timers_->get_policy().can_renew()) {
renewal_needed = true;
}
break;
}
case kLicenseStateWaitingLicenseUpdate: {
if (policy_timers_->HasRenewalRetryIntervalExpired(current_time)) {
if (policy_timers_->HasRenewalRetryIntervalExpired(current_time) &&
policy_timers_->get_policy().can_renew()) {
renewal_needed = true;
}
break;
@@ -249,7 +263,8 @@ bool PolicyEngine::BeginDecryption() {
case kLicenseStateWaitingLicenseUpdate:
policy_timers_->BeginDecryption(current_time);
if (policy_timers_->get_policy().renew_with_usage()) {
if (policy_timers_->get_policy().renew_with_usage() &&
policy_timers_->get_policy().can_renew()) {
license_state_ = kLicenseStateNeedRenewal;
}
NotifyExpirationUpdate(current_time);

View File

@@ -18,6 +18,7 @@ bool PolicyTimersV18::UpdateLicense(int64_t current_time,
if (!license.has_policy()) return false;
policy_.MergeFrom(license.policy());
can_renew_ = policy_.can_renew();
// some basic license validation
// license start time needs to be specified in the initial response
@@ -36,10 +37,18 @@ bool PolicyTimersV18::UpdateLicense(int64_t current_time,
case video_widevine::License_Policy_TimerDelayBase_LICENSE_START:
renewal_start_time_ = license.license_start_time();
break;
case video_widevine::License_Policy_TimerDelayBase_LICENSE_LOAD:
case video_widevine::License_Policy_TimerDelayBase_LICENSE_LOAD: {
const int64_t rental_expiry_time = GetRentalExpiryTime(current_time);
if ((rental_expiry_time == NEVER_EXPIRES) ||
(rental_expiry_time >= current_time)) {
renewal_start_time_ = current_time;
break;
BeginDecryption(current_time);
} else {
can_renew_ = false;
}
} break;
case video_widevine::License_Policy_TimerDelayBase_FIRST_DECRYPT:
renew_on_first_decrypt_ = true;
break;
default:
LOGE("Unrecognized initial_renewal_delay_base value = %d",
@@ -79,7 +88,7 @@ void PolicyTimersV18::BeginDecryption(int64_t current_time) {
bool PolicyTimersV18::HasRenewalDelayExpired(int64_t current_time) {
if (renew_on_first_decrypt_ && playback_start_time_ == 0) return false;
return policy_.can_renew() &&
return can_renew_ && (policy_.renewal_delay_seconds() > 0) &&
(renewal_start_time_ + policy_.renewal_delay_seconds() <=
current_time);
}

File diff suppressed because it is too large Load Diff