Add property to check if user forces L3

[ Merge of go/wvgerrit/186611 ]

Android user can set the property using the developer option.

Bug: 301669353
Change-Id: I730b635f6cc28dfb0471c1d679627c94b9e16af1
This commit is contained in:
Kyle Zhang
2023-10-26 21:19:45 +00:00
parent 45d8b38b43
commit 6b60fc3a76
7 changed files with 23 additions and 2 deletions

View File

@@ -82,6 +82,8 @@ class Properties {
static bool GetSandboxId(std::string* sandbox_id);
static bool AlwaysUseKeySetIds();
static bool UseProviderIdInProvisioningRequest();
// Cdm only loads L3 library when this returns true
static bool ForceL3();
static bool GetSecurityLevelDirectories(std::vector<std::string>* dirs);
static bool GetApplicationId(const CdmSessionId& session_id,

View File

@@ -794,6 +794,7 @@ class Adapter {
wvcdm::metrics::OEMCrypto_INITIALIZED_FORCING_L3);
return result;
}
LOGI("L3 Initialized. Trying L1.");
std::vector<std::string> library_names;
if (!wvcdm::Properties::GetOEMCryptoPaths(&library_names)) {
@@ -1376,9 +1377,15 @@ class Adapter {
std::mutex session_map_lock_;
std::vector<uint8_t> sandbox_id_;
// For running the unit tests using the level 3 oemcrypto. If the user sets
// the environment FORCE_LEVEL3_OEMCRYPTO, we ignore the level 1 library.
// First check if user sets force L3 property to be true. Then
// check if the user sets the environment FORCE_LEVEL3_OEMCRYPTO
// for running the unit tests using the level 3 oemcrypto.
// If any of above is true, we ignore the level 1 library.
bool force_level3() {
if (wvcdm::Properties::ForceL3()) {
LOGW("User requested falling back to L3");
return true;
}
const char* var = getenv("FORCE_LEVEL3_OEMCRYPTO");
if (!var) return false;
return !strcmp(var, "yes");