Allow querying of OEMCrypto build information
[ Merge of http://go/wvgerrit/67503 ] Bug: 117118184 Test: WV unit/integration tests Change-Id: I8db90c1617e068a4711eb41a5852d15b5e228f2f
This commit is contained in:
@@ -149,6 +149,8 @@ class CryptoSession {
|
||||
virtual bool IsSrmUpdateSupported();
|
||||
virtual bool LoadSrm(const std::string& srm);
|
||||
|
||||
virtual bool GetBuildInformation(std::string* info);
|
||||
|
||||
virtual CdmResponseType GenericEncrypt(const std::string& in_buffer,
|
||||
const std::string& key_id,
|
||||
const std::string& iv,
|
||||
|
||||
@@ -71,6 +71,8 @@ static const std::string QUERY_KEY_CURRENT_SRM_VERSION = "CurrentSRMVersion";
|
||||
static const std::string QUERY_KEY_SRM_UPDATE_SUPPORT = "SRMUpdateSupport";
|
||||
// whether OEM supports SRM update
|
||||
static const std::string QUERY_KEY_WVCDM_VERSION = "WidevineCdmVersion";
|
||||
static const std::string QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION =
|
||||
"OemCryptoBuildInformation";
|
||||
|
||||
static const std::string QUERY_VALUE_TRUE = "True";
|
||||
static const std::string QUERY_VALUE_FALSE = "False";
|
||||
|
||||
@@ -642,6 +642,11 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
|
||||
}
|
||||
|
||||
*query_response = cdm_version;
|
||||
} else if (query_token == QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION) {
|
||||
if (!crypto_session->GetBuildInformation(query_response)) {
|
||||
LOGW("CdmEngine::QueryStatus: GetBuildInformation failed");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
} else {
|
||||
LOGW("CdmEngine::QueryStatus: Unknown status requested, token = %s",
|
||||
query_token.c_str());
|
||||
|
||||
@@ -1773,6 +1773,24 @@ bool CryptoSession::LoadSrm(const std::string& srm) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CryptoSession::GetBuildInformation(std::string* info) {
|
||||
LOGV("GetBuildInformation");
|
||||
if (!initialized_) return false;
|
||||
if (info == nullptr) {
|
||||
LOGE("CryptoSession::GetBuildInformation: |info| cannot be empty");
|
||||
return false;
|
||||
}
|
||||
const char* build_information =
|
||||
OEMCrypto_BuildInformation(requested_security_level_);
|
||||
if (build_information == nullptr) {
|
||||
LOGE("CryptoSession::GetBuildInformation: returned null");
|
||||
return false;
|
||||
}
|
||||
|
||||
info->assign(build_information);
|
||||
return true;
|
||||
}
|
||||
|
||||
CdmResponseType CryptoSession::GenericEncrypt(const std::string& in_buffer,
|
||||
const std::string& key_id,
|
||||
const std::string& iv,
|
||||
|
||||
@@ -4137,6 +4137,12 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
|
||||
ASSERT_FALSE(ss.fail());
|
||||
EXPECT_TRUE(ss.eof());
|
||||
EXPECT_LE(10u, api_version);
|
||||
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.QueryStatus(
|
||||
kLevelDefault, wvcdm::QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION,
|
||||
&value));
|
||||
EXPECT_TRUE(!value.empty());
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
|
||||
|
||||
@@ -524,6 +524,8 @@ status_t WVDrmPlugin::getPropertyString(const String8& name,
|
||||
return queryProperty(QUERY_KEY_CURRENT_SRM_VERSION, value);
|
||||
} else if (name == "SRMUpdateSupport") {
|
||||
return queryProperty(QUERY_KEY_SRM_UPDATE_SUPPORT, value);
|
||||
} else if (name == "oemCryptoBuildInformation") {
|
||||
return queryProperty(QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION, value);
|
||||
} else {
|
||||
ALOGE("App requested unknown string property %s", name.string());
|
||||
return android::ERROR_DRM_CANNOT_HANDLE;
|
||||
|
||||
@@ -1020,6 +1020,8 @@ Return<void> WVDrmPlugin::getPropertyString(const hidl_string& propertyName,
|
||||
status = queryProperty(wvcdm::QUERY_KEY_CURRENT_SRM_VERSION, value);
|
||||
} else if (name == "SRMUpdateSupport") {
|
||||
status = queryProperty(wvcdm::QUERY_KEY_SRM_UPDATE_SUPPORT, value);
|
||||
} else if (name == "oemCryptoBuildInformation") {
|
||||
status = queryProperty(wvcdm::QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION, value);
|
||||
} else {
|
||||
ALOGE("App requested unknown string property %s", name.c_str());
|
||||
status = Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
|
||||
@@ -109,6 +109,7 @@ using wvcdm::QUERY_KEY_SECURITY_LEVEL;
|
||||
using wvcdm::QUERY_KEY_SRM_UPDATE_SUPPORT;
|
||||
using wvcdm::QUERY_KEY_SYSTEM_ID;
|
||||
using wvcdm::QUERY_KEY_WVCDM_VERSION;
|
||||
using wvcdm::QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION;
|
||||
using wvcdm::QUERY_VALUE_SECURITY_LEVEL_L1;
|
||||
using wvcdm::QUERY_VALUE_SECURITY_LEVEL_L3;
|
||||
using wvcdm::SESSION_ID_PREFIX;
|
||||
@@ -1134,6 +1135,7 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
static const std::string oemCryptoApiVersion = "13";
|
||||
static const std::string currentSRMVersion = "1";
|
||||
static const std::string cdmVersion = "Infinity Minus 1";
|
||||
static const std::string oemCryptoBuildInformation = "Mostly Harmless";
|
||||
drm_metrics::WvCdmMetrics expected_metrics;
|
||||
std::string serialized_metrics = wvcdm::a2bs_hex(kSerializedMetricsHex);
|
||||
ASSERT_TRUE(expected_metrics.ParseFromString(serialized_metrics));
|
||||
@@ -1180,6 +1182,10 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
|
||||
.WillOnce(DoAll(SetArgPointee<2>(cdmVersion),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_OEMCRYPTO_BUILD_INFORMATION, _))
|
||||
.WillOnce(DoAll(SetArgPointee<2>(oemCryptoBuildInformation),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, GetMetrics(_, _))
|
||||
.WillOnce(DoAll(SetArgPointee<1>(expected_metrics),
|
||||
testing::Return(wvcdm::NO_ERROR)));
|
||||
|
||||
Reference in New Issue
Block a user