Merges to android Pi release (part 9)
These are a set of CLs merged from the wv cdm repo to the android repo. * Make Android NDK Builds Work With Latest BoringSSL Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/37000 ] The latest updates to BoringSSL require C99 or later. Our NDK-based builds (OEMCrypto Variants & Fastball) were not specifying a C standard. This patch adds compiler flags so that C files are compiled as C11 now. Note that this is about the *C* standard in use, not the *C++* standard, which this patch leaves untouched. BUG: 67907873 Test: build_android_mock.sh * Update BoringSSL to f7412cb072cc6b1847140e0c4f8b3ceeccd0e708 Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/36761 ] This is the result of running UPDATE_BORINGSSL.sh. Future runs of this script should produce much smaller sets of changed files, but because the BoringSSL revision already in this directory was so old and contained many extraneous files from the Android operating system, the set of changed files is extensive this time. BUG: 67907873 * Refactoring the build files. Author: Vasantha Rao Polipelli <vasanthap@google.com> [ Merge of http://go/wvgerrit/37041 ] Move all common build dependencies to .gypi so that all fuzz test binary targets can be added to .gyp file without repeating code. * Introduce service certificate request property Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/36941 ] Platforms differ on whether they allows service certificates to be requested if privacy mode is enabled and a certificate is not present. This property allows behavior to be configurable. Generating the service certificate request will be introduced in a follow on CL. BUG: 68328352 * Deprecate using keyboxes as identification Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/36740 ] Previously some platforms supported using keyboxes rather than certificates as the identification tokens in the license request message. All platforms that share core CDM code of the master branch now either provision using a keybox and use a DRM certificate or an OEM certificate as identification. No future usage of keyboxes as identifying tokens is planned. Since the platform property use_certificates_as_identification is always set to true, the negative code paths are never taken and can be removed. * OEMCrypto_GenerateSignature API Fuzz Test. Author: Vasantha Rao Polipelli <vasanthap@google.com> [ Merge of http://go/wvgerrit/36863 ] - The first automated API fuzz test. - Also sumitting the corpus for the API fuzzed. * Add Script to Update BoringSSL from Source Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/36760 ] Adds a script to third_party/boringssl/ that, when run, deletes all the auto-generated files in the generated/ directory and regenerates them from scratch, starting from the latest public HEAD of BoringSSL. Bug: 67907873 * Fix Fastball / OEMCrypto Variant BoringSSL Makefiles Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/36926 ] Previously, when moving the BoringSSL source within the tree, I was not able to verify that I had not broken the NDK-compatible makefiles used by Fastball because that build is broken on master. I had to make a best-guess as to how they should be updated and hope. Now, however, I have been informed that the OEMCrypto Variants also use these makefiles, and I have been able to use that build to find where I broke them and get them fully working. Bug: 67386164 Test: build_android_mock.sh * Add kit/ to BoringSSL Include Path for Fastball & OEMCrypto Variants Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/36925 ] When I moved the BoringSSL source in the tree, I updated the Android.mk files that pointed to it in order to build it. I did not realize that some makefiles outside that directory also contained hardcoded pointers into that directory. These references broke after the move. This patch fixes those paths to point to the new BoringSSL location. Bug: 67386164 Test: build_android_mock.sh * OEMCrypto Unit Test Refactor. Author: Vasantha Rao Polipelli <vasanthap@google.com> [ Merge of http://go/wvgerrit/36562 ] Refactoring OEMCrypto Tests so the Session Utility test code can be reused in fuzz tests. * Reorder license server config table to match ids Author: Jeff Fore <jfore@google.com> [ Merge of http://go/wvgerrit/36743 ] * Separate Hand-Written BoringSSL Files from Downloaded/Generated Ones Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/36561 ] I want to make updating BoringSSL as simple as possible for us going forward. A future commit will add a script that automatically downloads and sets up the latest version of BoringSSL. To facilitate this script, a clear distinction needs to be made between the files that can be downloaded with / regenerated from the BoringSSL source and the files that are maintained by us by hand. The version of BoringSSL in this change is exactly the same as the one already in this directory. It has just been moved one folder deeper. Bug: 67907873 * Remove BoringSSL Symlinks, They Are Confusing Gerrit Author: John W. Bruce <juce@google.com> [ Merge of http://go/wvgerrit/36560 ] There are some symlinks in the current copy of BoringSSL that are causing headaches when I try to upload future changes to Gerrit. These were inherited from the Android OS and are not used by our build anywhere. They would be wiped out when I update BoringSSL anyway, but wiping them out in a separate change before I upload any other changes avoids confusing Gerrit. Bug: 67907873 * Add group master key id to support sublicense master key rotation, and content identification. Author: Jeff Fore <jfore@google.com> [ Merge of http://go/wvgerrit/36180 ] * OEMCrypto Fuzzer test framework Author: Vasantha Rao Polipelli <vasanthap@google.com> [ Merge of http://go/wvgerrit/36280 ] - Adding a sample fuzz test. - Adding build scripts for building the new Fuzz Tests to come. Design doc: go/oemcrypt_ref_impl_fuzz * Build Mod Mock with C++ 11 Author: Fred Gylys-Colwell <fredgc@google.com> [ Merge of http://go/wvgerrit/36328 ] This should fix the android oemcrypto mock build: http://go/wvbuild/job/Android_OEMCrypto_Variants BUG: 71650075 Test: Not currently passing. Will be addressed in a subsequent commit in the chain. Change-Id: Ic4d5be3118ef97e3f7d386149a2b5d9be8f0a87e
This commit is contained in:
@@ -6,18 +6,13 @@
|
||||
#define WVCDM_METRICS_EVENT_METRIC_H_
|
||||
|
||||
#include <cstdarg>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "lock.h"
|
||||
|
||||
#include "distribution.h"
|
||||
#include "field_tuples.h"
|
||||
#include "lock.h"
|
||||
#include "metric_serialization.h"
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -60,14 +55,6 @@ class BaseEventMetric : public MetricSerializable {
|
||||
Lock internal_lock_;
|
||||
};
|
||||
|
||||
// This is a placeholder type for unused type parameters.
|
||||
struct Unused {
|
||||
// Required for compilation. Should never be used.
|
||||
inline friend std::ostream& operator<< (std::ostream& out, const Unused&)
|
||||
{ return out; }
|
||||
};
|
||||
|
||||
|
||||
// This class converts the size_t value into the highest power of two
|
||||
// below the value. E.g. for 7, the value is 4. For 11, the value is 8.
|
||||
// This class is intended to simplify the use of EventMetric Fields that may
|
||||
@@ -113,7 +100,7 @@ class Pow2Bucket {
|
||||
// on certain "field" values. For example, if a particular operation can run in
|
||||
// one of two modes, it's useful to track the latency of the operation in each
|
||||
// mode separately. You can use Fields to define how to breakdown the
|
||||
// statistics. Each Field is a separate dimention. The statistics for each
|
||||
// statistics. Each Field is a separate dimension. The statistics for each
|
||||
// combination of field values are tracked independently.
|
||||
//
|
||||
// Example usage:
|
||||
@@ -123,19 +110,22 @@ class Pow2Bucket {
|
||||
//
|
||||
// my_metric.Record(1, 7, 23); // (latency value, request type, error code).
|
||||
//
|
||||
// A MetricNotification may be used to allow the EventMetric instance to
|
||||
// notify that an update occurred and provide the updated value.
|
||||
// The EventMetric supports serialization. A call to Serialize will
|
||||
// serialize all values to the provided MetricsSerializer instance.
|
||||
//
|
||||
// class MyMetricNotification : public MetricNotification {
|
||||
// example:
|
||||
//
|
||||
// class MyMetricSerializer : public MetricSerializer {
|
||||
// // Add implementation here.
|
||||
// }
|
||||
//
|
||||
// MyMetricNotification notification;
|
||||
// my_metric.Publish(notification);
|
||||
template<typename F1=Unused,
|
||||
typename F2=Unused,
|
||||
typename F3=Unused,
|
||||
typename F4=Unused>
|
||||
// MyMetricSerializer serializer;
|
||||
// my_metric.Serialize(&serializer);
|
||||
//
|
||||
template<typename F1=util::Unused,
|
||||
typename F2=util::Unused,
|
||||
typename F3=util::Unused,
|
||||
typename F4=util::Unused>
|
||||
class EventMetric : public BaseEventMetric {
|
||||
public:
|
||||
// Create an EventMetric instance with the name |metric_name|.
|
||||
@@ -162,116 +152,16 @@ class EventMetric : public BaseEventMetric {
|
||||
// Record will update the statistics of the EventMetric broken down by the
|
||||
// given field values.
|
||||
void Record(double value,
|
||||
F1 field1 = Unused(),
|
||||
F2 field2 = Unused(),
|
||||
F3 field3 = Unused(),
|
||||
F4 field4 = Unused());
|
||||
F1 field1 = util::Unused(),
|
||||
F2 field2 = util::Unused(),
|
||||
F3 field3 = util::Unused(),
|
||||
F4 field4 = util::Unused());
|
||||
|
||||
private:
|
||||
friend class EventMetricTest;
|
||||
std::vector<std::string> field_names_;
|
||||
};
|
||||
|
||||
// This is an internal namespace for helper functions only.
|
||||
namespace impl {
|
||||
|
||||
// This method formats the collection of field name/value pairs.
|
||||
// The format of the string is:
|
||||
//
|
||||
// [{field:value[&field:value]*}]
|
||||
//
|
||||
// If there are no pairs, returns a blank string.
|
||||
//
|
||||
// TODO(blueeyes): Add a check for the count of field_names and the count
|
||||
// of field values (check that the fields are not type Unused).
|
||||
template<typename F1, typename F2, typename F3, typename F4>
|
||||
std::string MakeFieldNameString(const std::vector<std::string>& field_names,
|
||||
const F1 field1, const F2 field2,
|
||||
const F3 field3, const F4 field4) {
|
||||
std::stringstream field_name_and_values;
|
||||
std::vector<std::string>::const_iterator field_name_iterator =
|
||||
field_names.begin();
|
||||
if (field_name_iterator == field_names.end()) {
|
||||
return field_name_and_values.str();
|
||||
}
|
||||
// There is at least one name/value pair. prepend open brace.
|
||||
field_name_and_values << "{";
|
||||
field_name_and_values << *field_name_iterator << ':' << field1;
|
||||
if (++field_name_iterator == field_names.end()) {
|
||||
field_name_and_values << "}";
|
||||
return field_name_and_values.str();
|
||||
}
|
||||
field_name_and_values << '&' << *field_name_iterator << ':' << field2;
|
||||
if (++field_name_iterator == field_names.end()) {
|
||||
field_name_and_values << "}";
|
||||
return field_name_and_values.str();
|
||||
}
|
||||
field_name_and_values << '&' << *field_name_iterator << ':' << field3;
|
||||
if (++field_name_iterator == field_names.end()) {
|
||||
field_name_and_values << "}";
|
||||
return field_name_and_values.str();
|
||||
}
|
||||
field_name_and_values << '&' << *field_name_iterator << ':' << field4;
|
||||
field_name_and_values << "}";
|
||||
return field_name_and_values.str();
|
||||
}
|
||||
|
||||
// This specialization of the helper method is a shortcut for EventMetric
|
||||
// instances with no fields.
|
||||
template<>
|
||||
inline std::string MakeFieldNameString<Unused, Unused, Unused, Unused>(
|
||||
const std::vector<std::string>& /* field_names */,
|
||||
const Unused /* unused1 */, const Unused /* unused2 */,
|
||||
const Unused /* unused3 */, const Unused /* unused4 */) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// This helper function appends the field names to a vector of strings.
|
||||
inline void AppendFieldNames(std::vector<std::string>* field_name_vector,
|
||||
int field_count, ...) {
|
||||
va_list field_names;
|
||||
|
||||
va_start(field_names, field_count);
|
||||
for (int x = 0; x < field_count; x++) {
|
||||
field_name_vector->push_back(va_arg(field_names, const char*));
|
||||
}
|
||||
va_end(field_names);
|
||||
}
|
||||
|
||||
// These helper methods and FirstUnusedType assure that there is no mismatch
|
||||
// between the specified types for EventMetrics and the constructors and
|
||||
// methods used for the specializations.
|
||||
template <bool>
|
||||
struct CompileAssert {};
|
||||
#define COMPILE_ASSERT(expr, msg) \
|
||||
typedef impl::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
|
||||
|
||||
template <typename T> struct is_unused { static const bool value = false; };
|
||||
template <> struct is_unused<Unused> { static const bool value = true; };
|
||||
|
||||
template <typename F1, typename F2, typename F3, typename F4>
|
||||
class FirstUnusedType {
|
||||
static const bool a = is_unused<F1>::value;
|
||||
static const bool b = is_unused<F2>::value;
|
||||
static const bool c = is_unused<F3>::value;
|
||||
static const bool d = is_unused<F4>::value;
|
||||
// Check that all types after the first Unused are also Unused.
|
||||
COMPILE_ASSERT(a <= b, Invalid_Unused_At_Position_2);
|
||||
COMPILE_ASSERT(b <= c, Invalid_Unused_At_Position_3);
|
||||
COMPILE_ASSERT(c <= d, Invalid_Unused_At_Position_4);
|
||||
|
||||
public:
|
||||
static const int value = 5 - (a + b + c + d);
|
||||
};
|
||||
|
||||
// Asserts that no Unused types exist before N; after N, are all Unused types.
|
||||
#define ASSERT_METRIC_UNUSED_START_FROM(N) \
|
||||
COMPILE_ASSERT((\
|
||||
impl::FirstUnusedType<F1, F2, F3, F4>::value) == N, \
|
||||
Unused_Start_From_##N)
|
||||
|
||||
} // namespace impl
|
||||
|
||||
// Overloaded template constructor implementations for EventMetric.
|
||||
template<typename F1, typename F2, typename F3, typename F4>
|
||||
EventMetric<F1, F2, F3, F4>::EventMetric(
|
||||
@@ -286,8 +176,8 @@ EventMetric<F1, F2, F3, F4>::EventMetric(
|
||||
const char* field_name)
|
||||
: BaseEventMetric(metric_name) {
|
||||
ASSERT_METRIC_UNUSED_START_FROM(2);
|
||||
impl::AppendFieldNames(&field_names_,
|
||||
impl::FirstUnusedType<F1, F2, F3, F4>::value - 1,
|
||||
util::AppendFieldNames(&field_names_,
|
||||
util::FirstUnusedType<F1, F2, F3, F4>::value - 1,
|
||||
field_name);
|
||||
}
|
||||
template<typename F1, typename F2, typename F3, typename F4>
|
||||
@@ -297,8 +187,8 @@ EventMetric<F1, F2, F3, F4>::EventMetric(
|
||||
const char* field_name2)
|
||||
: BaseEventMetric(metric_name) {
|
||||
ASSERT_METRIC_UNUSED_START_FROM(3);
|
||||
impl::AppendFieldNames(&field_names_,
|
||||
impl::FirstUnusedType<F1, F2, F3, F4>::value - 1,
|
||||
util::AppendFieldNames(&field_names_,
|
||||
util::FirstUnusedType<F1, F2, F3, F4>::value - 1,
|
||||
field_name1, field_name2);
|
||||
}
|
||||
template<typename F1, typename F2, typename F3, typename F4>
|
||||
@@ -309,8 +199,8 @@ EventMetric<F1, F2, F3, F4>::EventMetric(
|
||||
const char* field_name3)
|
||||
: BaseEventMetric(metric_name) {
|
||||
ASSERT_METRIC_UNUSED_START_FROM(4);
|
||||
impl::AppendFieldNames(&field_names_,
|
||||
impl::FirstUnusedType<F1, F2, F3, F4>::value - 1,
|
||||
util::AppendFieldNames(&field_names_,
|
||||
util::FirstUnusedType<F1, F2, F3, F4>::value - 1,
|
||||
field_name1, field_name2, field_name3);
|
||||
}
|
||||
template<typename F1, typename F2, typename F3, typename F4>
|
||||
@@ -322,8 +212,8 @@ EventMetric<F1, F2, F3, F4>::EventMetric(
|
||||
const char* field_name4)
|
||||
: BaseEventMetric(metric_name) {
|
||||
ASSERT_METRIC_UNUSED_START_FROM(5);
|
||||
impl::AppendFieldNames(&field_names_,
|
||||
impl::FirstUnusedType<F1, F2, F3, F4>::value - 1,
|
||||
util::AppendFieldNames(&field_names_,
|
||||
util::FirstUnusedType<F1, F2, F3, F4>::value - 1,
|
||||
field_name1, field_name2,
|
||||
field_name3, field_name4);
|
||||
}
|
||||
@@ -332,7 +222,7 @@ template<typename F1, typename F2, typename F3, typename F4>
|
||||
void EventMetric<F1, F2, F3, F4>::Record(
|
||||
double value, F1 field1, F2 field2, F3 field3, F4 field4) {
|
||||
std::string field_name_values =
|
||||
impl::MakeFieldNameString(field_names_, field1, field2, field3, field4);
|
||||
util::MakeFieldNameString(field_names_, field1, field2, field3, field4);
|
||||
BaseEventMetric::Record(field_name_values, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "counter_metric.h"
|
||||
#include "event_metric.h"
|
||||
#include "metrics.pb.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "value_metric.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
// This definition indicates that a given metric does not need timing
|
||||
@@ -86,70 +88,64 @@ class CryptoMetrics {
|
||||
void Serialize(drm_metrics::MetricsGroup* metrics);
|
||||
|
||||
/* CRYPTO SESSION */
|
||||
EventMetric<CdmResponseType> crypto_session_delete_all_usage_reports_;
|
||||
EventMetric<CdmResponseType> crypto_session_delete_multiple_usage_information_;
|
||||
// TODO(blueeyes): Convert this to crypto_session_default_security_level_.
|
||||
ValueMetric<CdmSecurityLevel> crypto_session_security_level_;
|
||||
CounterMetric<CdmResponseType> crypto_session_delete_all_usage_reports_;
|
||||
CounterMetric<CdmResponseType> crypto_session_delete_multiple_usage_information_;
|
||||
EventMetric<CdmResponseType, Pow2Bucket, CdmEncryptionAlgorithm> crypto_session_generic_decrypt_;
|
||||
EventMetric<CdmResponseType, Pow2Bucket, CdmEncryptionAlgorithm> crypto_session_generic_encrypt_;
|
||||
EventMetric<CdmResponseType, Pow2Bucket, CdmSigningAlgorithm> crypto_session_generic_sign_;
|
||||
EventMetric<CdmResponseType, Pow2Bucket, CdmSigningAlgorithm> crypto_session_generic_verify_;
|
||||
EventMetric<bool> crypto_session_get_device_unique_id_;
|
||||
EventMetric<CdmSecurityLevel> crypto_session_get_security_level_;
|
||||
EventMetric<bool, uint32_t> crypto_session_get_system_id_;
|
||||
EventMetric<bool> crypto_session_get_token_;
|
||||
EventMetric<> crypto_session_life_span_;
|
||||
CounterMetric<bool> crypto_session_get_device_unique_id_;
|
||||
CounterMetric<bool> crypto_session_get_token_;
|
||||
ValueMetric<double> crypto_session_life_span_;
|
||||
EventMetric<bool> crypto_session_load_certificate_private_key_;
|
||||
EventMetric<CdmResponseType, SecurityLevel> crypto_session_open_;
|
||||
EventMetric<CdmResponseType, SecurityLevel> crypto_session_open_; // This is the requested security level.
|
||||
ValueMetric<uint32_t> crypto_session_system_id_;
|
||||
EventMetric<CdmResponseType> crypto_session_update_usage_information_;
|
||||
EventMetric<bool> crypto_session_usage_information_support_;
|
||||
ValueMetric<bool> crypto_session_usage_information_support_;
|
||||
/* OEMCRYPTO */
|
||||
EventMetric<uint32_t, SecurityLevel> oemcrypto_api_version_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_close_session_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel, Pow2Bucket> oemcrypto_copy_buffer_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_deactivate_usage_entry_;
|
||||
ValueMetric<uint32_t> oemcrypto_api_version_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_close_session_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_copy_buffer_;
|
||||
ValueMetric<OEMCrypto_HDCP_Capability> oemcrypto_current_hdcp_capability_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_deactivate_usage_entry_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_decrypt_cenc_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_delete_usage_entry_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_delete_usage_table_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_delete_usage_entry_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_delete_usage_table_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_derive_keys_from_session_key_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_force_delete_usage_entry_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_force_delete_usage_entry_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_generate_derived_keys_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_generate_nonce_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_generate_nonce_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_generate_rsa_signature_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_generate_signature_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_generic_decrypt_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_generic_encrypt_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_generic_sign_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_generic_verify_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel> oemcrypto_get_device_id_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel> oemcrypto_get_hdcp_capability_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket, SecurityLevel> oemcrypto_get_key_data_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel> oemcrypto_get_max_number_of_sessions_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel> oemcrypto_get_number_of_open_sessions_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_get_oem_public_certificate_;
|
||||
EventMetric<OEMCrypto_ProvisioningMethod, SecurityLevel> oemcrypto_get_provisioning_method_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_get_random_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_get_device_id_;
|
||||
EventMetric<OEMCryptoResult, Pow2Bucket> oemcrypto_get_key_data_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_get_oem_public_certificate_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_get_random_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_initialize_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel> oemcrypto_install_keybox_;
|
||||
EventMetric<bool, SecurityLevel> oemcrypto_is_anti_rollback_hw_present_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel> oemcrypto_is_keybox_valid_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_install_keybox_;
|
||||
ValueMetric<bool> oemcrypto_is_anti_rollback_hw_present_;
|
||||
ValueMetric<bool> oemcrypto_is_keybox_valid_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_load_device_rsa_key_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_load_keys_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_load_test_keybox_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_load_test_rsa_key_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel> oemcrypto_open_session_;
|
||||
ValueMetric<OEMCrypto_HDCP_Capability> oemcrypto_max_hdcp_capability_;
|
||||
ValueMetric<size_t> oemcrypto_max_number_of_sessions_;
|
||||
ValueMetric<size_t> oemcrypto_number_of_open_sessions_;
|
||||
ValueMetric<OEMCrypto_ProvisioningMethod> oemcrypto_provisioning_method_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_refresh_keys_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_report_usage_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_report_usage_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_rewrap_device_rsa_key_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_rewrap_device_rsa_key_30_;
|
||||
EventMetric<CdmSecurityLevel, SecurityLevel> oemcrypto_security_level_;
|
||||
EventMetric<uint16_t, SecurityLevel> oemcrypto_security_patch_level_;
|
||||
ValueMetric<uint16_t> oemcrypto_security_patch_level_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_select_key_;
|
||||
EventMetric<OEMCryptoResult, SecurityLevel> oemcrypto_supports_usage_table_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_update_usage_table_;
|
||||
ValueMetric<bool> oemcrypto_supports_usage_table_;
|
||||
CounterMetric<OEMCryptoResult> oemcrypto_update_usage_table_;
|
||||
EventMetric<OEMCryptoResult> oemcrypto_wrap_keybox_;
|
||||
|
||||
/* Internal OEMCrypto Metrics */
|
||||
EventMetric<OEMCryptoInitializationMode> oemcrypto_initialization_mode_;
|
||||
EventMetric<uint32_t, uint32_t> oemcrypto_l1_api_version_;
|
||||
};
|
||||
|
||||
// This class contains session-scoped metrics. All properties and
|
||||
@@ -179,10 +175,10 @@ class SessionMetrics {
|
||||
CryptoMetrics* GetCryptoMetrics() { return &crypto_metrics_; }
|
||||
|
||||
// Metrics collected at the session level.
|
||||
EventMetric<> cdm_session_life_span_;
|
||||
ValueMetric<double> cdm_session_life_span_; // Milliseconds.
|
||||
EventMetric<CdmResponseType> cdm_session_renew_key_;
|
||||
EventMetric<CdmResponseType> cdm_session_restore_offline_session_;
|
||||
EventMetric<CdmResponseType> cdm_session_restore_usage_session_;
|
||||
CounterMetric<CdmResponseType> cdm_session_restore_offline_session_;
|
||||
CounterMetric<CdmResponseType> cdm_session_restore_usage_session_;
|
||||
|
||||
// Serialize the session metrics to the provided |metric_group|.
|
||||
// |metric_group| is owned by the caller and must not be null.
|
||||
@@ -195,6 +191,45 @@ class SessionMetrics {
|
||||
CryptoMetrics crypto_metrics_;
|
||||
};
|
||||
|
||||
// This class contains metrics for the OEMCrypto Dynamic Adapter. They are
|
||||
// separated from other metrics because they need to be encapsulated in a
|
||||
// singleton object. This is because the dynamic adapter uses the OEMCrypto
|
||||
// function signatures and contract and cannot be extended to inject
|
||||
// dependencies.
|
||||
//
|
||||
// Operations for this metrics class are serialized since these particular
|
||||
// metrics may be accessed by a separate thread during intialize even as
|
||||
// the metric may be serialized.
|
||||
class OemCryptoDynamicAdapterMetrics {
|
||||
public:
|
||||
explicit OemCryptoDynamicAdapterMetrics();
|
||||
|
||||
// Set methods for OEMCrypto metrics.
|
||||
void SetInitializationMode(OEMCryptoInitializationMode mode);
|
||||
void SetL1ApiVersion(uint32_t version);
|
||||
void SetL1MinApiVersion(uint32_t version);
|
||||
|
||||
// Serialize the session metrics to the provided |metric_group|.
|
||||
// |metric_group| is owned by the caller and must not be null.
|
||||
void Serialize(drm_metrics::MetricsGroup* metric_group);
|
||||
|
||||
// Clears the existing metric values.
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
Lock adapter_lock_;
|
||||
ValueMetric<OEMCryptoInitializationMode> oemcrypto_initialization_mode_;
|
||||
ValueMetric<uint32_t> oemcrypto_l1_api_version_;
|
||||
ValueMetric<uint32_t> oemcrypto_l1_min_api_version_;
|
||||
};
|
||||
|
||||
// This will fetch the singleton instance for dynamic adapter metrics.
|
||||
// This method is safe only if we use C++ 11. In C++ 11, static function-local
|
||||
// initialization is guaranteed to be threadsafe. We return the reference to
|
||||
// avoid non-guaranteed destructor order problems. Effectively, the destructor
|
||||
// is never run for the created instance.
|
||||
OemCryptoDynamicAdapterMetrics& GetDynamicAdapterMetricsInstance();
|
||||
|
||||
// This class contains engine-scoped metrics. All properties and
|
||||
// statistics related to operations within the engine, but outside
|
||||
// the scope of a session are recorded here.
|
||||
@@ -228,33 +263,39 @@ class EngineMetrics {
|
||||
void Serialize(drm_metrics::MetricsGroup* metric_group, bool completed_only,
|
||||
bool clear_serialized_sessions);
|
||||
|
||||
void SetAppPackageName(const std::string& app_package_name);
|
||||
|
||||
// Metrics recorded at the engine level.
|
||||
EventMetric<CdmResponseType> cdm_engine_add_key_;
|
||||
EventMetric<CdmResponseType> cdm_engine_close_session_;
|
||||
EventMetric<CdmResponseType> cdm_engine_decrypt_;
|
||||
EventMetric<bool> cdm_engine_find_session_for_key_;
|
||||
ValueMetric<std::string> cdm_engine_cdm_version_;
|
||||
CounterMetric<CdmResponseType> cdm_engine_close_session_;
|
||||
ValueMetric<int64_t> cdm_engine_creation_time_millis_;
|
||||
EventMetric<CdmResponseType, Pow2Bucket> cdm_engine_decrypt_;
|
||||
CounterMetric<bool> cdm_engine_find_session_for_key_;
|
||||
EventMetric<CdmResponseType> cdm_engine_generate_key_request_;
|
||||
EventMetric<CdmResponseType> cdm_engine_get_provisioning_request_;
|
||||
EventMetric<CdmResponseType> cdm_engine_get_usage_info_;
|
||||
EventMetric<CdmResponseType> cdm_engine_handle_provisioning_response_;
|
||||
EventMetric<> cdm_engine_life_span_;
|
||||
EventMetric<CdmResponseType> cdm_engine_open_key_set_session_;
|
||||
EventMetric<CdmResponseType> cdm_engine_open_session_;
|
||||
ValueMetric<double> cdm_engine_life_span_; // Milliseconds
|
||||
CounterMetric<CdmResponseType> cdm_engine_open_key_set_session_;
|
||||
CounterMetric<CdmResponseType> cdm_engine_open_session_;
|
||||
EventMetric<CdmResponseType> cdm_engine_query_key_status_;
|
||||
EventMetric<CdmResponseType> cdm_engine_release_all_usage_info_;
|
||||
EventMetric<CdmResponseType> cdm_engine_release_usage_info_;
|
||||
EventMetric<CdmResponseType> cdm_engine_remove_keys_;
|
||||
CounterMetric<CdmResponseType> cdm_engine_release_all_usage_info_;
|
||||
CounterMetric<CdmResponseType> cdm_engine_release_usage_info_;
|
||||
CounterMetric<CdmResponseType> cdm_engine_remove_keys_;
|
||||
EventMetric<CdmResponseType> cdm_engine_restore_key_;
|
||||
EventMetric<CdmResponseType, CdmSecurityLevel> cdm_engine_unprovision_;
|
||||
CounterMetric<CdmResponseType, CdmSecurityLevel> cdm_engine_unprovision_;
|
||||
|
||||
private:
|
||||
Lock session_metrics_lock_;
|
||||
std::vector<metrics::SessionMetrics*> session_metrics_list_;
|
||||
CryptoMetrics crypto_metrics_;
|
||||
std::string app_package_name_;
|
||||
|
||||
void SerializeEngineMetrics(drm_metrics::MetricsGroup* out);
|
||||
};
|
||||
|
||||
} // namespace metrics
|
||||
} // namespace wvcdm
|
||||
#endif
|
||||
|
||||
#endif // WVCDM_METRICS_METRICS_GROUP_H_
|
||||
|
||||
@@ -33,4 +33,7 @@ message MetricsGroup {
|
||||
|
||||
// Allow multiple sub groups of metrics.
|
||||
repeated MetricsGroup metric_sub_group = 2;
|
||||
|
||||
// Name of the application package associated with the metrics.
|
||||
optional string app_package_name = 3;
|
||||
}
|
||||
|
||||
@@ -63,11 +63,13 @@ namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
CryptoMetrics::CryptoMetrics() :
|
||||
crypto_session_security_level_(
|
||||
"/drm/widevine/crypto_session/security_level"),
|
||||
crypto_session_delete_all_usage_reports_(
|
||||
"/drm/widevine/crypto_session/delete_all_usage_reports/time",
|
||||
"/drm/widevine/crypto_session/delete_all_usage_reports",
|
||||
"error"),
|
||||
crypto_session_delete_multiple_usage_information_(
|
||||
"/drm/widevine/crypto_session/delete_multiple_usage_information/time",
|
||||
"/drm/widevine/crypto_session/delete_multiple_usage_information",
|
||||
"error"),
|
||||
crypto_session_generic_decrypt_(
|
||||
"/drm/widevine/crypto_session/generic_decrypt/time",
|
||||
@@ -90,20 +92,13 @@ CryptoMetrics::CryptoMetrics() :
|
||||
"length",
|
||||
"signing_algorithm"),
|
||||
crypto_session_get_device_unique_id_(
|
||||
"/drm/widevine/crypto_session/get_device_unique_id/time",
|
||||
"/drm/widevine/crypto_session/get_device_unique_id",
|
||||
"success"),
|
||||
crypto_session_get_security_level_(
|
||||
"/drm/widevine/crypto_session/get_security_level/time",
|
||||
"security_level"),
|
||||
crypto_session_get_system_id_(
|
||||
"/drm/widevine/crypto_session/get_system_id/time",
|
||||
"success",
|
||||
"system_id"),
|
||||
crypto_session_get_token_(
|
||||
"/drm/widevine/crypto_session/get_token/time",
|
||||
"/drm/widevine/crypto_session/get_token",
|
||||
"success"),
|
||||
crypto_session_life_span_(
|
||||
"/drm/widevine/crypto_session/life_span/time"),
|
||||
"/drm/widevine/crypto_session/life_span"),
|
||||
crypto_session_load_certificate_private_key_(
|
||||
"/drm/widevine/crypto_session/load_certificate_private_key/time",
|
||||
"success"),
|
||||
@@ -111,48 +106,48 @@ CryptoMetrics::CryptoMetrics() :
|
||||
"/drm/widevine/crypto_session/open/time",
|
||||
"error",
|
||||
"requested_security_level"),
|
||||
crypto_session_system_id_(
|
||||
"/drm/widevine/crypto_session/system_id"),
|
||||
crypto_session_update_usage_information_(
|
||||
"/drm/widevine/crypto_session/update_usage_information/time",
|
||||
"error"),
|
||||
crypto_session_usage_information_support_(
|
||||
"/drm/widevine/crypto_session/usage_information_support/time",
|
||||
"success"),
|
||||
"/drm/widevine/crypto_session/usage_information_support"),
|
||||
oemcrypto_api_version_(
|
||||
"/drm/widevine/oemcrypto/api_version/time",
|
||||
"version",
|
||||
"requested_security_level"),
|
||||
"/drm/widevine/oemcrypto/api_version"),
|
||||
oemcrypto_close_session_(
|
||||
"/drm/widevine/oemcrypto/close_session/time",
|
||||
"/drm/widevine/oemcrypto/close_session",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_copy_buffer_(
|
||||
"/drm/widevine/oemcrypto/copy_buffer/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level",
|
||||
"length"),
|
||||
oemcrypto_current_hdcp_capability_(
|
||||
"/drm/widevine/oemcrypto/current_hdcp_capability"),
|
||||
oemcrypto_deactivate_usage_entry_(
|
||||
"/drm/widevine/oemcrypto/deactivate_usage_entry/time",
|
||||
"/drm/widevine/oemcrypto/deactivate_usage_entry",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_decrypt_cenc_(
|
||||
"/drm/widevine/oemcrypto/decrypt_cenc/time",
|
||||
"oemcrypto_error",
|
||||
"length"),
|
||||
oemcrypto_delete_usage_entry_(
|
||||
"/drm/widevine/oemcrypto/delete_usage_entry/time",
|
||||
"/drm/widevine/oemcrypto/delete_usage_entry",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_delete_usage_table_(
|
||||
"/drm/widevine/oemcrypto/delete_usage_table/time",
|
||||
"/drm/widevine/oemcrypto/delete_usage_table",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_derive_keys_from_session_key_(
|
||||
"/drm/widevine/oemcrypto/derive_keys_from_session_key/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_force_delete_usage_entry_(
|
||||
"/drm/widevine/oemcrypto/force_delete_usage_entry/time",
|
||||
"/drm/widevine/oemcrypto/force_delete_usage_entry",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_generate_derived_keys_(
|
||||
"/drm/widevine/oemcrypto/generate_derived_keys/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_generate_nonce_(
|
||||
"/drm/widevine/oemcrypto/generate_nonce/time",
|
||||
"/drm/widevine/oemcrypto/generate_nonce",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_generate_rsa_signature_(
|
||||
"/drm/widevine/oemcrypto/generate_rsa_signature/time",
|
||||
@@ -179,73 +174,47 @@ CryptoMetrics::CryptoMetrics() :
|
||||
"oemcrypto_error",
|
||||
"length"),
|
||||
oemcrypto_get_device_id_(
|
||||
"/drm/widevine/oemcrypto/get_device_id/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level"),
|
||||
oemcrypto_get_hdcp_capability_(
|
||||
"/drm/widevine/oemcrypto/get_hdcp_capability/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level"),
|
||||
"/drm/widevine/oemcrypto/get_device_id",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_get_key_data_(
|
||||
"/drm/widevine/oemcrypto/get_key_data/time",
|
||||
"oemcrypto_error",
|
||||
"length",
|
||||
"requested_security_level"),
|
||||
oemcrypto_get_max_number_of_sessions_(
|
||||
"/drm/widevine/oemcrypto/get_max_number_of_sessions/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level"),
|
||||
oemcrypto_get_number_of_open_sessions_(
|
||||
"/drm/widevine/oemcrypto/get_number_of_open_sessions/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level"),
|
||||
oemcrypto_get_oem_public_certificate_(
|
||||
"/drm/widevine/oemcrypto/get_oem_public_certificate/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_get_provisioning_method_(
|
||||
"/drm/widevine/oemcrypto/get_provisioning_method/time",
|
||||
"method",
|
||||
"requested_security_level"),
|
||||
oemcrypto_get_random_(
|
||||
"/drm/widevine/oemcrypto/get_random/time",
|
||||
"oemcrypto_error",
|
||||
"length"),
|
||||
oemcrypto_get_oem_public_certificate_(
|
||||
"/drm/widevine/oemcrypto/get_oem_public_certificate",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_get_random_(
|
||||
"/drm/widevine/oemcrypto/get_random",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_initialize_(
|
||||
"/drm/widevine/oemcrypto/initialize/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_install_keybox_(
|
||||
"/drm/widevine/oemcrypto/install_keybox/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level"),
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_is_anti_rollback_hw_present_(
|
||||
"/drm/widevine/oemcrypto/is_anti_rollback_hw_present/time",
|
||||
"success",
|
||||
"requested_security_level"),
|
||||
"/drm/widevine/oemcrypto/is_anti_rollback_hw_present"),
|
||||
oemcrypto_is_keybox_valid_(
|
||||
"/drm/widevine/oemcrypto/is_keybox_valid/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level"),
|
||||
"/drm/widevine/oemcrypto/is_keybox_valid"),
|
||||
oemcrypto_load_device_rsa_key_(
|
||||
"/drm/widevine/oemcrypto/load_device_rsa_key/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_load_keys_(
|
||||
"/drm/widevine/oemcrypto/load_keys/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_load_test_keybox_(
|
||||
"/drm/widevine/oemcrypto/load_test_keybox/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_load_test_rsa_key_(
|
||||
"/drm/widevine/oemcrypto/load_test_rsa_key/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_open_session_(
|
||||
"/drm/widevine/oemcrypto/open_session/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level"),
|
||||
oemcrypto_max_hdcp_capability_(
|
||||
"/drm/widevine/oemcrypto/max_hdcp_capability"),
|
||||
oemcrypto_max_number_of_sessions_(
|
||||
"/drm/widevine/oemcrypto/max_number_of_sessions"),
|
||||
oemcrypto_number_of_open_sessions_(
|
||||
"/drm/widevine/oemcrypto/number_of_open_sessions"),
|
||||
oemcrypto_provisioning_method_(
|
||||
"/drm/widevine/oemcrypto/provisioning_method"),
|
||||
oemcrypto_refresh_keys_(
|
||||
"/drm/widevine/oemcrypto/refresh_keys/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_report_usage_(
|
||||
"/drm/widevine/oemcrypto/report_usage/time",
|
||||
"/drm/widevine/oemcrypto/report_usage",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_rewrap_device_rsa_key_(
|
||||
"/drm/widevine/oemcrypto/rewrap_device_rsa_key/time",
|
||||
@@ -253,38 +222,25 @@ CryptoMetrics::CryptoMetrics() :
|
||||
oemcrypto_rewrap_device_rsa_key_30_(
|
||||
"/drm/widevine/oemcrypto/rewrap_device_rsa_key_30/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_security_level_(
|
||||
"/drm/widevine/oemcrypto/security_level/time",
|
||||
"security_level",
|
||||
"requested_security_level"),
|
||||
oemcrypto_security_patch_level_(
|
||||
"/drm/widevine/oemcrypto/security_patch_level/time",
|
||||
"patch",
|
||||
"requested_security_level"),
|
||||
"/drm/widevine/oemcrypto/security_patch_level"),
|
||||
oemcrypto_select_key_(
|
||||
"/drm/widevine/oemcrypto/select_key/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_supports_usage_table_(
|
||||
"/drm/widevine/oemcrypto/supports_usage_table/time",
|
||||
"oemcrypto_error",
|
||||
"requested_security_level"),
|
||||
"/drm/widevine/oemcrypto/supports_usage_table"),
|
||||
oemcrypto_update_usage_table_(
|
||||
"/drm/widevine/oemcrypto/update_usage_table/time",
|
||||
"/drm/widevine/oemcrypto/update_usage_table",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_wrap_keybox_(
|
||||
"/drm/widevine/oemcrypto/wrap_keybox/time",
|
||||
"oemcrypto_error"),
|
||||
oemcrypto_initialization_mode_(
|
||||
"/drm/widevine/oemcrypto/initialization_mode",
|
||||
"initialization_mode"),
|
||||
oemcrypto_l1_api_version_(
|
||||
"/drm/widevine/oemcrypto/l1_api_version",
|
||||
"version",
|
||||
"min_version") {}
|
||||
"oemcrypto_error") {
|
||||
}
|
||||
|
||||
void CryptoMetrics::Serialize(MetricsGroup* metrics) {
|
||||
ProtoMetricSerializer serializer(metrics);
|
||||
/* CRYPTO SESSION */
|
||||
crypto_session_security_level_.Serialize(&serializer);
|
||||
crypto_session_delete_all_usage_reports_.Serialize(&serializer);
|
||||
crypto_session_delete_multiple_usage_information_.Serialize(&serializer);
|
||||
crypto_session_generic_decrypt_.Serialize(&serializer);
|
||||
@@ -292,12 +248,11 @@ void CryptoMetrics::Serialize(MetricsGroup* metrics) {
|
||||
crypto_session_generic_sign_.Serialize(&serializer);
|
||||
crypto_session_generic_verify_.Serialize(&serializer);
|
||||
crypto_session_get_device_unique_id_.Serialize(&serializer);
|
||||
crypto_session_get_security_level_.Serialize(&serializer);
|
||||
crypto_session_get_system_id_.Serialize(&serializer);
|
||||
crypto_session_get_token_.Serialize(&serializer);
|
||||
crypto_session_life_span_.Serialize(&serializer);
|
||||
crypto_session_load_certificate_private_key_.Serialize(&serializer);
|
||||
crypto_session_open_.Serialize(&serializer);
|
||||
crypto_session_system_id_.Serialize(&serializer);
|
||||
crypto_session_update_usage_information_.Serialize(&serializer);
|
||||
crypto_session_usage_information_support_.Serialize(&serializer);
|
||||
|
||||
@@ -305,6 +260,7 @@ void CryptoMetrics::Serialize(MetricsGroup* metrics) {
|
||||
oemcrypto_api_version_.Serialize(&serializer);
|
||||
oemcrypto_close_session_.Serialize(&serializer);
|
||||
oemcrypto_copy_buffer_.Serialize(&serializer);
|
||||
oemcrypto_current_hdcp_capability_.Serialize(&serializer);
|
||||
oemcrypto_deactivate_usage_entry_.Serialize(&serializer);
|
||||
oemcrypto_decrypt_cenc_.Serialize(&serializer);
|
||||
oemcrypto_delete_usage_entry_.Serialize(&serializer);
|
||||
@@ -320,12 +276,8 @@ void CryptoMetrics::Serialize(MetricsGroup* metrics) {
|
||||
oemcrypto_generic_sign_.Serialize(&serializer);
|
||||
oemcrypto_generic_verify_.Serialize(&serializer);
|
||||
oemcrypto_get_device_id_.Serialize(&serializer);
|
||||
oemcrypto_get_hdcp_capability_.Serialize(&serializer);
|
||||
oemcrypto_get_key_data_.Serialize(&serializer);
|
||||
oemcrypto_get_max_number_of_sessions_.Serialize(&serializer);
|
||||
oemcrypto_get_number_of_open_sessions_.Serialize(&serializer);
|
||||
oemcrypto_get_oem_public_certificate_.Serialize(&serializer);
|
||||
oemcrypto_get_provisioning_method_.Serialize(&serializer);
|
||||
oemcrypto_get_random_.Serialize(&serializer);
|
||||
oemcrypto_initialize_.Serialize(&serializer);
|
||||
oemcrypto_install_keybox_.Serialize(&serializer);
|
||||
@@ -333,36 +285,32 @@ void CryptoMetrics::Serialize(MetricsGroup* metrics) {
|
||||
oemcrypto_is_keybox_valid_.Serialize(&serializer);
|
||||
oemcrypto_load_device_rsa_key_.Serialize(&serializer);
|
||||
oemcrypto_load_keys_.Serialize(&serializer);
|
||||
oemcrypto_load_test_keybox_.Serialize(&serializer);
|
||||
oemcrypto_load_test_rsa_key_.Serialize(&serializer);
|
||||
oemcrypto_open_session_.Serialize(&serializer);
|
||||
oemcrypto_max_hdcp_capability_.Serialize(&serializer);
|
||||
oemcrypto_max_number_of_sessions_.Serialize(&serializer);
|
||||
oemcrypto_number_of_open_sessions_.Serialize(&serializer);
|
||||
oemcrypto_provisioning_method_.Serialize(&serializer);
|
||||
oemcrypto_refresh_keys_.Serialize(&serializer);
|
||||
oemcrypto_report_usage_.Serialize(&serializer);
|
||||
oemcrypto_rewrap_device_rsa_key_.Serialize(&serializer);
|
||||
oemcrypto_rewrap_device_rsa_key_30_.Serialize(&serializer);
|
||||
oemcrypto_security_level_.Serialize(&serializer);
|
||||
oemcrypto_security_patch_level_.Serialize(&serializer);
|
||||
oemcrypto_select_key_.Serialize(&serializer);
|
||||
oemcrypto_supports_usage_table_.Serialize(&serializer);
|
||||
oemcrypto_update_usage_table_.Serialize(&serializer);
|
||||
oemcrypto_wrap_keybox_.Serialize(&serializer);
|
||||
|
||||
/* Internal OEMCrypto Metrics */
|
||||
oemcrypto_initialization_mode_.Serialize(&serializer);
|
||||
oemcrypto_l1_api_version_.Serialize(&serializer);
|
||||
}
|
||||
|
||||
SessionMetrics::SessionMetrics() :
|
||||
cdm_session_life_span_(
|
||||
"/drm/widevine/cdm_session/life_span/time"),
|
||||
"/drm/widevine/cdm_session/life_span"),
|
||||
cdm_session_renew_key_(
|
||||
"/drm/widevine/cdm_session/renew_key/time",
|
||||
"error"),
|
||||
cdm_session_restore_offline_session_(
|
||||
"/drm/widevine/cdm_session/restore_offline_session/time",
|
||||
"/drm/widevine/cdm_session/restore_offline_session",
|
||||
"error"),
|
||||
cdm_session_restore_usage_session_(
|
||||
"/drm/widevine/cdm_session/restore_usage_session/time",
|
||||
"/drm/widevine/cdm_session/restore_usage_session",
|
||||
"error"),
|
||||
completed_(false) {
|
||||
}
|
||||
@@ -382,18 +330,76 @@ void SessionMetrics::SerializeSessionMetrics(MetricsGroup* metric_group) {
|
||||
cdm_session_restore_usage_session_.Serialize(&serializer);
|
||||
}
|
||||
|
||||
OemCryptoDynamicAdapterMetrics::OemCryptoDynamicAdapterMetrics() :
|
||||
oemcrypto_initialization_mode_(
|
||||
"/drm/widevine/oemcrypto/initialization_mode"),
|
||||
oemcrypto_l1_api_version_(
|
||||
"/drm/widevine/oemcrypto/l1_api_version"),
|
||||
oemcrypto_l1_min_api_version_(
|
||||
"/drm/widevine/oemcrypto/l1_min_api_version") {
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::SetInitializationMode(
|
||||
OEMCryptoInitializationMode mode) {
|
||||
AutoLock lock(adapter_lock_);
|
||||
oemcrypto_initialization_mode_.Record(mode);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::SetL1ApiVersion(uint32_t version) {
|
||||
AutoLock lock(adapter_lock_);
|
||||
oemcrypto_l1_api_version_.Record(version);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::SetL1MinApiVersion(uint32_t version) {
|
||||
AutoLock lock(adapter_lock_);
|
||||
oemcrypto_l1_min_api_version_.Record(version);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::Serialize(
|
||||
drm_metrics::MetricsGroup* metric_group) {
|
||||
AutoLock lock(adapter_lock_);
|
||||
ProtoMetricSerializer serializer(metric_group);
|
||||
|
||||
oemcrypto_initialization_mode_.Serialize(&serializer);
|
||||
oemcrypto_l1_api_version_.Serialize(&serializer);
|
||||
oemcrypto_l1_min_api_version_.Serialize(&serializer);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::Clear() {
|
||||
AutoLock lock(adapter_lock_);
|
||||
|
||||
oemcrypto_initialization_mode_.Clear();
|
||||
oemcrypto_l1_api_version_.Clear();
|
||||
oemcrypto_l1_min_api_version_.Clear();
|
||||
}
|
||||
|
||||
// This method returns a reference. This means that the destructor is never
|
||||
// executed for the returned object.
|
||||
OemCryptoDynamicAdapterMetrics& GetDynamicAdapterMetricsInstance() {
|
||||
// This is safe in C++ 11 since the initialization is guaranteed to run
|
||||
// only once regardless of multi-threaded access.
|
||||
static OemCryptoDynamicAdapterMetrics* adapter_metrics =
|
||||
new OemCryptoDynamicAdapterMetrics();
|
||||
return *adapter_metrics;
|
||||
}
|
||||
|
||||
EngineMetrics::EngineMetrics() :
|
||||
cdm_engine_add_key_(
|
||||
"/drm/widevine/cdm_engine/add_key/time",
|
||||
"error"),
|
||||
cdm_engine_cdm_version_(
|
||||
"/drm/widevine/cdm_engine/version"),
|
||||
cdm_engine_close_session_(
|
||||
"/drm/widevine/cdm_engine/close_session/time",
|
||||
"/drm/widevine/cdm_engine/close_session",
|
||||
"error"),
|
||||
cdm_engine_creation_time_millis_(
|
||||
"/drm/widevine/cdm_engine/creation_time_millis"),
|
||||
cdm_engine_decrypt_(
|
||||
"/drm/widevine/cdm_engine/decrypt/time",
|
||||
"error"),
|
||||
"error",
|
||||
"length"),
|
||||
cdm_engine_find_session_for_key_(
|
||||
"/drm/widevine/cdm_engine/find_session_for_key/time",
|
||||
"/drm/widevine/cdm_engine/find_session_for_key",
|
||||
"success"),
|
||||
cdm_engine_generate_key_request_(
|
||||
"/drm/widevine/cdm_engine/generate_key_request/time",
|
||||
@@ -408,36 +414,37 @@ EngineMetrics::EngineMetrics() :
|
||||
"/drm/widevine/cdm_engine/handle_provisioning_response/time",
|
||||
"error"),
|
||||
cdm_engine_life_span_(
|
||||
"/drm/widevine/cdm_engine/life_span/time"),
|
||||
"/drm/widevine/cdm_engine/life_span"),
|
||||
cdm_engine_open_key_set_session_(
|
||||
"/drm/widevine/cdm_engine/open_key_set_session/time",
|
||||
"/drm/widevine/cdm_engine/open_key_set_session",
|
||||
"error"),
|
||||
cdm_engine_open_session_(
|
||||
"/drm/widevine/cdm_engine/open_session/time",
|
||||
"/drm/widevine/cdm_engine/open_session",
|
||||
"error"),
|
||||
cdm_engine_query_key_status_(
|
||||
"/drm/widevine/cdm_engine/query_key_status/time",
|
||||
"error"),
|
||||
cdm_engine_release_all_usage_info_(
|
||||
"/drm/widevine/cdm_engine/release_all_usage_info/time",
|
||||
"/drm/widevine/cdm_engine/release_all_usage_info",
|
||||
"error"),
|
||||
cdm_engine_release_usage_info_(
|
||||
"/drm/widevine/cdm_engine/release_usage_info/time",
|
||||
"/drm/widevine/cdm_engine/release_usage_info",
|
||||
"error"),
|
||||
cdm_engine_remove_keys_(
|
||||
"/drm/widevine/cdm_engine/remove_keys/time",
|
||||
"/drm/widevine/cdm_engine/remove_keys",
|
||||
"error"),
|
||||
cdm_engine_restore_key_(
|
||||
"/drm/widevine/cdm_engine/restore_key/time",
|
||||
"error"),
|
||||
cdm_engine_unprovision_(
|
||||
"/drm/widevine/cdm_engine/unprovision/time",
|
||||
"/drm/widevine/cdm_engine/unprovision",
|
||||
"error",
|
||||
"security_level") {
|
||||
"security_level"),
|
||||
app_package_name_("") {
|
||||
}
|
||||
|
||||
EngineMetrics::~EngineMetrics() {
|
||||
AutoLock kock(session_metrics_lock_);
|
||||
AutoLock lock(session_metrics_lock_);
|
||||
std::vector<SessionMetrics*>::iterator i;
|
||||
if (!session_metrics_list_.empty()) {
|
||||
LOGV("EngineMetrics::~EngineMetrics. Session count: %d",
|
||||
@@ -471,13 +478,24 @@ void EngineMetrics::Serialize(drm_metrics::MetricsGroup* metric_group,
|
||||
bool clear_serialized_sessions) {
|
||||
AutoLock lock(session_metrics_lock_);
|
||||
|
||||
// Serialize the most recent metrics from the OemCyrpto dynamic adapter.
|
||||
OemCryptoDynamicAdapterMetrics& adapter_metrics =
|
||||
GetDynamicAdapterMetricsInstance();
|
||||
adapter_metrics.Serialize(metric_group);
|
||||
if (!app_package_name_.empty()) {
|
||||
metric_group->set_app_package_name(app_package_name_);
|
||||
}
|
||||
SerializeEngineMetrics(metric_group);
|
||||
std::vector<SessionMetrics*>::iterator i;
|
||||
for (i = session_metrics_list_.begin(); i != session_metrics_list_.end();
|
||||
/* no increment */) {
|
||||
bool serialized = false;
|
||||
if (!completed_only || (*i)->IsCompleted()) {
|
||||
(*i)->Serialize(metric_group->add_metric_sub_group());
|
||||
MetricsGroup* metric_sub_group = metric_group->add_metric_sub_group();
|
||||
if (!app_package_name_.empty()) {
|
||||
metric_sub_group->set_app_package_name(app_package_name_);
|
||||
}
|
||||
(*i)->Serialize(metric_sub_group);
|
||||
serialized = true;
|
||||
}
|
||||
|
||||
@@ -490,10 +508,16 @@ void EngineMetrics::Serialize(drm_metrics::MetricsGroup* metric_group,
|
||||
}
|
||||
}
|
||||
|
||||
void EngineMetrics::SetAppPackageName(const std::string& app_package_name) {
|
||||
app_package_name_ = app_package_name;
|
||||
}
|
||||
|
||||
void EngineMetrics::SerializeEngineMetrics(MetricsGroup* metric_group) {
|
||||
ProtoMetricSerializer serializer(metric_group);
|
||||
cdm_engine_add_key_.Serialize(&serializer);
|
||||
cdm_engine_cdm_version_.Serialize(&serializer);
|
||||
cdm_engine_close_session_.Serialize(&serializer);
|
||||
cdm_engine_creation_time_millis_.Serialize(&serializer);
|
||||
cdm_engine_decrypt_.Serialize(&serializer);
|
||||
cdm_engine_find_session_for_key_.Serialize(&serializer);
|
||||
cdm_engine_generate_key_request_.Serialize(&serializer);
|
||||
|
||||
Reference in New Issue
Block a user