Logging for L1 devices falling back to L3
[ Merge of http://go/wvgerrit/161877 ] This change introduces some logging to shed some light on why some L1 devices fallback to L3. * Additional logging has been added to indicate whether a lookup of the symbols for OEMCrypto_Initialize, OEMCrypto_APIVersion or OEMCrypto_Terminate failed. * OEMCrypto_Initialize error code is saved and reported later. Bug: 245887116 Test: GtsMediaTestCases Change-Id: Ice4d966d2fee458de2fae28a1355f292f879c38b
This commit is contained in:
@@ -926,9 +926,15 @@ class Adapter {
|
||||
LOOKUP_ALL(18, SetMaxAPIVersion, OEMCrypto_SetMaxAPIVersion);
|
||||
if (level1_.Initialize == nullptr || level1_.APIVersion == nullptr ||
|
||||
level1_.Terminate == nullptr) {
|
||||
const char* kSucceeded = "succeeded";
|
||||
const char* kFailed = "failed";
|
||||
LOGW(
|
||||
"Lookup for OEMCrypto_Initialize: %s, OEMCrypto_APIVersion: %s,"
|
||||
" OEMCrypto_Terminate: %s",
|
||||
level1_.Initialize == nullptr ? kFailed : kSucceeded,
|
||||
level1_.APIVersion == nullptr ? kFailed : kSucceeded,
|
||||
level1_.Terminate == nullptr ? kFailed : kSucceeded);
|
||||
level1_valid_ = false;
|
||||
}
|
||||
if (!level1_valid_) {
|
||||
metrics->OemCryptoDynamicAdapterMetrics::SetInitializationMode(
|
||||
wvcdm::metrics::OEMCrypto_INITIALIZED_USING_L3_INVALID_L1);
|
||||
return false;
|
||||
@@ -940,9 +946,10 @@ class Adapter {
|
||||
level1_.SetSandbox(&sandbox_id_[0], sandbox_id_.size());
|
||||
}
|
||||
}
|
||||
OEMCryptoResult st = level1_.Initialize();
|
||||
if (st != OEMCrypto_SUCCESS) {
|
||||
LOGW("Could not initialize L1. Falling back to L3.");
|
||||
level1_initialization_result_ = level1_.Initialize();
|
||||
if (level1_initialization_result_ != OEMCrypto_SUCCESS) {
|
||||
LOGW("Could not initialize L1. Falling back to L3: %d",
|
||||
static_cast<int>(level1_initialization_result_));
|
||||
metrics->OemCryptoDynamicAdapterMetrics::SetInitializationMode(
|
||||
wvcdm::metrics::
|
||||
OEMCrypto_INITIALIZED_USING_L3_COULD_NOT_INITIALIZE_L1);
|
||||
@@ -1317,7 +1324,11 @@ class Adapter {
|
||||
if (!level1_valid_) {
|
||||
// TODO(b/189989043): add metrics.
|
||||
// If level 1 not initialized, then return level 3's answer.
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
LOGE("L1 not initialized. Falling back to L3");
|
||||
if (level1_initialization_result_ != OEMCrypto_SUCCESS)
|
||||
return level1_initialization_result_;
|
||||
else
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
// Figure out provisioning method. Defaults to keybox.
|
||||
const OEMCrypto_ProvisioningMethod provisioning_method =
|
||||
@@ -1424,6 +1435,7 @@ class Adapter {
|
||||
private:
|
||||
bool level1_valid_ = false;
|
||||
bool level1_initialized_ = false;
|
||||
OEMCryptoResult level1_initialization_result_ = OEMCrypto_SUCCESS;
|
||||
// If the level 1 fails to initialize once, we don't try again.
|
||||
bool level1_failed_ = false;
|
||||
void* level1_library_ = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user