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

@@ -129,6 +129,7 @@ cc_defaults {
"libwvdrmdrmplugin_aidl",
"libwvlevel3",
"lib_apex_manifest_minimal_proto_lite",
"libPlatformProperties",
],
}
@@ -227,6 +228,7 @@ cc_library_static {
static_libs: [
"libprotobuf-cpp-lite",
"lib_apex_manifest_minimal_proto_lite",
"libPlatformProperties",
],
min_sdk_version: "34",
@@ -286,6 +288,7 @@ cc_library {
"libwvdrmdrmplugin_aidl",
"libwvlevel3",
"lib_apex_manifest_minimal_proto_lite",
"libPlatformProperties",
],
shared_libs: [

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");

View File

@@ -10,11 +10,13 @@
#include <string>
#include <android-base/properties.h>
#include <android/sysprop/WidevineProperties.sysprop.h>
#include "log.h"
#include "wv_android_constants.h"
#include "widevine_apex_info.h"
using namespace android::sysprop;
namespace {
const char kBasePathPrefix[] = "/data/vendor/mediadrm/IDM";
@@ -211,4 +213,8 @@ bool Properties::AlwaysUseKeySetIds() { return false; }
bool Properties::UseProviderIdInProvisioningRequest() { return false; }
bool Properties::ForceL3() {
return WidevineProperties::forcel3_enabled().value_or(false);
}
} // namespace wvcdm

View File

@@ -60,6 +60,7 @@ LOCAL_STATIC_LIBRARIES := \
libwvlevel3 \
libwv_kdo \
libwv_odk \
libPlatformProperties \
LOCAL_SHARED_LIBRARIES := \
libbase \

View File

@@ -52,6 +52,7 @@ LOCAL_STATIC_LIBRARIES := \
libcdm_utils \
libwv_kdo \
libwv_odk \
libPlatformProperties \
LOCAL_SHARED_LIBRARIES := \
libbase \

View File

@@ -55,6 +55,7 @@ cc_test {
"libwv_odk",
"libwvdrmdrmplugin_aidl",
"libwvlevel3",
"libPlatformProperties",
],
shared_libs: [
"android.hardware.drm-V1-ndk",