Source release v3.0.4
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "cdm_engine.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <iostream>
|
||||
@@ -10,6 +11,7 @@
|
||||
#include "cdm_session.h"
|
||||
#include "clock.h"
|
||||
#include "device_files.h"
|
||||
#include "file_store.h"
|
||||
#include "license_protocol.pb.h"
|
||||
#include "log.h"
|
||||
#include "properties.h"
|
||||
@@ -227,7 +229,8 @@ CdmResponseType CdmEngine::GenerateKeyRequest(
|
||||
|
||||
key_request->clear();
|
||||
|
||||
if (license_type == kLicenseTypeRelease) {
|
||||
if (license_type == kLicenseTypeRelease &&
|
||||
!iter->second->license_received()) {
|
||||
sts = iter->second->RestoreOfflineSession(key_set_id, kLicenseTypeRelease);
|
||||
if (sts != KEY_ADDED) {
|
||||
LOGE("CdmEngine::GenerateKeyRequest: key release restoration failed,"
|
||||
@@ -338,7 +341,7 @@ CdmResponseType CdmEngine::RestoreKey(const CdmSessionId& session_id,
|
||||
if (sts != KEY_ADDED && sts != GET_RELEASED_LICENSE_ERROR) {
|
||||
LOGE("CdmEngine::RestoreKey: restore offline session failed = %d", sts);
|
||||
}
|
||||
return sts; // TODO ewew
|
||||
return sts;
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::RemoveKeys(const CdmSessionId& session_id) {
|
||||
@@ -602,6 +605,9 @@ CdmResponseType CdmEngine::GetProvisioningRequest(
|
||||
LOGE("CdmEngine::GetProvisioningRequest: invalid output parameters");
|
||||
return INVALID_PROVISIONING_REQUEST_PARAM_2;
|
||||
}
|
||||
|
||||
DeleteAllUsageReportsUponFactoryReset();
|
||||
|
||||
if (NULL == cert_provisioning_.get()) {
|
||||
cert_provisioning_.reset(new CertificateProvisioning());
|
||||
}
|
||||
@@ -663,6 +669,7 @@ CdmResponseType CdmEngine::HandleProvisioningResponse(
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
CdmResponseType ret = cert_provisioning_->HandleProvisioningResponse(
|
||||
origin, response, cert, wrapped_key);
|
||||
// Release resources only on success. It is possible that a provisioning
|
||||
@@ -928,6 +935,66 @@ CdmResponseType CdmEngine::ReleaseUsageInfo(
|
||||
return status;
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::LoadUsageSession(const CdmKeySetId& key_set_id,
|
||||
CdmKeyMessage* release_message) {
|
||||
LOGI("CdmEngine::LoadUsageSession");
|
||||
// This method is currently only used by the CE CDM, in which all session IDs
|
||||
// are key set IDs.
|
||||
assert(Properties::AlwaysUseKeySetIds());
|
||||
|
||||
if (key_set_id.empty()) {
|
||||
LOGE("CdmEngine::LoadUsageSession: invalid key set id");
|
||||
return EMPTY_KEYSET_ID_ENG_5;
|
||||
}
|
||||
|
||||
CdmSessionMap::iterator iter = sessions_.find(key_set_id);
|
||||
if (iter == sessions_.end()) {
|
||||
LOGE("CdmEngine::LoadUsageSession: session_id not found = %s ",
|
||||
key_set_id.c_str());
|
||||
return SESSION_NOT_FOUND_11;
|
||||
}
|
||||
|
||||
DeviceFiles handle;
|
||||
if (!handle.Init(iter->second->GetSecurityLevel())) {
|
||||
LOGE("CdmEngine::LoadUsageSession: unable to initialize device files");
|
||||
return LOAD_USAGE_INFO_FILE_ERROR;
|
||||
}
|
||||
|
||||
std::string app_id;
|
||||
iter->second->GetApplicationId(&app_id);
|
||||
|
||||
CdmKeyMessage key_message;
|
||||
CdmKeyResponse key_response;
|
||||
if (!handle.RetrieveUsageInfoByKeySetId(app_id, key_set_id, &key_message,
|
||||
&key_response)) {
|
||||
LOGE("CdmEngine::LoadUsageSession: unable to find usage information");
|
||||
return LOAD_USAGE_INFO_MISSING;
|
||||
}
|
||||
|
||||
CdmResponseType status =
|
||||
iter->second->RestoreUsageSession(key_message, key_response);
|
||||
if (KEY_ADDED != status) {
|
||||
LOGE("CdmEngine::LoadUsageSession: usage session error %ld", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
std::string server_url;
|
||||
status = iter->second->GenerateReleaseRequest(release_message, &server_url);
|
||||
|
||||
switch (status) {
|
||||
case KEY_MESSAGE:
|
||||
break;
|
||||
case KEY_CANCELED: // usage information not present in
|
||||
iter->second->DeleteLicense(); // OEMCrypto, delete and try again
|
||||
break;
|
||||
default:
|
||||
LOGE("CdmEngine::LoadUsageSession: generate release request error: %d",
|
||||
status);
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::Decrypt(const CdmSessionId& session_id,
|
||||
const CdmDecryptionParameters& parameters) {
|
||||
if (parameters.key_id == NULL) {
|
||||
@@ -1097,4 +1164,34 @@ std::string CdmEngine::MapHdcpVersion(
|
||||
return "";
|
||||
}
|
||||
|
||||
void CdmEngine::DeleteAllUsageReportsUponFactoryReset() {
|
||||
std::string device_base_path_level1 = "";
|
||||
std::string device_base_path_level3 = "";
|
||||
Properties::GetDeviceFilesBasePath(kSecurityLevelL1,
|
||||
&device_base_path_level1);
|
||||
Properties::GetDeviceFilesBasePath(kSecurityLevelL3,
|
||||
&device_base_path_level3);
|
||||
|
||||
File file;
|
||||
if (!file.Exists(device_base_path_level1) &&
|
||||
!file.Exists(device_base_path_level3)) {
|
||||
scoped_ptr<CryptoSession> crypto_session(new CryptoSession());
|
||||
CdmResponseType status = crypto_session->Open(
|
||||
cert_provisioning_requested_security_level_);
|
||||
if (NO_ERROR == status) {
|
||||
status = crypto_session->DeleteAllUsageReports();
|
||||
if (NO_ERROR != status) {
|
||||
LOGW(
|
||||
"CdmEngine::GetProvisioningRequest: "
|
||||
"Fails to delete usage reports: %d", status);
|
||||
}
|
||||
} else {
|
||||
LOGW(
|
||||
"CdmEngine::GetProvisioningRequest: "
|
||||
"Fails to open crypto session: error=%d.\n"
|
||||
"Usage reports are not removed after factory reset.", status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user