From 04e1d8efbca98c958f1f2425fa65ffde200f2e53 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Sun, 19 Dec 2021 20:00:25 +0000 Subject: [PATCH] Add MediaDrm property to allow test keybox Merge from Widevine repo of http://go/wvgerrit/142150 (part 1) For an EVT device, without a keybox or with a test keybox, we want it to fall back to L3. However, when running the unit or integration tests it should continue running tests with test keybox. This will allow us to test L1 oemcrypto on an EVT device, while still using an EVT device for dogfooding video content at the L3 level. The original CL modified the HIDL and non-HIDL plugin, so this is the hand cherry-pick. Bug: 210807585 Change-Id: I85b96f127abe30f8f061b242f7580fa8f6c01776 --- .../cdm/include/wv_content_decryption_module.h | 6 ++++++ .../cdm/src/wv_content_decryption_module.cpp | 5 +++++ libwvdrmengine/mediadrm/src_hidl/WVDrmPlugin.cpp | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/libwvdrmengine/cdm/include/wv_content_decryption_module.h b/libwvdrmengine/cdm/include/wv_content_decryption_module.h index 1630ae93..fab928ac 100644 --- a/libwvdrmengine/cdm/include/wv_content_decryption_module.h +++ b/libwvdrmengine/cdm/include/wv_content_decryption_module.h @@ -159,8 +159,14 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler { // Closes the CdmEngine and sessions associated with the given CdmIdentifier. virtual CdmResponseType CloseCdm(const CdmIdentifier& identifier); + // When positive, the keybox will be ignored at initialization and force the + // device to request a keybox OTA reprovisioning. virtual CdmResponseType SetDebugIgnoreKeyboxCount(uint32_t count); + // Allow the device to continue with a test keybox. Otherwise, it will fall + // back to L3. + virtual CdmResponseType SetAllowTestKeybox(bool allow); + virtual CdmResponseType SetDecryptHash(const std::string& hash_data, CdmSessionId* session_id); virtual CdmResponseType GetDecryptHashError(const CdmSessionId& session_id, diff --git a/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp b/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp index 3256d102..e87d7890 100644 --- a/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp +++ b/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp @@ -505,6 +505,11 @@ CdmResponseType WvContentDecryptionModule::SetDebugIgnoreKeyboxCount( return CdmEngine::SetDebugIgnoreKeyboxCount(count); } +CdmResponseType WvContentDecryptionModule::SetAllowTestKeybox(bool allow) { + // TODO(210807585) add functionality in next CL. + return NO_ERROR; +} + CdmResponseType WvContentDecryptionModule::SetDecryptHash( const std::string& hash_data, CdmSessionId* id) { if (id == nullptr) { diff --git a/libwvdrmengine/mediadrm/src_hidl/WVDrmPlugin.cpp b/libwvdrmengine/mediadrm/src_hidl/WVDrmPlugin.cpp index aa1efe37..73744a4f 100644 --- a/libwvdrmengine/mediadrm/src_hidl/WVDrmPlugin.cpp +++ b/libwvdrmengine/mediadrm/src_hidl/WVDrmPlugin.cpp @@ -1443,6 +1443,18 @@ Return WVDrmPlugin::setPropertyString(const hidl_string& propertyName, } CdmResponseType res = mCDM->SetDebugIgnoreKeyboxCount(count); return mapCdmResponseType(res); + } else if (name == "allowTestKeybox") { + bool allow; + if (_value == kEnable) { + allow = true; + } else if (_value == kDisable) { + allow = false; + } else { + ALOGE("App requested unknown allowTestKeybox %s", _value.c_str()); + return Status::BAD_VALUE; + } + CdmResponseType res = mCDM->SetAllowTestKeybox(allow); + return mapCdmResponseType(res); } else if (name == "decryptHash") { wvcdm::CdmSessionId sessionId; CdmResponseType res =