Merge "Include DRM key type to SessionMetrics."
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
return false; \
|
||||
}
|
||||
|
||||
namespace wvcdm {
|
||||
namespace {
|
||||
const size_t kKeySetIdLength = 14;
|
||||
|
||||
@@ -49,10 +50,22 @@ void SetErrorDetail(int* error_detail, T error_code) {
|
||||
}
|
||||
}
|
||||
|
||||
int DrmKeyTypeToMetricValue(CryptoWrappedKey::Type type) {
|
||||
constexpr int kUnknownMetricType = -1;
|
||||
constexpr int kRsaMetricType = 0;
|
||||
constexpr int kEccMetricType = 1;
|
||||
switch (type) {
|
||||
case CryptoWrappedKey::kRsa:
|
||||
return kRsaMetricType;
|
||||
case CryptoWrappedKey::kEcc:
|
||||
return kEccMetricType;
|
||||
default:
|
||||
LOGE("Unexpected DRM key type: %d", static_cast<int>(type));
|
||||
return kUnknownMetricType;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
CdmSession::CdmSession(FileSystem* file_system,
|
||||
std::shared_ptr<metrics::SessionMetrics> metrics)
|
||||
: metrics_(metrics),
|
||||
@@ -187,6 +200,8 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
load_cert_sts);
|
||||
switch (load_cert_sts) {
|
||||
case NO_ERROR:
|
||||
metrics_->drm_certificate_key_type_.Record(
|
||||
DrmKeyTypeToMetricValue(private_key.type()));
|
||||
break;
|
||||
case SESSION_LOST_STATE_ERROR:
|
||||
case SYSTEM_INVALIDATED_ERROR:
|
||||
|
||||
@@ -1300,7 +1300,7 @@ CdmResponseType CryptoSession::LoadCertificatePrivateKey(
|
||||
oec_session_id_, key_type,
|
||||
reinterpret_cast<const uint8_t*>(wrapped_key.data()),
|
||||
wrapped_key.size()),
|
||||
metrics_, oemcrypto_load_device_rsa_key_, sts);
|
||||
metrics_, oemcrypto_load_device_drm_key_, sts);
|
||||
});
|
||||
|
||||
return MapOEMCryptoResult(sts, LOAD_DEVICE_RSA_KEY_ERROR,
|
||||
|
||||
@@ -234,7 +234,7 @@ class CryptoMetrics {
|
||||
ValueMetric<bool> oemcrypto_is_anti_rollback_hw_present_;
|
||||
ValueMetric<bool> oemcrypto_is_keybox_valid_;
|
||||
EventMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||
oemcrypto_load_device_rsa_key_;
|
||||
oemcrypto_load_device_drm_key_;
|
||||
EventMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||
oemcrypto_load_entitled_keys_;
|
||||
EventMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||
@@ -338,6 +338,7 @@ class SessionMetrics {
|
||||
ValueMetric<std::string> license_sdk_version_;
|
||||
ValueMetric<std::string> license_service_version_;
|
||||
ValueMetric<std::string> playback_id_;
|
||||
ValueMetric<int> drm_certificate_key_type_;
|
||||
|
||||
// Serialize the session metrics to the provided |metric_group|.
|
||||
// |metric_group| is owned by the caller and must not be null.
|
||||
|
||||
@@ -140,8 +140,8 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
|
||||
oemcrypto_is_anti_rollback_hw_present_.ToProto());
|
||||
crypto_metrics->set_allocated_oemcrypto_is_keybox_valid(
|
||||
oemcrypto_is_keybox_valid_.ToProto());
|
||||
oemcrypto_load_device_rsa_key_.ToProto(
|
||||
crypto_metrics->mutable_oemcrypto_load_device_rsa_key_time_us());
|
||||
oemcrypto_load_device_drm_key_.ToProto(
|
||||
crypto_metrics->mutable_oemcrypto_load_device_drm_key_time_us());
|
||||
oemcrypto_load_entitled_keys_.ToProto(
|
||||
crypto_metrics->mutable_oemcrypto_load_entitled_keys_time_us());
|
||||
oemcrypto_load_keys_.ToProto(
|
||||
@@ -247,6 +247,8 @@ void SessionMetrics::SerializeSessionMetrics(
|
||||
session_metrics->set_allocated_license_service_version(
|
||||
license_service_version_.ToProto());
|
||||
session_metrics->set_allocated_playback_id(playback_id_.ToProto());
|
||||
session_metrics->set_allocated_drm_certificate_key_type(
|
||||
drm_certificate_key_type_.ToProto());
|
||||
}
|
||||
|
||||
OemCryptoDynamicAdapterMetrics::OemCryptoDynamicAdapterMetrics()
|
||||
|
||||
@@ -155,7 +155,7 @@ message WvCdmMetrics {
|
||||
repeated DistributionMetric oemcrypto_initialize_time_us = 38;
|
||||
optional ValueMetric oemcrypto_is_anti_rollback_hw_present = 39;
|
||||
optional ValueMetric oemcrypto_is_keybox_valid = 40;
|
||||
repeated DistributionMetric oemcrypto_load_device_rsa_key_time_us = 41;
|
||||
repeated DistributionMetric oemcrypto_load_device_drm_key_time_us = 41;
|
||||
repeated DistributionMetric oemcrypto_load_entitled_keys_time_us = 42;
|
||||
repeated DistributionMetric oemcrypto_load_keys_time_us = 43;
|
||||
optional ValueMetric oemcrypto_max_hdcp_capability = 44;
|
||||
@@ -182,8 +182,6 @@ message WvCdmMetrics {
|
||||
optional ValueMetric oemcrypto_set_sandbox = 70;
|
||||
repeated CounterMetric oemcrypto_set_decrypt_hash = 71;
|
||||
optional ValueMetric oemcrypto_resource_rating_tier = 72;
|
||||
// TODO(b/142684157): Remove this comment before closing bug.
|
||||
// OemCrypto V16 metrics start at 77 (4 new metrics pending review).
|
||||
repeated DistributionMetric
|
||||
oemcrypto_prep_and_sign_license_request_time_us = 77;
|
||||
repeated DistributionMetric
|
||||
@@ -199,7 +197,7 @@ message WvCdmMetrics {
|
||||
|
||||
// This contains metrics that were captured within a CdmSession. This contains
|
||||
// nested CryptoMetrics that were captured in the context of the session.
|
||||
// next id: 9
|
||||
// next id: 13
|
||||
message SessionMetrics {
|
||||
optional ValueMetric session_id = 1;
|
||||
optional CryptoMetrics crypto_metrics = 2;
|
||||
@@ -212,6 +210,8 @@ message WvCdmMetrics {
|
||||
optional ValueMetric license_sdk_version = 9;
|
||||
optional ValueMetric license_service_version = 10;
|
||||
optional ValueMetric playback_id = 11;
|
||||
// Value is enumerated based on the OEMCrypto document: RSA = 0, ECC = 1
|
||||
optional ValueMetric drm_certificate_key_type = 12;
|
||||
}
|
||||
|
||||
// These are metrics recorded at the Engine level. This includes CryptoSession
|
||||
|
||||
@@ -276,6 +276,7 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) {
|
||||
session_metrics.oemcrypto_build_info_.Record("test build info");
|
||||
session_metrics.license_sdk_version_.Record("test license sdk version");
|
||||
session_metrics.license_service_version_.Record("test license service version");
|
||||
session_metrics.drm_certificate_key_type_.Record(1);
|
||||
|
||||
// Record a CryptoMetrics metric in the session.
|
||||
session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_
|
||||
@@ -297,6 +298,7 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) {
|
||||
actual.license_service_version().string_value().c_str());
|
||||
EXPECT_GT(
|
||||
actual.crypto_metrics().crypto_session_generic_decrypt_time_us_size(), 0);
|
||||
EXPECT_EQ(1, actual.drm_certificate_key_type().int_value());
|
||||
}
|
||||
|
||||
TEST_F(SessionMetricsTest, EmptySessionMetrics) {
|
||||
@@ -404,8 +406,8 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
|
||||
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
|
||||
crypto_metrics.oemcrypto_is_anti_rollback_hw_present_.Record(true);
|
||||
crypto_metrics.oemcrypto_is_keybox_valid_.Record(true);
|
||||
crypto_metrics.oemcrypto_load_device_rsa_key_
|
||||
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
|
||||
crypto_metrics.oemcrypto_load_device_drm_key_.Record(
|
||||
1.0, OEMCrypto_ERROR_INIT_FAILED);
|
||||
crypto_metrics.oemcrypto_load_keys_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
|
||||
crypto_metrics.oemcrypto_refresh_keys_
|
||||
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
|
||||
@@ -509,7 +511,7 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
|
||||
EXPECT_GT(actual.oemcrypto_initialize_time_us_size(), 0);
|
||||
EXPECT_EQ(true, actual.oemcrypto_is_anti_rollback_hw_present().int_value());
|
||||
EXPECT_EQ(true, actual.oemcrypto_is_keybox_valid().int_value());
|
||||
EXPECT_GT(actual.oemcrypto_load_device_rsa_key_time_us_size(), 0);
|
||||
EXPECT_GT(actual.oemcrypto_load_device_drm_key_time_us_size(), 0);
|
||||
EXPECT_GT(actual.oemcrypto_load_keys_time_us_size(), 0);
|
||||
EXPECT_GT(actual.oemcrypto_refresh_keys_time_us_size(), 0);
|
||||
EXPECT_GT(actual.oemcrypto_report_usage_size(), 0);
|
||||
|
||||
@@ -570,8 +570,8 @@ void HidlMetricsAdapter::AddCryptoMetrics(
|
||||
proto_metrics.oemcrypto_is_keybox_valid());
|
||||
}
|
||||
group_builder->AddDistributions(
|
||||
"oemcrypto_load_device_rsa_key_time_us",
|
||||
proto_metrics.oemcrypto_load_device_rsa_key_time_us());
|
||||
"oemcrypto_load_device_drm_key_time_us",
|
||||
proto_metrics.oemcrypto_load_device_drm_key_time_us());
|
||||
group_builder->AddDistributions(
|
||||
"oemcrypto_load_entitled_keys_time_us",
|
||||
proto_metrics.oemcrypto_load_entitled_keys_time_us());
|
||||
|
||||
@@ -378,7 +378,7 @@ TEST(HidlMetricsAdapterTest, EngineAndSessionAllMetrics) {
|
||||
crypto_metrics.mutable_oemcrypto_is_anti_rollback_hw_present
|
||||
()->set_int_value(1);
|
||||
crypto_metrics.mutable_oemcrypto_is_keybox_valid()->set_int_value(1);
|
||||
crypto_metrics.add_oemcrypto_load_device_rsa_key_time_us()->set_min(1.0f);
|
||||
crypto_metrics.add_oemcrypto_load_device_drm_key_time_us()->set_min(1.0f);
|
||||
crypto_metrics.add_oemcrypto_load_entitled_keys_time_us()->set_min(1.0f);
|
||||
crypto_metrics.add_oemcrypto_load_keys_time_us()->set_min(1.0f);
|
||||
crypto_metrics.mutable_oemcrypto_max_hdcp_capability()->set_int_value(1);
|
||||
|
||||
@@ -333,7 +333,7 @@ void FormatCryptoMetrics(const WvCdmMetrics_CryptoMetrics metrics,
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_initialize_time_us, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_is_anti_rollback_hw_present, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_is_keybox_valid, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_device_rsa_key_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_device_drm_key_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_entitled_keys_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_keys_time_us, indent);
|
||||
FORMAT_OPTIONAL_HDCP_CAPABILITY(oemcrypto_max_hdcp_capability, indent);
|
||||
|
||||
@@ -330,7 +330,7 @@ void FormatCryptoMetrics(const drm_metrics::WvCdmMetrics_CryptoMetrics metrics,
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_initialize_time_us, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_is_anti_rollback_hw_present, indent);
|
||||
FORMAT_OPTIONAL_VALUE(oemcrypto_is_keybox_valid, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_device_rsa_key_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_device_drm_key_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_entitled_keys_time_us, indent);
|
||||
FORMAT_REPEATED_DISTRIBUTION(oemcrypto_load_keys_time_us, indent);
|
||||
FORMAT_OPTIONAL_HDCP_CAPABILITY(oemcrypto_max_hdcp_capability, indent);
|
||||
|
||||
Reference in New Issue
Block a user