Correct offline license handling am: 1857da2c8c am: 4c8af4872d

am: ce54031351

Change-Id: I6ffef72ad17a2e9a56b7738da8c800af1dd8bda9
This commit is contained in:
Rahul Frias
2017-06-08 16:13:42 +00:00
committed by android-build-merger
4 changed files with 26 additions and 11 deletions

View File

@@ -73,6 +73,7 @@ static const std::string QUERY_VALUE_SECURITY_LEVEL_L1 = "L1";
static const std::string QUERY_VALUE_SECURITY_LEVEL_L2 = "L2"; static const std::string QUERY_VALUE_SECURITY_LEVEL_L2 = "L2";
static const std::string QUERY_VALUE_SECURITY_LEVEL_L3 = "L3"; static const std::string QUERY_VALUE_SECURITY_LEVEL_L3 = "L3";
static const std::string QUERY_VALUE_SECURITY_LEVEL_UNKNOWN = "Unknown"; static const std::string QUERY_VALUE_SECURITY_LEVEL_UNKNOWN = "Unknown";
static const std::string QUERY_VALUE_SECURITY_LEVEL_DEFAULT = "Default";
static const std::string QUERY_VALUE_DISCONNECTED = "Disconnected"; static const std::string QUERY_VALUE_DISCONNECTED = "Disconnected";
static const std::string QUERY_VALUE_UNPROTECTED = "Unprotected"; static const std::string QUERY_VALUE_UNPROTECTED = "Unprotected";
static const std::string QUERY_VALUE_HDCP_V1 = "HDCP-1.x"; static const std::string QUERY_VALUE_HDCP_V1 = "HDCP-1.x";

View File

@@ -212,7 +212,14 @@ CdmResponseType CdmSession::RestoreOfflineSession(
return GET_RELEASED_LICENSE_ERROR; return GET_RELEASED_LICENSE_ERROR;
} }
if (usage_support_type_ == kUsageEntrySupport) { std::string provider_session_token;
if (!license_parser_->ExtractProviderSessionToken(
key_response_, &provider_session_token)) {
provider_session_token.clear();
}
if (usage_support_type_ == kUsageEntrySupport &&
provider_session_token.size() > 0) {
CdmResponseType sts = usage_table_header_->LoadEntry(crypto_session_.get(), CdmResponseType sts = usage_table_header_->LoadEntry(crypto_session_.get(),
usage_entry_, usage_entry_,
usage_entry_number_); usage_entry_number_);
@@ -236,7 +243,8 @@ CdmResponseType CdmSession::RestoreOfflineSession(
} }
} }
if (usage_support_type_ == kUsageEntrySupport) { if (usage_support_type_ == kUsageEntrySupport &&
provider_session_token.size() > 0) {
CdmResponseType sts = CdmResponseType sts =
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_); usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
if (sts != NO_ERROR) { if (sts != NO_ERROR) {
@@ -459,8 +467,10 @@ CdmResponseType CdmSession::AddKey(const CdmKeyResponse& key_response) {
key_response_ = key_response; key_response_ = key_response;
if (is_offline_ || has_provider_session_token()) { if (is_offline_ || has_provider_session_token()) {
if (usage_support_type_ == kUsageEntrySupport) if (has_provider_session_token() &&
usage_support_type_ == kUsageEntrySupport) {
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_); usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
}
if (!is_offline_) if (!is_offline_)
usage_provider_session_token_ = usage_provider_session_token_ =

View File

@@ -434,8 +434,10 @@ uint8_t CryptoSession::GetSecurityPatchLevel() {
} }
CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) { CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
LOGV("CryptoSession::Open: Lock: requested_security_level: %d", LOGD("CryptoSession::Open: Lock: requested_security_level: %s",
requested_security_level); requested_security_level == kLevel3
? QUERY_VALUE_SECURITY_LEVEL_L3.c_str()
: QUERY_VALUE_SECURITY_LEVEL_DEFAULT.c_str());
AutoLock auto_lock(crypto_lock_); AutoLock auto_lock(crypto_lock_);
if (!initialized_) return UNKNOWN_ERROR; if (!initialized_) return UNKNOWN_ERROR;
if (open_) return NO_ERROR; if (open_) return NO_ERROR;
@@ -1645,11 +1647,15 @@ bool CryptoSession::GetSrmVersion(uint16_t* srm_version) {
} }
OEMCryptoResult status = OEMCrypto_GetCurrentSRMVersion(srm_version); OEMCryptoResult status = OEMCrypto_GetCurrentSRMVersion(srm_version);
if (OEMCrypto_SUCCESS != status) { switch (status) {
LOGW("OEMCrypto_GetCurrentSRMVersion fails with %d", status); case OEMCrypto_SUCCESS:
return false; return true;
case OEMCrypto_ERROR_NOT_IMPLEMENTED:
return false;
default:
LOGW("OEMCrypto_GetCurrentSRMVersion fails with %d", status);
return false;
} }
return true;
} }
bool CryptoSession::IsSrmUpdateSupported() { bool CryptoSession::IsSrmUpdateSupported() {

View File

@@ -363,7 +363,6 @@ TEST_F(UsageTableHeaderTest, LoadEntry) {
TEST_F(UsageTableHeaderTest, UpdateEntry_CryptoSessionError) { TEST_F(UsageTableHeaderTest, UpdateEntry_CryptoSessionError) {
Init(kSecurityLevelL1, kUsageTableHeader, kUsageEntryInfoVector); Init(kSecurityLevelL1, kUsageTableHeader, kUsageEntryInfoVector);
uint32_t usage_entry_number;
CdmUsageEntry usage_entry; CdmUsageEntry usage_entry;
EXPECT_CALL(*crypto_session_, UpdateUsageEntry(NotNull(), NotNull())) EXPECT_CALL(*crypto_session_, UpdateUsageEntry(NotNull(), NotNull()))
@@ -377,7 +376,6 @@ TEST_F(UsageTableHeaderTest, UpdateEntry_CryptoSessionError) {
TEST_F(UsageTableHeaderTest, UpdateEntry) { TEST_F(UsageTableHeaderTest, UpdateEntry) {
Init(kSecurityLevelL1, kUsageTableHeader, kUsageEntryInfoVector); Init(kSecurityLevelL1, kUsageTableHeader, kUsageEntryInfoVector);
uint32_t usage_entry_number;
CdmUsageEntry usage_entry; CdmUsageEntry usage_entry;
EXPECT_CALL(*crypto_session_, UpdateUsageEntry(NotNull(), NotNull())) EXPECT_CALL(*crypto_session_, UpdateUsageEntry(NotNull(), NotNull()))