Source release 15.0.0

This commit is contained in:
John W. Bruce
2019-02-28 16:25:30 -08:00
parent f51edaba5a
commit 66628486b5
2672 changed files with 260431 additions and 762489 deletions

View File

@@ -8,6 +8,7 @@
#include <stddef.h>
#include <stdint.h>
#include <mutex>
#include <ostream>
#include "OEMCryptoCENC.h"
@@ -66,6 +67,8 @@ const int kErrorCodeFieldNumber =
::drm_metrics::Attributes::kErrorCodeFieldNumber;
const int kErrorCodeBoolFieldNumber =
::drm_metrics::Attributes::kErrorCodeBoolFieldNumber;
const int kErrorDetailFieldNumber =
::drm_metrics::Attributes::kErrorDetailFieldNumber;
const int kCdmSecurityLevelFieldNumber =
::drm_metrics::Attributes::kCdmSecurityLevelFieldNumber;
const int kSecurityLevelFieldNumber =
@@ -84,9 +87,15 @@ const int kEventTypeFieldNumber =
::drm_metrics::Attributes::kEventTypeFieldNumber;
const int kKeyRequestTypeFieldNumber =
::drm_metrics::Attributes::kKeyRequestTypeFieldNumber;
const int kLicenseTypeFieldNumber =
::drm_metrics::Attributes::kLicenseTypeFieldNumber;
} // anonymous namespace
// The maximum number of completed sessions that can be stored. More than this
// will cause some metrics to be discarded.
const int kMaxCompletedSessions = 40;
// This enum defines the conditions encountered during OEMCrypto Initialization
// in oemcrypto_adapter_dynamic.
typedef enum OEMCryptoInitializationMode {
@@ -106,10 +115,13 @@ typedef enum OEMCryptoInitializationMode {
OEMCrypto_INITIALIZED_USING_L1_INSTALLED_KEYBOX = 13,
OEMCrypto_INITIALIZED_USING_L3_INVALID_L1 = 14,
OEMCrypto_INITIALIZED_USING_L1_WITH_PROVISIONING_3_0 = 15,
OEMCrypto_INITIALIZED_L3_INITIALIZATION_FAILED = 16
OEMCrypto_INITIALIZED_L3_INITIALIZATION_FAILED = 16,
OEMCrypto_INITIALIZED_L3_RNG_FAILED = 17,
OEMCrypto_INITIALIZED_L3_SAVE_DEVICE_KEYS_FAILED = 18,
OEMCrypto_INITIALIZED_L3_READ_DEVICE_KEYS_FAILED = 19,
OEMCrypto_INITIALIZED_L3_VERIFY_DEVICE_KEYS_FAILED = 20,
} OEMCryptoInitializationMode;
// This class contains metrics for Crypto Session and OEM Crypto.
class CryptoMetrics {
public:
@@ -135,11 +147,12 @@ class CryptoMetrics {
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kLengthFieldNumber,
Pow2Bucket, kSigningAlgorithmFieldNumber, CdmSigningAlgorithm>
crypto_session_generic_verify_;
CounterMetric<kErrorCodeBoolFieldNumber, bool>
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
crypto_session_get_device_unique_id_;
CounterMetric<kErrorCodeBoolFieldNumber, bool> crypto_session_get_token_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
crypto_session_get_token_;
ValueMetric<double> crypto_session_life_span_;
EventMetric<kErrorCodeBoolFieldNumber, bool>
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
crypto_session_load_certificate_private_key_;
// This uses the requested security level.
EventMetric<kErrorCodeFieldNumber, CdmResponseType, kSecurityLevelFieldNumber,
@@ -265,13 +278,16 @@ class SessionMetrics {
// Metrics collected at the session level.
ValueMetric<double> cdm_session_life_span_; // Milliseconds.
EventMetric<kErrorCodeFieldNumber, CdmResponseType> cdm_session_renew_key_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
CounterMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
cdm_session_restore_offline_session_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
CounterMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
cdm_session_restore_usage_session_;
EventMetric<kKeyRequestTypeFieldNumber, CdmKeyRequestType>
cdm_session_license_request_latency_ms_;
ValueMetric<std::string> oemcrypto_build_info_;
// Serialize the session metrics to the provided |metric_group|.
// |metric_group| is owned by the caller and must not be null.
@@ -301,6 +317,8 @@ class OemCryptoDynamicAdapterMetrics {
// Set methods for OEMCrypto metrics.
void SetInitializationMode(OEMCryptoInitializationMode mode);
void SetLevel3InitializationError(OEMCryptoInitializationMode mode);
void SetPreviousInitializationFailure(OEMCryptoInitializationMode mode);
void SetL1ApiVersion(uint32_t version);
void SetL1MinApiVersion(uint32_t version);
@@ -313,8 +331,12 @@ class OemCryptoDynamicAdapterMetrics {
void Clear();
private:
mutable Lock adapter_lock_;
mutable std::mutex adapter_lock_;
ValueMetric<OEMCryptoInitializationMode>
level3_oemcrypto_initialization_error_;
ValueMetric<OEMCryptoInitializationMode> oemcrypto_initialization_mode_;
ValueMetric<OEMCryptoInitializationMode>
previous_oemcrypto_initialization_failure_;
ValueMetric<uint32_t> oemcrypto_l1_api_version_;
ValueMetric<uint32_t> oemcrypto_l1_min_api_version_;
};
@@ -335,36 +357,38 @@ class EngineMetrics {
~EngineMetrics();
// Add a new SessionMetrics instance and return a pointer to the caller.
// The new SessionMetrics instance is owned by this EngineMetrics instance
// and will exist until RemoveSession is called or this object is deleted.
SessionMetrics *AddSession();
// A shared_ptr is used since it's possible that the SessionMetrics instance
// may be in use after the EngineMetrics instance is closed. The EngineMetrics
// instance will hold a shared_ptr reference to the SessionMetrics instance
// until RemoveSession is called, the EngineMetrics instance is deleted, or
// the SessionMetrics instance is marked as completed and ConsolidateSessions
// removes it.
std::shared_ptr<SessionMetrics> AddSession();
// Removes the metrics object for the given session id. This should only
// be called when the SessionMetrics instance is no longer in use.
void RemoveSession(CdmSessionId session_id);
// Looks for session metrics that have been marked as completed. These metrics
// may be merged or discarded if there are too many completed session metric
// instances.
void ConsolidateSessions();
// Returns a pointer to the crypto metrics belonging to the engine instance.
// The CryptoMetrics instance is still owned by this object and will exist
// until this object is deleted.
CryptoMetrics *GetCryptoMetrics() { return &crypto_metrics_; }
// Serialize engine and session metrics into a serialized MetricsGroup
// instance and output that instance to the provided |metric_group|.
// |metric_group| is owned by the caller and must NOT be null.
// |completed_only| indicates that this call should only publish
// SessionMetrics instances that are marked as completed.
// |clear_sessions| indicates that this call should clear sessions metrics
// for those sessions that were serialized. This allows atomic
// serialization and closing of session-level metrics.
// void Serialize(drm_metrics::MetricsGroup* metric_group, bool
// completed_only,
// bool clear_serialized_sessions);
// Serialize engine and session metrics into a serialized WvCdmMetrics
// instance and output that instance to the provided |engine_metrics|.
// |engine_metrics| is owned by the caller and must NOT be null.
void Serialize(drm_metrics::WvCdmMetrics *engine_metrics) const;
void SetAppPackageName(const std::string &app_package_name);
// Metrics recorded at the engine level.
EventMetric<kErrorCodeFieldNumber, CdmResponseType> cdm_engine_add_key_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kLicenseTypeFieldNumber, CdmLicenseType> cdm_engine_add_key_;
ValueMetric<std::string> cdm_engine_cdm_version_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_close_session_;
@@ -374,13 +398,15 @@ class EngineMetrics {
cdm_engine_decrypt_;
CounterMetric<kErrorCodeBoolFieldNumber, bool>
cdm_engine_find_session_for_key_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kLicenseTypeFieldNumber, CdmLicenseType>
cdm_engine_generate_key_request_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_get_provisioning_request_;
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_get_secure_stop_ids_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
kErrorDetailFieldNumber, int32_t>
cdm_engine_get_usage_info_;
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
cdm_engine_handle_provisioning_response_;
@@ -405,8 +431,11 @@ class EngineMetrics {
cdm_engine_unprovision_;
private:
mutable Lock session_metrics_lock_;
std::vector<metrics::SessionMetrics *> session_metrics_list_;
mutable std::mutex session_metrics_lock_;
std::vector<std::shared_ptr<metrics::SessionMetrics>>
active_session_metrics_list_;
std::vector<std::shared_ptr<metrics::SessionMetrics>>
completed_session_metrics_list_;
// This is used to populate the engine lifespan metric
metrics::TimerMetric life_span_internal_;
CryptoMetrics crypto_metrics_;