Test session should continue with no keybox am: 75b87c7f59 am: 78d0b73964
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/16507242 Change-Id: I448766407f548908468143aa2ca2e45b8362c10d
This commit is contained in:
committed by
Automerger Merge Worker
commit
2f964df424
@@ -323,8 +323,11 @@ class CryptoSession {
|
|||||||
|
|
||||||
int session_count() const { return session_count_; }
|
int session_count() const { return session_count_; }
|
||||||
bool initialized() const { return initialized_; }
|
bool initialized() const { return initialized_; }
|
||||||
void OverrideInitializedForTesting(bool initialized) {
|
void set_initialized(bool initialized) { initialized_ = initialized; }
|
||||||
initialized_ = initialized;
|
// Cache api version and fallback policy. Call this once at initialization.
|
||||||
|
void CacheVersion();
|
||||||
|
void OverrideNeedKeyboxForTesting(bool needs_keybox_provisioning) {
|
||||||
|
needs_keybox_provisioning_ = needs_keybox_provisioning;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -354,6 +354,11 @@ void CryptoSession::Init() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
|
CacheVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CryptoSession::CacheVersion() {
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
std::string api_version =
|
std::string api_version =
|
||||||
CryptoSession::GetApiVersion(kLevelDefault, &version)
|
CryptoSession::GetApiVersion(kLevelDefault, &version)
|
||||||
@@ -363,8 +368,8 @@ void CryptoSession::Init() {
|
|||||||
CryptoSession::GetApiMinorVersion(kLevelDefault, &version)
|
CryptoSession::GetApiMinorVersion(kLevelDefault, &version)
|
||||||
? std::to_string(version)
|
? std::to_string(version)
|
||||||
: kStringNotAvailable;
|
: kStringNotAvailable;
|
||||||
LOGD("OEMCrypto version (default security level): %s.%s",
|
LOGD("OEMCrypto version (default security level): %s.%s", api_version.c_str(),
|
||||||
api_version.c_str(), api_minor_version.c_str());
|
api_minor_version.c_str());
|
||||||
|
|
||||||
api_version = CryptoSession::GetApiVersion(kLevel3, &version)
|
api_version = CryptoSession::GetApiVersion(kLevel3, &version)
|
||||||
? std::to_string(version)
|
? std::to_string(version)
|
||||||
@@ -387,7 +392,6 @@ void CryptoSession::Init() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CryptoSession::TryTerminate() {
|
bool CryptoSession::TryTerminate() {
|
||||||
|
|||||||
@@ -223,14 +223,17 @@ std::string WvCdmTestBase::SignHMAC(const std::string& message,
|
|||||||
TestCryptoSession::TestCryptoSession(metrics::CryptoMetrics* crypto_metrics)
|
TestCryptoSession::TestCryptoSession(metrics::CryptoMetrics* crypto_metrics)
|
||||||
: CryptoSession(crypto_metrics) {
|
: CryptoSession(crypto_metrics) {
|
||||||
// The first CryptoSession should have initialized OEMCrypto. This is right
|
// The first CryptoSession should have initialized OEMCrypto. This is right
|
||||||
// after that, so should tell oemcrypto to use a test keybox.
|
// after that, so we should tell oemcrypto to use a test keybox.
|
||||||
if (session_count() == 1) {
|
if (session_count() == 1) {
|
||||||
|
OverrideNeedKeyboxForTesting(false);
|
||||||
|
// However, if the device does not have a keybox, initialization would have
|
||||||
|
// failed. In that case we should try again.
|
||||||
if (!initialized()) {
|
if (!initialized()) {
|
||||||
// If not initialized, try again and see if we are just missing a keybox.
|
// Give up if we cannot initialize at all.
|
||||||
// Since we plan to install a test keybox, we can ignore keybox errors.
|
if (OEMCrypto_SUCCESS != OEMCrypto_Initialize()) return;
|
||||||
const OEMCryptoResult status = ::OEMCrypto_Initialize();
|
set_initialized(true);
|
||||||
if (status != OEMCrypto_SUCCESS) return;
|
// This was skipped in Init because initialization failed.
|
||||||
OverrideInitializedForTesting(true);
|
CacheVersion();
|
||||||
}
|
}
|
||||||
WvCdmTestBase::InstallTestRootOfTrust();
|
WvCdmTestBase::InstallTestRootOfTrust();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user