diff --git a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp index c780e4bf..8fde8fb1 100644 --- a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp +++ b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp @@ -418,19 +418,10 @@ class Adapter { ~Adapter() { } - OEMCryptoResult Initialize() { - - /* - * To avoid changing the function signature and function contract - declare - * a one-off metrics group to collect detailed information about how - * oemcrypto was intialized. - * - * TODO(blueeyes): Refactor this to allow Initialize to provide the - * details to the caller or to use the metrics instance provided by - * the caller. - */ - wvcdm::metrics::CryptoMetrics metrics; - + OEMCryptoResult Initialize(wvcdm::metrics::CryptoMetrics* metrics) { + if (metrics == nullptr) { + return OEMCrypto_ERROR_INIT_FAILED; + } level1_ = FunctionPointers(); // start with all null pointers. level3_ = FunctionPointers(); // start with all null pointers. LoadLevel3(); @@ -441,7 +432,7 @@ class Adapter { base_path.c_str()); if (Level3_IsInApp()) { M_RECORD( - &metrics, + metrics, oemcrypto_initialization_mode_, NO_TIME, wvcdm::metrics::OEMCrypto_INITIALIZED_USING_IN_APP); @@ -450,7 +441,7 @@ class Adapter { if (force_level3()) { LOGW("Test code. User requested falling back to L3"); M_RECORD( - &metrics, + metrics, oemcrypto_initialization_mode_, NO_TIME, wvcdm::metrics::OEMCrypto_INITIALIZED_FORCING_L3); @@ -460,7 +451,7 @@ class Adapter { if (!wvcdm::Properties::GetOEMCryptoPath(&library_name)) { LOGW("L1 library not specified. Falling back to L3"); M_RECORD( - &metrics, + metrics, oemcrypto_initialization_mode_, NO_TIME, wvcdm::metrics::OEMCrypto_INITIALIZED_USING_L3_NO_L1_LIBRARY_PATH); @@ -471,13 +462,13 @@ class Adapter { LOGW("Could not load %s. Falling back to L3. %s", library_name.c_str(), dlerror()); M_RECORD( - &metrics, + metrics, oemcrypto_initialization_mode_, NO_TIME, wvcdm::metrics::OEMCrypto_INITIALIZED_USING_L3_L1_OPEN_FAILED); return result; } - if (LoadLevel1(&metrics)) { + if (LoadLevel1(metrics)) { LOGD("OEMCrypto_Initialize Level 1 success. I will use level 1."); } else { level1_ = FunctionPointers(); // revert to all null pointers. @@ -489,6 +480,9 @@ class Adapter { } bool LoadLevel1(wvcdm::metrics::CryptoMetrics* metrics) { + if (metrics == nullptr) { + return false; + } level1_valid_ = true; const uint32_t kMinimumVersion = 8; const uint32_t kMaximumVersion = 13; @@ -885,7 +879,7 @@ class WatchDog { delete kAdapter; } kAdapter = new Adapter(); - status_ = kAdapter->Initialize(); + status_ = kAdapter->Initialize(&metrics_); } std::string FailureFilename() { @@ -913,6 +907,11 @@ class WatchDog { file_system.Remove(filename); if (size == size_read && flag) { LOGE("Previous L3 Init failed."); + M_RECORD( + &metrics_, + oemcrypto_initialization_mode_, + NO_TIME, + wvcdm::metrics::OEMCrypto_INITIALIZED_L3_INITIALIZATION_FAILED); } } } @@ -990,6 +989,15 @@ class WatchDog { pthread_cond_t condition_; bool running_; bool gave_up_; + // A Metrics Group for the different initialization outcomes. Since one + // outcome is a watchdog timeout and abort on the PREVIOUS initialization, + // we put the group here, owned by the watchdog timer. + // + // TODO(blueeyes): Refactor this to allow Initialize to provide the + // details to the caller or to use the metrics instance provided by + // the caller. + + wvcdm::metrics::CryptoMetrics metrics_; }; // Function called by new worker thread in pthread_create. diff --git a/libwvdrmengine/cdm/metrics/include/metrics_collections.h b/libwvdrmengine/cdm/metrics/include/metrics_collections.h index 3b40cc1f..2f34470d 100644 --- a/libwvdrmengine/cdm/metrics/include/metrics_collections.h +++ b/libwvdrmengine/cdm/metrics/include/metrics_collections.h @@ -73,7 +73,8 @@ typedef enum OEMCryptoInitializationMode { OEMCrypto_INITIALIZED_USING_L3_COULD_NOT_INSTALL_KEYBOX = 12, OEMCrypto_INITIALIZED_USING_L1_INSTALLED_KEYBOX = 13, OEMCrypto_INITIALIZED_USING_L3_INVALID_L1 = 14, - OEMCrypto_INITIALIZED_USING_L1_WITH_PROVISIONING_3_0 = 15 + OEMCrypto_INITIALIZED_USING_L1_WITH_PROVISIONING_3_0 = 15, + OEMCrypto_INITIALIZED_L3_INITIALIZATION_FAILED = 16 } OEMCryptoInitializationMode;