CDM Core: Removed support for v15 licenses.
[ Merge of http://go/wvgerrit/160000 ] OEMCrypto v15 licenses made use of several now-obsolete API functions of OEMCrypto (mainly LoadKeys and RefreshKeys). All license handled by the CDM must be v16 or newer. The CDM can now rely on all license requests/responses containing a core message, using v16 policy timers, and requires loading using LoadLicense() / LoadRenewal(). Bug: 252670759 Test: run_x86_64_tests and policy_engine_unittest Change-Id: I3f65a6ec0326b4c89d1919b8911e065079cb90d2
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "clock.h"
|
||||
#include "log.h"
|
||||
#include "policy_timers_v15.h"
|
||||
#include "policy_timers_v16.h"
|
||||
#include "properties.h"
|
||||
#include "string_conversions.h"
|
||||
@@ -30,14 +29,11 @@ namespace wvcdm {
|
||||
PolicyEngine::PolicyEngine(CdmSessionId session_id,
|
||||
WvCdmEventListener* event_listener,
|
||||
CryptoSession* crypto_session)
|
||||
: license_state_(kLicenseStateInitial),
|
||||
license_state_update_deadline_(0),
|
||||
last_recorded_current_time_(0),
|
||||
session_id_(session_id),
|
||||
: session_id_(session_id),
|
||||
event_listener_(event_listener),
|
||||
license_keys_(new LicenseKeys(crypto_session->GetSecurityLevel())),
|
||||
policy_timers_(new PolicyTimersV15),
|
||||
clock_(new wvutil::Clock) {
|
||||
policy_timers_(new PolicyTimersV16()),
|
||||
clock_(new wvutil::Clock()) {
|
||||
InitDevice(crypto_session);
|
||||
}
|
||||
|
||||
@@ -46,11 +42,10 @@ PolicyEngine::~PolicyEngine() {}
|
||||
bool PolicyEngine::CanDecryptContent(const KeyId& key_id) {
|
||||
if (license_keys_->IsContentKey(key_id)) {
|
||||
return license_keys_->CanDecryptContent(key_id);
|
||||
} else {
|
||||
LOGE("Provided content key is not in license: key_id = %s",
|
||||
wvutil::b2a_hex(key_id).c_str());
|
||||
return false;
|
||||
}
|
||||
LOGE("Provided content key is not in license: key_id = %s",
|
||||
wvutil::b2a_hex(key_id).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
CdmKeyStatus PolicyEngine::GetKeyStatus(const KeyId& key_id) {
|
||||
@@ -104,7 +99,8 @@ void PolicyEngine::OnTimerEvent() {
|
||||
}
|
||||
|
||||
// If we have passed the grace period, the expiration will update.
|
||||
if (policy_timers_->HasPassedGracePeriod(current_time)) {
|
||||
if (license_state_ != kLicenseStateInitial &&
|
||||
policy_timers_->HasPassedGracePeriod(current_time)) {
|
||||
NotifyExpirationUpdate(current_time);
|
||||
}
|
||||
|
||||
@@ -172,9 +168,7 @@ void PolicyEngine::OnTimerEvent() {
|
||||
}
|
||||
|
||||
void PolicyEngine::SetLicense(const License& license,
|
||||
bool supports_core_messages,
|
||||
bool defer_license_state_update) {
|
||||
if (supports_core_messages) policy_timers_.reset(new PolicyTimersV16());
|
||||
license_id_.CopyFrom(license.id());
|
||||
license_keys_->SetFromLicense(license);
|
||||
policy_timers_->SetLicense(license);
|
||||
@@ -186,11 +180,8 @@ void PolicyEngine::SetEntitledLicenseKeys(
|
||||
license_keys_->SetEntitledKeys(entitled_keys);
|
||||
}
|
||||
|
||||
void PolicyEngine::SetLicenseForRelease(const License& license,
|
||||
bool supports_core_messages) {
|
||||
if (supports_core_messages) policy_timers_.reset(new PolicyTimersV16());
|
||||
void PolicyEngine::SetLicenseForRelease(const License& license) {
|
||||
license_id_.CopyFrom(license.id());
|
||||
|
||||
// Expire any old keys.
|
||||
NotifyKeysChange(kKeyStatusExpired);
|
||||
policy_timers_->SetLicense(license);
|
||||
@@ -211,18 +202,20 @@ void PolicyEngine::UpdateLicense(const License& license,
|
||||
|
||||
// if renewal, discard license if version has not been updated
|
||||
if (license_state_ != kLicenseStateInitial) {
|
||||
if (license.id().version() > license_id_.version())
|
||||
if (license.id().version() > license_id_.version()) {
|
||||
license_id_.CopyFrom(license.id());
|
||||
else
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const int64_t current_time = GetCurrentTime();
|
||||
policy_timers_->UpdateLicense(current_time, license);
|
||||
if (defer_license_state_update)
|
||||
if (defer_license_state_update) {
|
||||
license_state_update_deadline_ = current_time + kLicenseStateUpdateDelay;
|
||||
else
|
||||
} else {
|
||||
UpdateLicenseState(current_time);
|
||||
}
|
||||
}
|
||||
|
||||
void PolicyEngine::UpdateLicenseState(int64_t current_time) {
|
||||
@@ -410,17 +403,19 @@ void PolicyEngine::NotifyKeysChange(CdmKeyStatus new_status) {
|
||||
void PolicyEngine::NotifyExpirationUpdate(int64_t current_time) {
|
||||
int64_t expiry_time;
|
||||
if (policy_timers_->UpdateExpirationTime(current_time, &expiry_time)) {
|
||||
if (event_listener_)
|
||||
if (event_listener_) {
|
||||
event_listener_->OnExpirationUpdate(session_id_, expiry_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t PolicyEngine::GetCurrentTime() {
|
||||
int64_t current_time = clock_->GetCurrentTime();
|
||||
if (current_time + kClockSkewDelta < last_recorded_current_time_)
|
||||
if (current_time + kClockSkewDelta < last_recorded_current_time_) {
|
||||
current_time = last_recorded_current_time_;
|
||||
else
|
||||
} else {
|
||||
last_recorded_current_time_ = current_time;
|
||||
}
|
||||
return current_time;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user