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
This commit is contained in:
Alex Dale
2022-03-30 13:53:28 -07:00
parent 3ac8cddc34
commit 8d3d0b60b4

View File

@@ -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.