Merge "Use real system id in GetProvisioningTokenValidMetrics"
This commit is contained in:
committed by
Android (Google) Code Review
commit
4e5599d4ff
@@ -1,5 +1,6 @@
|
|||||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -290,6 +291,17 @@ class CryptoSessionMetricsTest : public testing::Test {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t FindKeyboxSystemID() {
|
||||||
|
OEMCryptoResult sts;
|
||||||
|
uint8_t key_data[256];
|
||||||
|
size_t key_data_len = sizeof(key_data);
|
||||||
|
sts = OEMCrypto_GetKeyData(key_data, &key_data_len, kLevelDefault);
|
||||||
|
if (sts != OEMCrypto_SUCCESS) return 0;
|
||||||
|
uint32_t* data = reinterpret_cast<uint32_t*>(key_data);
|
||||||
|
uint32_t system_id = htonl(data[1]);
|
||||||
|
return system_id;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::pair<std::string, drm_metrics::MetricsGroup::Metric>
|
static std::pair<std::string, drm_metrics::MetricsGroup::Metric>
|
||||||
MakeMetricPair(const drm_metrics::MetricsGroup::Metric& metric) {
|
MakeMetricPair(const drm_metrics::MetricsGroup::Metric& metric) {
|
||||||
@@ -337,9 +349,10 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
|||||||
CdmClientTokenType token_type = session.GetPreProvisionTokenType();
|
CdmClientTokenType token_type = session.GetPreProvisionTokenType();
|
||||||
|
|
||||||
if (token_type == kClientTokenKeybox) {
|
if (token_type == kClientTokenKeybox) {
|
||||||
|
uint32_t system_id = FindKeyboxSystemID();
|
||||||
EXPECT_TRUE(FindMetric(
|
EXPECT_TRUE(FindMetric(
|
||||||
metric_map, "/drm/widevine/crypto_session/system_id", &metric));
|
metric_map, "/drm/widevine/crypto_session/system_id", &metric));
|
||||||
EXPECT_EQ(metric.value().int_value(), 4121);
|
EXPECT_EQ(metric.value().int_value(), system_id);
|
||||||
|
|
||||||
EXPECT_TRUE(FindMetric(
|
EXPECT_TRUE(FindMetric(
|
||||||
metric_map,
|
metric_map,
|
||||||
@@ -363,7 +376,11 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
|||||||
} else if (token_type == kClientTokenOemCert) {
|
} else if (token_type == kClientTokenOemCert) {
|
||||||
EXPECT_TRUE(FindMetric(
|
EXPECT_TRUE(FindMetric(
|
||||||
metric_map, "/drm/widevine/crypto_session/system_id", &metric));
|
metric_map, "/drm/widevine/crypto_session/system_id", &metric));
|
||||||
EXPECT_EQ(metric.value().int_value(), 7346);
|
// Recent devices all have a system id between 1k and 6 or 7k. Errors we
|
||||||
|
// are trying to catch are 0, byte swapped 32 bit numbers, or garbage. These
|
||||||
|
// errors will most likely be outside the range of 1000 to 2^16.
|
||||||
|
EXPECT_LE(1000, metric.value().int_value());
|
||||||
|
EXPECT_GT(0x10000, metric.value().int_value());
|
||||||
|
|
||||||
EXPECT_TRUE(FindMetric(
|
EXPECT_TRUE(FindMetric(
|
||||||
metric_map,
|
metric_map,
|
||||||
@@ -417,7 +434,8 @@ TEST_F(CryptoSessionMetricsTest, GetProvisioningTokenValidMetrics) {
|
|||||||
EXPECT_TRUE(FindMetric(
|
EXPECT_TRUE(FindMetric(
|
||||||
metric_map, "/drm/widevine/crypto_session/system_id",
|
metric_map, "/drm/widevine/crypto_session/system_id",
|
||||||
&metric));
|
&metric));
|
||||||
EXPECT_EQ(metric.value().int_value(), 4121);
|
uint32_t system_id = FindKeyboxSystemID();
|
||||||
|
EXPECT_EQ(metric.value().int_value(), system_id);
|
||||||
EXPECT_TRUE(FindMetric(
|
EXPECT_TRUE(FindMetric(
|
||||||
metric_map,
|
metric_map,
|
||||||
"/drm/widevine/oemcrypto/get_key_data/time/count"
|
"/drm/widevine/oemcrypto/get_key_data/time/count"
|
||||||
@@ -433,7 +451,11 @@ TEST_F(CryptoSessionMetricsTest, GetProvisioningTokenValidMetrics) {
|
|||||||
EXPECT_TRUE(FindMetric(
|
EXPECT_TRUE(FindMetric(
|
||||||
metric_map, "/drm/widevine/crypto_session/system_id",
|
metric_map, "/drm/widevine/crypto_session/system_id",
|
||||||
&metric));
|
&metric));
|
||||||
EXPECT_EQ(metric.value().int_value(), 7346);
|
// Recent devices all have a system id between 1k and 6 or 7k. Errors we
|
||||||
|
// are trying to catch are 0, byte swapped 32 bit numbers, or garbage. These
|
||||||
|
// errors will most likely be outside the range of 1000 to 2^16.
|
||||||
|
EXPECT_LE(1000, metric.value().int_value());
|
||||||
|
EXPECT_GT(0x10000, metric.value().int_value());
|
||||||
EXPECT_TRUE(FindMetric(
|
EXPECT_TRUE(FindMetric(
|
||||||
metric_map,
|
metric_map,
|
||||||
"/drm/widevine/oemcrypto/get_oem_public_certificate/count"
|
"/drm/widevine/oemcrypto/get_oem_public_certificate/count"
|
||||||
|
|||||||
Reference in New Issue
Block a user