Merge "Cache security level" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
47324cc6fe
@@ -35,6 +35,7 @@
|
|||||||
#include "metrics_collections.h"
|
#include "metrics_collections.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "wv_cdm_constants.h"
|
#include "wv_cdm_constants.h"
|
||||||
|
#include "wv_cdm_types.h"
|
||||||
|
|
||||||
using namespace wvoec3;
|
using namespace wvoec3;
|
||||||
using video_widevine::ProvisioningResponse;
|
using video_widevine::ProvisioningResponse;
|
||||||
@@ -319,6 +320,7 @@ typedef OEMCryptoResult (*L1_LoadProvisioning_t)(
|
|||||||
typedef uint32_t (*L1_MinorAPIVersion_t)();
|
typedef uint32_t (*L1_MinorAPIVersion_t)();
|
||||||
|
|
||||||
struct FunctionPointers {
|
struct FunctionPointers {
|
||||||
|
wvcdm::CdmSecurityLevel security_level;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
L1_Initialize_t Initialize;
|
L1_Initialize_t Initialize;
|
||||||
L1_SetSandbox_t SetSandbox;
|
L1_SetSandbox_t SetSandbox;
|
||||||
@@ -690,6 +692,7 @@ class Adapter {
|
|||||||
|
|
||||||
level1_ = FunctionPointers(); // start with all null pointers.
|
level1_ = FunctionPointers(); // start with all null pointers.
|
||||||
level3_ = FunctionPointers(); // start with all null pointers.
|
level3_ = FunctionPointers(); // start with all null pointers.
|
||||||
|
level3_.security_level = wvcdm::kSecurityLevelL3;
|
||||||
LoadLevel3();
|
LoadLevel3();
|
||||||
WatchDog* watcher = new WatchDog(sandbox_id_);
|
WatchDog* watcher = new WatchDog(sandbox_id_);
|
||||||
watcher->CheckForPreviousFailure(&metrics);
|
watcher->CheckForPreviousFailure(&metrics);
|
||||||
@@ -782,6 +785,7 @@ class Adapter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
level1_.version = level1_.APIVersion();
|
level1_.version = level1_.APIVersion();
|
||||||
|
level1_.security_level = wvcdm::kSecurityLevelUninitialized;
|
||||||
metrics->SetL1ApiVersion(level1_.version);
|
metrics->SetL1ApiVersion(level1_.version);
|
||||||
metrics->SetL1MinApiVersion(kMinimumVersion);
|
metrics->SetL1MinApiVersion(kMinimumVersion);
|
||||||
|
|
||||||
@@ -895,6 +899,22 @@ class Adapter {
|
|||||||
level1_library_, "OEMCrypto_FreeSecureBuffer");
|
level1_library_, "OEMCrypto_FreeSecureBuffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (level1_.SecurityLevel) {
|
||||||
|
const char* level = level1_.SecurityLevel();
|
||||||
|
if (strncmp(level, "L1", 2) == 0) {
|
||||||
|
level1_.security_level = wvcdm::kSecurityLevelL1;
|
||||||
|
} else if (strncmp(level, "L3", 2) == 0) {
|
||||||
|
// It is possible that the dynamically loaded OEMCrypto is really L3.
|
||||||
|
// We might want to use it if it has better performance than the built
|
||||||
|
// in L3.
|
||||||
|
LOGW("L1 OEMCrypto is really L3");
|
||||||
|
level1_.security_level = wvcdm::kSecurityLevelL3;
|
||||||
|
} else {
|
||||||
|
LOGE("Unknown security level %.2s", level);
|
||||||
|
level1_.security_level = wvcdm::kSecurityLevelUnknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(119830252): make the code below available to a static adapter.
|
// TODO(119830252): make the code below available to a static adapter.
|
||||||
// Check if the keybox or oem certificate is valid, if so, we are finished
|
// Check if the keybox or oem certificate is valid, if so, we are finished
|
||||||
// with initialization.
|
// with initialization.
|
||||||
@@ -1219,8 +1239,16 @@ const char* OEMCrypto_SecurityLevel(SecurityLevel level) {
|
|||||||
if (!gAdapter) return "";
|
if (!gAdapter) return "";
|
||||||
const FunctionPointers* fcn = gAdapter->GetFunctionPointers(level);
|
const FunctionPointers* fcn = gAdapter->GetFunctionPointers(level);
|
||||||
if (!fcn) return "";
|
if (!fcn) return "";
|
||||||
if (fcn->SecurityLevel == nullptr) return "";
|
switch (fcn->security_level) {
|
||||||
return fcn->SecurityLevel();
|
case kSecurityLevelL1:
|
||||||
|
return "L1";
|
||||||
|
case kSecurityLevelL2:
|
||||||
|
return "L2";
|
||||||
|
case kSecurityLevelL3:
|
||||||
|
return "L3";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OEMCryptoResult OEMCrypto_GetHDCPCapability(
|
OEMCryptoResult OEMCrypto_GetHDCPCapability(
|
||||||
|
|||||||
Reference in New Issue
Block a user