From 8091ed239e055924c6b34841c309b57dca89cd10 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/149130 ] 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libwvdrmengine/cdm/core/src/crypto_session.cpp b/libwvdrmengine/cdm/core/src/crypto_session.cpp index 61321942..1ff794ee 100644 --- a/libwvdrmengine/cdm/core/src/crypto_session.cpp +++ b/libwvdrmengine/cdm/core/src/crypto_session.cpp @@ -374,15 +374,18 @@ void CryptoSession::Init() { void CryptoSession::ReinitializeForTest() { if (initialized_) { - initialized_ = false; - OEMCryptoResult status = OEMCrypto_Terminate(); + const OEMCryptoResult status = OEMCrypto_Terminate(); if (OEMCrypto_SUCCESS != status) { LOGE("OEMCrypto_Terminate failed: %d", status); return; } + initialized_ = false; + // 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. - OEMCryptoResult status = OEMCrypto_Initialize(); + const OEMCryptoResult status = OEMCrypto_Initialize(); if (OEMCrypto_SUCCESS != status) { LOGE("OEMCrypto_Initialize failed: %d", status); return;