Remove usage reports upon factory reset of device.

(This is a merge of http://go/wvgerrit/16162)

Usage tables on L3 devices are stored under IDM*. They will be removed
upon factory reset. However, we need to call OEMCrypto_DeleteUsageTable
for L1 devices because the usage tables are stored in secure storage.

bug: 25597957
Change-Id: I8533dfac60fad6ce7ddfd026a283633d6875dcf3
This commit is contained in:
Edwin Wong
2015-11-20 17:34:34 -08:00
parent a53589c6fc
commit c1894e8fa4
3 changed files with 48 additions and 6 deletions

View File

@@ -173,6 +173,7 @@ class CdmEngine {
private:
// private methods
void DeleteAllUsageReportsUponFactoryReset();
bool ValidateKeySystem(const CdmKeySystem& key_system);
CdmResponseType GetUsageInfo(const std::string& app_id,
SecurityLevel requested_security_level,

View File

@@ -10,6 +10,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"
@@ -299,12 +300,18 @@ CdmResponseType CdmEngine::AddKey(const CdmSessionId& session_id,
CdmResponseType sts = iter->second->AddKey(key_data, key_set_id);
if (KEY_ADDED != sts) {
LOGE("CdmEngine::AddKey: keys not added, result = %d", sts);
return sts;
switch (sts) {
case KEY_ADDED:
break;
case NEED_KEY:
LOGI("CdmEngine::AddKey: service certificate loaded, no key added");
break;
default:
LOGE("CdmEngine::AddKey: keys not added, result = %d", sts);
break;
}
return KEY_ADDED;
return sts;
}
CdmResponseType CdmEngine::RestoreKey(const CdmSessionId& session_id,
@@ -332,7 +339,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) {
@@ -596,6 +603,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());
}
@@ -657,6 +667,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
@@ -1091,4 +1102,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

View File

@@ -226,7 +226,7 @@ struct LevelSession {
// the dynamically loaded level 1 oemcrypto. When initialized, it tries to
// load the level 1 library and verifies that all needed functions are present.
// If they are not, then it flags the level 1 as invalid. Later, when the
// function get(kLevel3) is called, if returns the level 3 function pointers.
// function get(kLevel3) is called, it returns the level 3 function pointers.
// When get(kLevelDefault) is called, it returns level 1 function pointers if
// level 1 is valid and otherwise returns the level 3 function pointers.
class Adapter {