From 8d3d0b60b471a7b19309cbff2e24eb619757cd7b Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Wed, 30 Mar 2022 13:53:28 -0700 Subject: [PATCH] Reset UsageTableHeader when re-init for tests. [ Merge of http://go/wvgerrit/149389 ] [ Cherry-pick of http://ag/17511529 ] When re-initializing OEMCrypto for testing purposes, the UsageTableHeader must be reset as well. This is to inform future sessions to load or create a new header before creating new entries. Bug: 219075437 Test: request_license_test and MediaDrmTests GTS Change-Id: Ie8bc72bc7ea079d21587e114223fcb67547c756a --- libwvdrmengine/cdm/core/src/crypto_session.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libwvdrmengine/cdm/core/src/crypto_session.cpp b/libwvdrmengine/cdm/core/src/crypto_session.cpp index 40229cb3..db53e6b2 100644 --- a/libwvdrmengine/cdm/core/src/crypto_session.cpp +++ b/libwvdrmengine/cdm/core/src/crypto_session.cpp @@ -360,11 +360,22 @@ void CryptoSession::Init() { void CryptoSession::ReinitializeForTest() { if (initialized_) { + const OEMCryptoResult status = OEMCrypto_Terminate(); + if (OEMCrypto_SUCCESS != status) { + LOGE("OEMCrypto_Terminate failed: %d", status); + return; + } initialized_ = false; - if (OEMCrypto_SUCCESS != OEMCrypto_Terminate()) return; + // Tables will be reinitialized by tests when needed. + usage_table_header_l1_.reset(); + usage_table_header_l3_.reset(); } // Give up if we cannot initialize at all. - if (OEMCrypto_SUCCESS != OEMCrypto_Initialize()) return; + const OEMCryptoResult status = OEMCrypto_Initialize(); + if (OEMCrypto_SUCCESS != status) { + LOGE("OEMCrypto_Initialize failed: %d", status); + return; + } initialized_ = true; // For integration and unit tests we will install a test keybox and do not // need to do keybox provisioning.