Replace DeviceFiles::LicenseState with CdmOfflineLicenseState
[ Merge of http://go/wvgerrit/123003 ] Bug: 160006474 Test: WV unit/integration tests Change-Id: Ied813f58405fcac44f0543f715ab2175129bbf9c
This commit is contained in:
@@ -237,7 +237,7 @@ class CdmSession {
|
||||
|
||||
CdmResponseType StoreLicense();
|
||||
|
||||
bool StoreLicense(DeviceFiles::LicenseState state, int* error_detail);
|
||||
bool StoreLicense(CdmOfflineLicenseState state, int* error_detail);
|
||||
|
||||
bool UpdateUsageInfo();
|
||||
|
||||
|
||||
@@ -25,12 +25,6 @@ class FileSystem;
|
||||
|
||||
class DeviceFiles {
|
||||
public:
|
||||
typedef enum {
|
||||
kLicenseStateActive,
|
||||
kLicenseStateReleasing,
|
||||
kLicenseStateUnknown,
|
||||
} LicenseState;
|
||||
|
||||
typedef enum {
|
||||
kCertificateValid,
|
||||
kCertificateExpired,
|
||||
@@ -76,7 +70,7 @@ class DeviceFiles {
|
||||
// license file. License data is uniquely keyed using |key_set_id|.
|
||||
struct CdmLicenseData {
|
||||
std::string key_set_id;
|
||||
LicenseState state;
|
||||
CdmOfflineLicenseState state;
|
||||
CdmInitData pssh_data;
|
||||
// License request / response.
|
||||
CdmKeyMessage license_request;
|
||||
|
||||
@@ -30,18 +30,6 @@ namespace wvcdm {
|
||||
namespace {
|
||||
const uint64_t kReleaseSessionTimeToLive = 60; // seconds
|
||||
const uint32_t kUpdateUsageInformationPeriod = 60; // seconds
|
||||
|
||||
wvcdm::CdmOfflineLicenseState MapDeviceFilesLicenseState(
|
||||
wvcdm::DeviceFiles::LicenseState state) {
|
||||
switch (state) {
|
||||
case wvcdm::DeviceFiles::LicenseState::kLicenseStateActive:
|
||||
return wvcdm::kLicenseStateActive;
|
||||
case wvcdm::DeviceFiles::LicenseState::kLicenseStateReleasing:
|
||||
return wvcdm::kLicenseStateReleasing;
|
||||
default:
|
||||
return wvcdm::kLicenseStateUnknown;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class UsagePropertySet : public CdmClientPropertySet {
|
||||
@@ -1130,7 +1118,7 @@ CdmResponseType CdmEngine::GetOfflineLicenseState(
|
||||
IdToString(key_set_id));
|
||||
return GET_OFFLINE_LICENSE_STATE_ERROR_2;
|
||||
}
|
||||
*license_state = MapDeviceFilesLicenseState(license_data.state);
|
||||
*license_state = license_data.state;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
||||
// Attempts to restore a released offline license are treated as a release
|
||||
// retry.
|
||||
if (Properties::allow_restore_of_offline_licenses_with_release()) {
|
||||
if (license_data.state == DeviceFiles::kLicenseStateReleasing) {
|
||||
if (license_data.state == kLicenseStateReleasing) {
|
||||
license_type = kLicenseTypeRelease;
|
||||
}
|
||||
}
|
||||
@@ -307,7 +307,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
||||
// Only restore offline licenses if they are active or this is a release
|
||||
// retry.
|
||||
if (!(license_type == kLicenseTypeRelease ||
|
||||
license_data.state == DeviceFiles::kLicenseStateActive)) {
|
||||
license_data.state == kLicenseStateActive)) {
|
||||
LOGE("Invalid offline license state: state = %d, license_type = %d",
|
||||
static_cast<int>(license_data.state), static_cast<int>(license_type));
|
||||
return GET_RELEASED_LICENSE_ERROR;
|
||||
@@ -797,8 +797,7 @@ CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
|
||||
|
||||
if (is_offline_) {
|
||||
offline_key_renewal_response_ = key_response;
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateActive,
|
||||
nullptr /* error_detail */))
|
||||
if (!StoreLicense(kLicenseStateActive, nullptr /* error_detail */))
|
||||
return RENEW_KEY_ERROR_2;
|
||||
}
|
||||
return KEY_ADDED;
|
||||
@@ -831,7 +830,7 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
||||
}
|
||||
|
||||
if (is_offline_) { // Mark license as being released
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateReleasing, nullptr))
|
||||
if (!StoreLicense(kLicenseStateReleasing, nullptr))
|
||||
return RELEASE_KEY_REQUEST_ERROR;
|
||||
} else if (!usage_provider_session_token_.empty()) {
|
||||
if (supports_usage_info()) {
|
||||
@@ -958,7 +957,7 @@ CdmResponseType CdmSession::StoreLicense() {
|
||||
return OFFLINE_LICENSE_PROHIBITED;
|
||||
}
|
||||
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateActive, nullptr)) {
|
||||
if (!StoreLicense(kLicenseStateActive, nullptr)) {
|
||||
LOGE("Unable to store license");
|
||||
return STORE_LICENSE_ERROR_1;
|
||||
}
|
||||
@@ -994,8 +993,7 @@ CdmResponseType CdmSession::StoreLicense() {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool CdmSession::StoreLicense(DeviceFiles::LicenseState state,
|
||||
int* error_detail) {
|
||||
bool CdmSession::StoreLicense(CdmOfflineLicenseState state, int* error_detail) {
|
||||
DeviceFiles::ResponseType error_detail_alt = DeviceFiles::kNoError;
|
||||
DeviceFiles::CdmLicenseData license_data{
|
||||
key_set_id_,
|
||||
@@ -1066,7 +1064,7 @@ void CdmSession::OnTimerEvent(bool update_usage) {
|
||||
policy_engine_->DecryptionEvent();
|
||||
has_decrypted_since_last_report_ = false;
|
||||
if (is_offline_ && !is_release_) {
|
||||
StoreLicense(DeviceFiles::kLicenseStateActive, nullptr);
|
||||
StoreLicense(kLicenseStateActive, nullptr);
|
||||
}
|
||||
}
|
||||
policy_engine_->OnTimerEvent();
|
||||
@@ -1103,8 +1101,7 @@ CdmResponseType CdmSession::UpdateUsageEntryInformation() {
|
||||
if (sts != NO_ERROR) return sts;
|
||||
|
||||
if (is_offline_)
|
||||
StoreLicense(is_release_ ? DeviceFiles::kLicenseStateReleasing
|
||||
: DeviceFiles::kLicenseStateActive,
|
||||
StoreLicense(is_release_ ? kLicenseStateReleasing : kLicenseStateActive,
|
||||
nullptr);
|
||||
else if (!usage_provider_session_token_.empty())
|
||||
UpdateUsageInfo();
|
||||
|
||||
@@ -1605,7 +1605,7 @@ constexpr size_t kNumberOfDefaultCertificates =
|
||||
|
||||
struct LicenseInfo {
|
||||
std::string key_set_id;
|
||||
DeviceFiles::LicenseState license_state;
|
||||
CdmOfflineLicenseState license_state;
|
||||
std::string pssh_data;
|
||||
std::string key_request;
|
||||
std::string key_response;
|
||||
@@ -1630,7 +1630,7 @@ struct LicenseInfo {
|
||||
const LicenseInfo kLicenseTestData[] = {
|
||||
|
||||
// license 0
|
||||
{"ksid54C57C966E23CEF5", DeviceFiles::kLicenseStateActive,
|
||||
{"ksid54C57C966E23CEF5", kLicenseStateActive,
|
||||
a2bs_hex("0801121030313233343536373839414243444546"),
|
||||
a2bs_hex("080112950C0AD70B080112EF090AB002080212103E560EC5335E346F591B"
|
||||
"C4D07A7D507618A5D3A68F05228E023082010A0282010100A947904B8DBD"
|
||||
@@ -1807,7 +1807,7 @@ const LicenseInfo kLicenseTestData[] = {
|
||||
"FF232D23F98B72F1DCE96A")},
|
||||
|
||||
// license 1
|
||||
{"ksidC8EAA2579A282EB0", DeviceFiles::kLicenseStateReleasing,
|
||||
{"ksidC8EAA2579A282EB0", kLicenseStateReleasing,
|
||||
a2bs_hex("0801121030313233343536373839414243444546"),
|
||||
a2bs_hex("080112950C0AD70B080112EF090AB002080212103E560EC5335E346F591B"
|
||||
"C4D07A7D507618A5D3A68F05228E023082010A0282010100A947904B8DBD"
|
||||
@@ -1990,7 +1990,7 @@ const LicenseInfo kLicenseTestData[] = {
|
||||
"17B2F8B2D7511C9DE89A87CB5208AB")},
|
||||
|
||||
// license 2
|
||||
{"ksidE8C37662C88DC673", DeviceFiles::kLicenseStateReleasing,
|
||||
{"ksidE8C37662C88DC673", kLicenseStateReleasing,
|
||||
a2bs_hex("0801121030313233343536373839414243444546"),
|
||||
a2bs_hex("080112950C0AD70B080112EF090AB002080212103E560EC5335E346F591B"
|
||||
"C4D07A7D507618A5D3A68F05228E023082010A0282010100A947904B8DBD"
|
||||
@@ -2175,7 +2175,7 @@ const LicenseInfo kLicenseTestData[] = {
|
||||
"F")},
|
||||
|
||||
// license 3
|
||||
{"ksidF991C5F45E98CB97", DeviceFiles::kLicenseStateActive,
|
||||
{"ksidF991C5F45E98CB97", kLicenseStateActive,
|
||||
a2bs_hex("0801121030313233343536373839414243444546"),
|
||||
a2bs_hex("080112950C0AD70B080112EF090AB002080212103E560EC5335E346F591B"
|
||||
"FA0E5DFC3DE9A34BA5F08BE349553C319A9FB274905A8770ADC9CA4A2CBC"
|
||||
@@ -2418,7 +2418,7 @@ constexpr size_t kNumberOfLicenses = ArraySize(kLicenseTestData);
|
||||
// The data is used to test license-related functions.
|
||||
const LicenseInfo kLicenseUpdateTestData[] = {
|
||||
// active license
|
||||
{"key_set_id_: ksid2A048BC7FAEC885A", DeviceFiles::kLicenseStateActive,
|
||||
{"key_set_id_: ksid2A048BC7FAEC885A", kLicenseStateActive,
|
||||
a2bs_hex("0801121030313233343536373839414243444546"),
|
||||
a2bs_hex("080112950C0AD70B080112EF090AB002080212103E560EC5335E346F591B"
|
||||
"C4D07A7D5076189EDFB68F05228E023082010A0282010100CC1715C81AD3"
|
||||
@@ -2601,8 +2601,8 @@ const LicenseInfo kLicenseUpdateTestData[] = {
|
||||
"766D60B07CBC")},
|
||||
// license being released. all fields are identical except for license
|
||||
// state and hashed file data
|
||||
{"", DeviceFiles::kLicenseStateReleasing, "", "", "", "", "", "", 0, 0, 0,
|
||||
"", "", 15, "", CryptoWrappedKey::kUninitialized, "",
|
||||
{"", kLicenseStateReleasing, "", "", "", "", "", "", 0, 0, 0, "", "", 15,
|
||||
"", CryptoWrappedKey::kUninitialized, "",
|
||||
a2bs_hex(
|
||||
"0AEE150802100122E7150802121408011210303132333435363738394142434445461"
|
||||
"A9D0E080112950C0AD70B080112EF090AB002080212103E560EC5335E346F591BC4D0"
|
||||
@@ -2694,7 +2694,7 @@ const LicenseInfo kLicenseUpdateTestData[] = {
|
||||
const LicenseInfo kLicenseAppParametersBackwardsCompatibilityTestData = {
|
||||
|
||||
"ksid54C57C966E23CEF5",
|
||||
DeviceFiles::kLicenseStateActive,
|
||||
kLicenseStateActive,
|
||||
a2bs_hex("0801121030313233343536373839414243444546"),
|
||||
a2bs_hex("080112950C0AD70B080112EF090AB002080212103E560EC5335E346F591B"
|
||||
"C4D07A7D507618A5D3A68F05228E023082010A0282010100A947904B8DBD"
|
||||
@@ -3806,7 +3806,7 @@ class DeviceFilesTest : public ::testing::Test {
|
||||
app_parameters_len += itr->first.length();
|
||||
app_parameters_len += itr->second.length();
|
||||
}
|
||||
return sizeof(DeviceFiles::LicenseState) + data.pssh_data.size() +
|
||||
return sizeof(CdmOfflineLicenseState) + data.pssh_data.size() +
|
||||
data.key_request.size() + data.key_response.size() +
|
||||
data.key_renewal_request.size() + data.key_renewal_response.size() +
|
||||
data.key_release_url.size() + 3 * sizeof(int64_t) +
|
||||
|
||||
@@ -208,8 +208,7 @@ std::vector<CdmUsageEntryInfo> kUsageEntryInfoVector;
|
||||
std::vector<CdmUsageEntryInfo> k10UsageEntryInfoVector;
|
||||
std::vector<CdmUsageEntryInfo> kOverFullUsageEntryInfoVector;
|
||||
|
||||
const DeviceFiles::LicenseState kActiveLicenseState =
|
||||
DeviceFiles::kLicenseStateActive;
|
||||
const CdmOfflineLicenseState kActiveLicenseState = kLicenseStateActive;
|
||||
const CdmInitData kPsshData = "pssh data";
|
||||
const CdmKeyMessage kKeyRequest = "key request";
|
||||
const CdmKeyResponse kKeyResponse = "key response";
|
||||
|
||||
Reference in New Issue
Block a user