From d751e817909a9dd9dbe3bad7b15b3f5c1e2b66ee Mon Sep 17 00:00:00 2001 From: Edwin Wong Date: Thu, 11 May 2017 18:10:57 -0700 Subject: [PATCH] Fix GTS testL3PlayHDCPV* tests. These tests verify whether a L3 device respects the HDCP policy set in the license request. L3 device should only play the clear lead, and stop at encrypted content. MeidaDrm should throw an ERROR_INSUFFICIENT_OUTPUT_PROTECTION exception. This is because L3 device always returns current HDCP connection status as HDCP_NONE. This CL modifies the policy engine CanDecryptContent method to return CdmResponseType instead of a boolean, so the app can generate the correct error response if HDCP constriants are not met. Test: GTS tests ANDROID_BUILD_TOP= ./android-gts/tooadefed run gts -m GtsMediaTestCases --test com.google.android.media.gts.WidevineDashPolicyTests#testL3PlayHDCPV*Required Test: unit tests adb shell /data/app/policy_engine_unittest adb shell /data/app/policy_engine_constraints_unittest Test: Play Movies bug: 34258607 Change-Id: I11fc9da1e077e18e38f34159daae9d8ebcd948b6 --- libwvdrmengine/cdm/core/include/policy_engine.h | 4 ++++ libwvdrmengine/cdm/core/src/cdm_session.cpp | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libwvdrmengine/cdm/core/include/policy_engine.h b/libwvdrmengine/cdm/core/include/policy_engine.h index 6cd9aad1..83214622 100644 --- a/libwvdrmengine/cdm/core/include/policy_engine.h +++ b/libwvdrmengine/cdm/core/include/policy_engine.h @@ -99,6 +99,10 @@ class PolicyEngine { bool CanRenew() { return policy_.can_renew(); } + bool IsSufficientOutputProtection(const KeyId& key_id) { + return license_keys_->MeetsConstraints(key_id); + } + private: friend class PolicyEngineTest; friend class PolicyEngineConstraintsTest; diff --git a/libwvdrmengine/cdm/core/src/cdm_session.cpp b/libwvdrmengine/cdm/core/src/cdm_session.cpp index d4a12313..2e7fcb60 100644 --- a/libwvdrmengine/cdm/core/src/cdm_session.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_session.cpp @@ -551,9 +551,14 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) { // Playback may not begin until either the start time passes or the license // is updated, so we treat this Decrypt call as invalid. - if (params.is_encrypted && - !policy_engine_->CanDecryptContent(*params.key_id)) { - return policy_engine_->IsLicenseForFuture() ? DECRYPT_NOT_READY : NEED_KEY; + if (params.is_encrypted) { + if (!policy_engine_->CanDecryptContent(*params.key_id)) { + if (policy_engine_->IsLicenseForFuture()) + return DECRYPT_NOT_READY; + if (!policy_engine_->IsSufficientOutputProtection(*params.key_id)) + return INSUFFICIENT_OUTPUT_PROTECTION; + return NEED_KEY; + } } CdmResponseType status = crypto_session_->Decrypt(params);