Implement Method to Release Licenses Without a Server Roundtrip
Merge from Widevine repo of http://go/wvgerrit/52480 Partners have asked for a way to release offline licenses without using a release message. This is typically used by cable partners who are caching licenses ahead of time and do not care about usage statistics. As part of implementing this request, CdmSession::DeleteLicense() was renamed to reflect that it only deletes the *files* associated with a license, and a new CdmSession::DeleteLicense() has been written that also cleans up other related data. Bug: 77955334 Test: CE CDM Unit Tests Test: tested as part of http://go/ag/4674759 Change-Id: I00d6e20935c5fecb3ac9be6757c0f191d85c6bd6
This commit is contained in:
@@ -113,8 +113,18 @@ class CdmEngine {
|
||||
virtual CdmResponseType RestoreKey(const CdmSessionId& session_id,
|
||||
const CdmKeySetId& key_set_id);
|
||||
|
||||
// This method releases the crypto resources and policy resources associated
|
||||
// with the given session. This renders the session largely useless. It is
|
||||
// preferable to close the session outright. This method does not delete any
|
||||
// stored offline data associated with the session.
|
||||
virtual CdmResponseType RemoveKeys(const CdmSessionId& session_id);
|
||||
|
||||
// This method removes all offline data associated with the session, such as
|
||||
// offline keys and usage info. It should be used with care, as it deletes the
|
||||
// info immediately and without using a release message, so the server is not
|
||||
// able to receive usage info or track releases for offline licenses.
|
||||
virtual CdmResponseType RemoveLicense(const CdmSessionId& session_id);
|
||||
|
||||
// Construct valid renewal request for the current session keys.
|
||||
virtual CdmResponseType GenerateRenewalRequest(
|
||||
const CdmSessionId& session_id, CdmKeyRequest* key_request);
|
||||
|
||||
@@ -153,8 +153,13 @@ class CdmSession {
|
||||
// preferable to simply delete this object rather than call this method.
|
||||
virtual CdmResponseType RemoveKeys();
|
||||
|
||||
// Delete current license and matching usage record
|
||||
bool DeleteLicense();
|
||||
// Remove the current offline license and/or matching usage record, if any
|
||||
// exist.
|
||||
CdmResponseType RemoveLicense();
|
||||
// Delete this session's associated license or usage record file. Note that,
|
||||
// unlike RemoveLicense(), this method ONLY affects the file system and does
|
||||
// not touch the usage table headers.
|
||||
bool DeleteLicenseFile();
|
||||
|
||||
// Generate unique ID for each new session.
|
||||
CdmSessionId GenerateSessionId();
|
||||
|
||||
@@ -334,6 +334,7 @@ enum CdmResponseType {
|
||||
SESSION_NOT_FOUND_17 = 290,
|
||||
SESSION_NOT_FOUND_18 = 291,
|
||||
DEVICE_CANNOT_REPROVISION = 293,
|
||||
SESSION_NOT_FOUND_19 = 294,
|
||||
};
|
||||
|
||||
enum CdmKeyStatus {
|
||||
|
||||
@@ -414,6 +414,18 @@ CdmResponseType CdmEngine::RemoveKeys(const CdmSessionId& session_id) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::RemoveLicense(const CdmSessionId& session_id) {
|
||||
LOGI("CdmEngine::RemoveLicense");
|
||||
|
||||
shared_ptr<CdmSession> session;
|
||||
if (!session_map_.FindSession(session_id, &session)) {
|
||||
LOGE("session_id not found = %s", session_id.c_str());
|
||||
return SESSION_NOT_FOUND_19;
|
||||
}
|
||||
|
||||
return session->RemoveLicense();
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::GenerateRenewalRequest(
|
||||
const CdmSessionId& session_id, CdmKeyRequest* key_request) {
|
||||
LOGI("CdmEngine::GenerateRenewalRequest");
|
||||
@@ -1167,8 +1179,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
switch (status) {
|
||||
case KEY_MESSAGE:
|
||||
break;
|
||||
case KEY_CANCELED: // usage information not present in
|
||||
usage_session_->DeleteLicense(); // OEMCrypto, delete and try again
|
||||
case KEY_CANCELED: // usage information not present in
|
||||
usage_session_->DeleteLicenseFile(); // OEMCrypto, delete and try again
|
||||
usage_info->clear();
|
||||
break;
|
||||
default:
|
||||
@@ -1455,7 +1467,7 @@ CdmResponseType CdmEngine::LoadUsageSession(const CdmKeySetId& key_set_id,
|
||||
break;
|
||||
case KEY_CANCELED:
|
||||
// usage information not present in OEMCrypto, delete and try again
|
||||
session->DeleteLicense();
|
||||
session->DeleteLicenseFile();
|
||||
break;
|
||||
default:
|
||||
LOGE("CdmEngine::LoadUsageSession: generate release request error: %d",
|
||||
|
||||
@@ -715,16 +715,7 @@ CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
|
||||
|
||||
if (sts != KEY_ADDED) return (sts == KEY_ERROR) ? RELEASE_KEY_ERROR : sts;
|
||||
|
||||
if (is_offline_ || has_provider_session_token()) {
|
||||
DeleteLicense();
|
||||
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
has_provider_session_token()) {
|
||||
sts = DeleteUsageEntry(usage_entry_number_);
|
||||
if (NO_ERROR != sts) return sts;
|
||||
}
|
||||
}
|
||||
return NO_ERROR;
|
||||
return RemoveLicense();
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
||||
@@ -897,9 +888,21 @@ CdmResponseType CdmSession::RemoveKeys() {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool CdmSession::DeleteLicense() {
|
||||
if (!is_offline_ && !has_provider_session_token())
|
||||
return false;
|
||||
CdmResponseType CdmSession::RemoveLicense() {
|
||||
if (is_offline_ || has_provider_session_token()) {
|
||||
DeleteLicenseFile();
|
||||
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
has_provider_session_token()) {
|
||||
CdmResponseType sts = DeleteUsageEntry(usage_entry_number_);
|
||||
if (NO_ERROR != sts) return sts;
|
||||
}
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool CdmSession::DeleteLicenseFile() {
|
||||
if (!is_offline_ && !has_provider_session_token()) return false;
|
||||
|
||||
if (is_offline_) {
|
||||
return file_handle_->DeleteLicense(key_set_id_);
|
||||
|
||||
@@ -601,6 +601,8 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
||||
break;
|
||||
case DEVICE_CANNOT_REPROVISION: *os << "DEVICE_CANNOT_REPROVISION";
|
||||
break;
|
||||
case SESSION_NOT_FOUND_19: *os << "SESSION_NOT_FOUND_19";
|
||||
break;
|
||||
default:
|
||||
*os << "Unknown CdmResponseType";
|
||||
break;
|
||||
|
||||
@@ -230,6 +230,7 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
case wvcdm::SESSION_NOT_FOUND_10:
|
||||
case wvcdm::SESSION_NOT_FOUND_17:
|
||||
case wvcdm::SESSION_NOT_FOUND_18:
|
||||
case wvcdm::SESSION_NOT_FOUND_19:
|
||||
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
case wvcdm::SESSION_KEYS_NOT_FOUND:
|
||||
return kSessionKeysNotFound;
|
||||
|
||||
@@ -58,6 +58,7 @@ static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
case wvcdm::SESSION_NOT_FOUND_10:
|
||||
case wvcdm::SESSION_NOT_FOUND_17:
|
||||
case wvcdm::SESSION_NOT_FOUND_18:
|
||||
case wvcdm::SESSION_NOT_FOUND_19:
|
||||
return Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
|
||||
case wvcdm::DECRYPT_ERROR:
|
||||
|
||||
Reference in New Issue
Block a user