Ran clang-format on android/cdm/ files.
[ Merge of http://go/wvgerrit/87123 ] Certain android files have yet to be formated since we introduced clang-formatting. Test: built for android Bug: 134365840 Change-Id: Ia316b039e7469f7cf803464ee95a919fe7966450
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
namespace wvcdm {
|
||||
|
||||
class AmiAdapter {
|
||||
|
||||
public:
|
||||
AmiAdapter();
|
||||
AmiAdapter(int64_t parent);
|
||||
@@ -26,7 +25,6 @@ class AmiAdapter {
|
||||
|
||||
private:
|
||||
android::MediaAnalyticsItem analytics_item_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -43,17 +43,16 @@ struct CdmIdentifier {
|
||||
// comparison in lieu of the == operator when checking to see if the
|
||||
// identifier would cause the default provisioned certificate to be used.
|
||||
bool IsEquivalentToDefault() {
|
||||
return spoid == EMPTY_SPOID
|
||||
&& origin == EMPTY_ORIGIN
|
||||
&& app_package_name == EMPTY_APP_PACKAGE_NAME;
|
||||
return spoid == EMPTY_SPOID && origin == EMPTY_ORIGIN &&
|
||||
app_package_name == EMPTY_APP_PACKAGE_NAME;
|
||||
}
|
||||
};
|
||||
|
||||
// Provide comparison operators
|
||||
inline bool operator==(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
|
||||
return lhs.spoid == rhs.spoid && lhs.origin == rhs.origin
|
||||
&& lhs.app_package_name == rhs.app_package_name
|
||||
&& lhs.unique_id == rhs.unique_id;
|
||||
return lhs.spoid == rhs.spoid && lhs.origin == rhs.origin &&
|
||||
lhs.app_package_name == rhs.app_package_name &&
|
||||
lhs.unique_id == rhs.unique_id;
|
||||
}
|
||||
|
||||
inline bool operator!=(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
|
||||
@@ -61,13 +60,13 @@ inline bool operator!=(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
|
||||
}
|
||||
|
||||
inline bool operator<(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
|
||||
return (lhs.spoid < rhs.spoid)
|
||||
|| ((lhs.spoid == rhs.spoid)
|
||||
&& (lhs.origin < rhs.origin
|
||||
|| (lhs.origin == rhs.origin
|
||||
&& (lhs.app_package_name < rhs.app_package_name
|
||||
|| (lhs.app_package_name == rhs.app_package_name
|
||||
&& lhs.unique_id < rhs.unique_id)))));
|
||||
return (lhs.spoid < rhs.spoid) ||
|
||||
((lhs.spoid == rhs.spoid) &&
|
||||
(lhs.origin < rhs.origin ||
|
||||
(lhs.origin == rhs.origin &&
|
||||
(lhs.app_package_name < rhs.app_package_name ||
|
||||
(lhs.app_package_name == rhs.app_package_name &&
|
||||
lhs.unique_id < rhs.unique_id)))));
|
||||
}
|
||||
|
||||
inline bool operator>(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
|
||||
@@ -83,12 +82,8 @@ inline bool operator>=(const CdmIdentifier& lhs, const CdmIdentifier& rhs) {
|
||||
}
|
||||
|
||||
// Provide default
|
||||
static const CdmIdentifier kDefaultCdmIdentifier = {
|
||||
EMPTY_SPOID,
|
||||
EMPTY_ORIGIN,
|
||||
EMPTY_APP_PACKAGE_NAME,
|
||||
0
|
||||
};
|
||||
static const CdmIdentifier kDefaultCdmIdentifier = {EMPTY_SPOID, EMPTY_ORIGIN,
|
||||
EMPTY_APP_PACKAGE_NAME, 0};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#ifndef CDM_BASE_PROPERTIES_CONFIGURATION_H_
|
||||
#define CDM_BASE_PROPERTIES_CONFIGURATION_H_
|
||||
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "properties.h"
|
||||
#include "wv_cdm_constants.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
@@ -39,6 +39,6 @@ const bool kDeviceFilesIsARealFileSystem = true;
|
||||
// will be treated as a release request. If false, a restoration will fail.
|
||||
const bool kAllowRestoreOfflineLicenseWithRelease = false;
|
||||
|
||||
} // namespace wvcdm
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif // CDM_BASE_WV_PROPERTIES_CONFIGURATION_H_
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace wvcdm {
|
||||
|
||||
class TimerHandler {
|
||||
public:
|
||||
TimerHandler() {};
|
||||
virtual ~TimerHandler() {};
|
||||
TimerHandler() {}
|
||||
virtual ~TimerHandler() {}
|
||||
|
||||
virtual void OnTimerEvent() = 0;
|
||||
};
|
||||
@@ -42,7 +42,7 @@ class Timer {
|
||||
Timer();
|
||||
~Timer();
|
||||
|
||||
bool Start(TimerHandler *handler, uint32_t time_in_secs);
|
||||
bool Start(TimerHandler* handler, uint32_t time_in_secs);
|
||||
void Stop();
|
||||
bool IsRunning();
|
||||
|
||||
|
||||
@@ -108,8 +108,7 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
||||
virtual CdmResponseType RemoveAllUsageInfo(const std::string& app_id,
|
||||
const CdmIdentifier& identifier);
|
||||
virtual CdmResponseType RemoveUsageInfo(
|
||||
const std::string& app_id,
|
||||
const CdmIdentifier& identifier,
|
||||
const std::string& app_id, const CdmIdentifier& identifier,
|
||||
const CdmSecureStopId& secure_stop_id);
|
||||
virtual CdmResponseType ReleaseUsageInfo(
|
||||
const CdmUsageInfoReleaseMessage& message,
|
||||
@@ -151,22 +150,18 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
||||
// Return the list of key_set_ids stored on the current (origin-specific)
|
||||
// file system.
|
||||
virtual CdmResponseType ListStoredLicenses(
|
||||
CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier,
|
||||
CdmSecurityLevel security_level, const CdmIdentifier& identifier,
|
||||
std::vector<CdmKeySetId>* key_set_ids);
|
||||
|
||||
// Retrieve offline license state using key_set_id.
|
||||
virtual CdmResponseType GetOfflineLicenseState(
|
||||
const CdmKeySetId& key_set_id,
|
||||
CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier,
|
||||
CdmOfflineLicenseState* licenseState);
|
||||
const CdmKeySetId& key_set_id, CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier, CdmOfflineLicenseState* licenseState);
|
||||
|
||||
// Remove offline license using key_set_id.
|
||||
virtual CdmResponseType RemoveOfflineLicense(
|
||||
const CdmKeySetId& key_set_id,
|
||||
CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier);
|
||||
virtual CdmResponseType RemoveOfflineLicense(const CdmKeySetId& key_set_id,
|
||||
CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier);
|
||||
|
||||
private:
|
||||
struct CdmInfo {
|
||||
|
||||
@@ -8,59 +8,40 @@
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
AmiAdapter::AmiAdapter() :
|
||||
analytics_item_("widevine") {
|
||||
AmiAdapter::AmiAdapter() : analytics_item_("widevine") {
|
||||
analytics_item_.generateSessionID();
|
||||
}
|
||||
|
||||
AmiAdapter::AmiAdapter(int64_t parent) :
|
||||
analytics_item_("widevine") {
|
||||
AmiAdapter::AmiAdapter(int64_t parent) : analytics_item_("widevine") {
|
||||
analytics_item_.generateSessionID();
|
||||
analytics_item_.setInt64("/drm/widevine/parent/external", parent);
|
||||
}
|
||||
|
||||
AmiAdapter::~AmiAdapter() {
|
||||
analytics_item_.selfrecord();
|
||||
}
|
||||
AmiAdapter::~AmiAdapter() { analytics_item_.selfrecord(); }
|
||||
|
||||
void AmiAdapter::UpdateString(const std::string& metric_id,
|
||||
const std::string& value) {
|
||||
analytics_item_.setCString(metric_id.c_str(), value.c_str());
|
||||
LOGV(
|
||||
"AmiAdapter (%lld) %s : %s",
|
||||
analytics_item_.getSessionID(),
|
||||
metric_id.c_str(),
|
||||
value.c_str());
|
||||
LOGV("AmiAdapter (%lld) %s : %s", analytics_item_.getSessionID(),
|
||||
metric_id.c_str(), value.c_str());
|
||||
}
|
||||
|
||||
void AmiAdapter::UpdateInt32(const std::string& metric_id,
|
||||
int32_t value) {
|
||||
void AmiAdapter::UpdateInt32(const std::string& metric_id, int32_t value) {
|
||||
analytics_item_.setInt32(metric_id.c_str(), value);
|
||||
LOGV(
|
||||
"AmiAdapter (%lld) %s : %ld",
|
||||
analytics_item_.getSessionID(),
|
||||
metric_id.c_str(),
|
||||
value);
|
||||
LOGV("AmiAdapter (%lld) %s : %ld", analytics_item_.getSessionID(),
|
||||
metric_id.c_str(), value);
|
||||
}
|
||||
|
||||
void AmiAdapter::UpdateInt64(const std::string& metric_id,
|
||||
int64_t value) {
|
||||
void AmiAdapter::UpdateInt64(const std::string& metric_id, int64_t value) {
|
||||
analytics_item_.setInt64(metric_id.c_str(), value);
|
||||
LOGV(
|
||||
"AmiAdapter (%lld) %s : %lld",
|
||||
analytics_item_.getSessionID(),
|
||||
metric_id.c_str(),
|
||||
value);
|
||||
LOGV("AmiAdapter (%lld) %s : %lld", analytics_item_.getSessionID(),
|
||||
metric_id.c_str(), value);
|
||||
}
|
||||
|
||||
void AmiAdapter::UpdateDouble(const std::string& metric_id,
|
||||
double value) {
|
||||
void AmiAdapter::UpdateDouble(const std::string& metric_id, double value) {
|
||||
analytics_item_.setDouble(metric_id.c_str(), value);
|
||||
LOGV(
|
||||
"AmiAdapter (%lld) %s : %f",
|
||||
analytics_item_.getSessionID(),
|
||||
metric_id.c_str(),
|
||||
value);
|
||||
LOGV("AmiAdapter (%lld) %s : %f", analytics_item_.getSessionID(),
|
||||
metric_id.c_str(), value);
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -121,9 +121,15 @@ bool Properties::GetDeviceFilesBasePath(CdmSecurityLevel security_level,
|
||||
std::stringstream ss;
|
||||
ss << kBasePathPrefix << getuid();
|
||||
switch (security_level) {
|
||||
case kSecurityLevelL1: ss << kL1Dir; break;
|
||||
case kSecurityLevelL2: ss << kL2Dir; break;
|
||||
case kSecurityLevelL3: ss << kL3Dir; break;
|
||||
case kSecurityLevelL1:
|
||||
ss << kL1Dir;
|
||||
break;
|
||||
case kSecurityLevelL2:
|
||||
ss << kL2Dir;
|
||||
break;
|
||||
case kSecurityLevelL3:
|
||||
ss << kL3Dir;
|
||||
break;
|
||||
default:
|
||||
LOGW("Properties::GetDeviceFilesBasePath: Unknown security level: %d",
|
||||
security_level);
|
||||
@@ -163,12 +169,8 @@ bool Properties::GetSandboxId(std::string* /* sandbox_id */) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Properties::AlwaysUseKeySetIds() {
|
||||
return false;
|
||||
}
|
||||
bool Properties::AlwaysUseKeySetIds() { return false; }
|
||||
|
||||
bool Properties::UseProviderIdInProvisioningRequest() {
|
||||
return false;
|
||||
}
|
||||
bool Properties::UseProviderIdInProvisioningRequest() { return false; }
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -20,21 +20,21 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
class ImplThread : public android::Thread {
|
||||
public:
|
||||
ImplThread() : Thread(false), handler_(nullptr), period_ns_(0) {}
|
||||
virtual ~ImplThread() {};
|
||||
virtual ~ImplThread() {}
|
||||
|
||||
bool Start(TimerHandler *handler, uint32_t time_in_secs) {
|
||||
bool Start(TimerHandler* handler, uint32_t time_in_secs) {
|
||||
handler_ = handler;
|
||||
period_ns_ = time_in_secs * 1000000000ll;
|
||||
return run("wvcdm::Timer::Impl") == android::NO_ERROR;
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
{
|
||||
android::Mutex::Autolock autoLock(lock_);
|
||||
stop_condition_.signal();
|
||||
}
|
||||
requestExitAndWait();
|
||||
}
|
||||
void Stop() {
|
||||
{
|
||||
android::Mutex::Autolock autoLock(lock_);
|
||||
stop_condition_.signal();
|
||||
}
|
||||
requestExitAndWait();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool threadLoop() {
|
||||
@@ -44,7 +44,7 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
TimerHandler *handler_;
|
||||
TimerHandler* handler_;
|
||||
uint64_t period_ns_;
|
||||
android::Mutex lock_;
|
||||
android::Condition stop_condition_;
|
||||
@@ -56,9 +56,9 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
|
||||
public:
|
||||
Impl() {}
|
||||
virtual ~Impl() {};
|
||||
virtual ~Impl(){};
|
||||
|
||||
bool Start(TimerHandler *handler, uint32_t time_in_secs) {
|
||||
bool Start(TimerHandler* handler, uint32_t time_in_secs) {
|
||||
impl_thread_ = new ImplThread();
|
||||
return impl_thread_->Start(handler, time_in_secs);
|
||||
}
|
||||
@@ -75,27 +75,20 @@ class Timer::Impl : virtual public android::RefBase {
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(Impl);
|
||||
};
|
||||
|
||||
Timer::Timer() : impl_(new Timer::Impl()) {
|
||||
}
|
||||
Timer::Timer() : impl_(new Timer::Impl()) {}
|
||||
|
||||
Timer::~Timer() {
|
||||
if (IsRunning())
|
||||
Stop();
|
||||
if (IsRunning()) Stop();
|
||||
}
|
||||
|
||||
bool Timer::Start(TimerHandler *handler, uint32_t time_in_secs) {
|
||||
if (!handler || time_in_secs == 0)
|
||||
return false;
|
||||
bool Timer::Start(TimerHandler* handler, uint32_t time_in_secs) {
|
||||
if (!handler || time_in_secs == 0) return false;
|
||||
|
||||
return impl_->Start(handler, time_in_secs);
|
||||
}
|
||||
|
||||
void Timer::Stop() {
|
||||
impl_->Stop();
|
||||
}
|
||||
void Timer::Stop() { impl_->Stop(); }
|
||||
|
||||
bool Timer::IsRunning() {
|
||||
return impl_->IsRunning();
|
||||
}
|
||||
bool Timer::IsRunning() { return impl_->IsRunning(); }
|
||||
|
||||
} // namespace wvcdm
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -106,16 +106,14 @@ CdmResponseType WvContentDecryptionModule::GenerateKeyRequest(
|
||||
}
|
||||
|
||||
const SecurityLevel requested_security_level =
|
||||
property_set &&
|
||||
property_set->security_level().compare(
|
||||
wvcdm::QUERY_VALUE_SECURITY_LEVEL_L3) == 0
|
||||
property_set && property_set->security_level().compare(
|
||||
wvcdm::QUERY_VALUE_SECURITY_LEVEL_L3) == 0
|
||||
? wvcdm::kLevel3
|
||||
: wvcdm::kLevelDefault;
|
||||
|
||||
std::string oec_version;
|
||||
sts = cdm_engine->QueryStatus(requested_security_level,
|
||||
QUERY_KEY_OEMCRYPTO_API_VERSION,
|
||||
&oec_version);
|
||||
QUERY_KEY_OEMCRYPTO_API_VERSION, &oec_version);
|
||||
if (sts != NO_ERROR) {
|
||||
return sts;
|
||||
}
|
||||
@@ -258,8 +256,7 @@ CdmResponseType WvContentDecryptionModule::RemoveAllUsageInfo(
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::RemoveUsageInfo(
|
||||
const std::string& app_id,
|
||||
const CdmIdentifier& identifier,
|
||||
const std::string& app_id, const CdmIdentifier& identifier,
|
||||
const CdmSecureStopId& secure_stop_id) {
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(identifier);
|
||||
return cdm_engine->RemoveUsageInfo(app_id, secure_stop_id);
|
||||
@@ -273,12 +270,12 @@ CdmResponseType WvContentDecryptionModule::ReleaseUsageInfo(
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GetSecureStopIds(
|
||||
const std::string& app_id,
|
||||
const CdmIdentifier& identifier,
|
||||
const std::string& app_id, const CdmIdentifier& identifier,
|
||||
std::vector<CdmSecureStopId>* ssids) {
|
||||
if (ssids == nullptr) {
|
||||
LOGE("WvContentDecryptionModule::GetSecureStopIds: ssid destination not "
|
||||
"provided");
|
||||
LOGE(
|
||||
"WvContentDecryptionModule::GetSecureStopIds: "
|
||||
"ssid destination not provided");
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
|
||||
@@ -337,7 +334,6 @@ bool WvContentDecryptionModule::IsValidServiceCertificate(
|
||||
return cert.has_certificate();
|
||||
}
|
||||
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GetMetrics(
|
||||
const CdmIdentifier& identifier, drm_metrics::WvCdmMetrics* metrics) {
|
||||
if (!metrics) {
|
||||
@@ -350,8 +346,8 @@ CdmResponseType WvContentDecryptionModule::GetMetrics(
|
||||
// TODO(blueeyes): Add a better error.
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
return it->second.cdm_engine->GetMetricsSnapshot(metrics) ?
|
||||
NO_ERROR : UNKNOWN_ERROR;
|
||||
return it->second.cdm_engine->GetMetricsSnapshot(metrics) ? NO_ERROR
|
||||
: UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
WvContentDecryptionModule::CdmInfo::CdmInfo()
|
||||
@@ -453,13 +449,13 @@ CdmResponseType WvContentDecryptionModule::SetDecryptHash(
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GetDecryptHashError(
|
||||
const CdmSessionId& session_id,
|
||||
std::string* hash_error_string) {
|
||||
const CdmSessionId& session_id, std::string* hash_error_string) {
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
|
||||
if (!cdm_engine) {
|
||||
LOGE("WVContentDecryptionModule::GetDecryptHashError: Unable to find "
|
||||
"CdmEngine");
|
||||
LOGE(
|
||||
"WVContentDecryptionModule::GetDecryptHashError: "
|
||||
"Unable to find CdmEngine");
|
||||
return SESSION_NOT_FOUND_20;
|
||||
}
|
||||
return cdm_engine->GetDecryptHashError(session_id, hash_error_string);
|
||||
@@ -491,31 +487,25 @@ uint32_t WvContentDecryptionModule::GenerateSessionSharingId() {
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::ListStoredLicenses(
|
||||
CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier,
|
||||
CdmSecurityLevel security_level, const CdmIdentifier& identifier,
|
||||
std::vector<CdmKeySetId>* key_set_ids) {
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(identifier);
|
||||
return cdm_engine->ListStoredLicenses(
|
||||
security_level, key_set_ids);
|
||||
return cdm_engine->ListStoredLicenses(security_level, key_set_ids);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GetOfflineLicenseState(
|
||||
const CdmKeySetId& key_set_id,
|
||||
CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier,
|
||||
CdmOfflineLicenseState* license_state) {
|
||||
const CdmKeySetId& key_set_id, CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier, CdmOfflineLicenseState* license_state) {
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(identifier);
|
||||
return cdm_engine->GetOfflineLicenseState(
|
||||
key_set_id, security_level, license_state);
|
||||
return cdm_engine->GetOfflineLicenseState(key_set_id, security_level,
|
||||
license_state);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::RemoveOfflineLicense(
|
||||
const CdmKeySetId& key_set_id,
|
||||
CdmSecurityLevel security_level,
|
||||
const CdmKeySetId& key_set_id, CdmSecurityLevel security_level,
|
||||
const CdmIdentifier& identifier) {
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(identifier);
|
||||
return cdm_engine->RemoveOfflineLicense(
|
||||
key_set_id, security_level);
|
||||
return cdm_engine->RemoveOfflineLicense(key_set_id, security_level);
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -408,11 +408,9 @@ TEST_F(WvCdmFeatureTest, OEMCertificateProvisioning) {
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.GetProvisioningRequest(cert_type, cert_authority,
|
||||
kDefaultCdmIdentifier,
|
||||
kEmptyServiceCertificate,
|
||||
&key_msg_,
|
||||
&provisioning_server_url));
|
||||
decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, kDefaultCdmIdentifier,
|
||||
kEmptyServiceCertificate, &key_msg_, &provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, config_.provisioning_server());
|
||||
|
||||
ClientIdentification_TokenType token_type;
|
||||
@@ -445,11 +443,9 @@ TEST_F(WvCdmFeatureTest, KeyboxProvisioning) {
|
||||
std::string cert_authority, cert, wrapped_key;
|
||||
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.GetProvisioningRequest(cert_type, cert_authority,
|
||||
kDefaultCdmIdentifier,
|
||||
kEmptyServiceCertificate,
|
||||
&key_msg_,
|
||||
&provisioning_server_url));
|
||||
decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, kDefaultCdmIdentifier,
|
||||
kEmptyServiceCertificate, &key_msg_, &provisioning_server_url));
|
||||
EXPECT_EQ(provisioning_server_url, config_.provisioning_server());
|
||||
|
||||
ClientIdentification_TokenType token_type;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,14 +3,15 @@
|
||||
// License Agreement.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class TestTimerHandler : public TimerHandler {
|
||||
public:
|
||||
TestTimerHandler() : timer_events_(0) {};
|
||||
virtual ~TestTimerHandler() {};
|
||||
TestTimerHandler() : timer_events_(0){};
|
||||
virtual ~TestTimerHandler(){};
|
||||
|
||||
virtual void OnTimerEvent() { timer_events_++; }
|
||||
|
||||
@@ -49,4 +50,4 @@ TEST(TimerTest, TimerCheck) {
|
||||
EXPECT_LE(duration - 1, handler.timer_events());
|
||||
EXPECT_LE(handler.timer_events(), duration + 1);
|
||||
}
|
||||
}
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
#include "wv_content_decryption_module.h"
|
||||
|
||||
using ::testing::Eq;
|
||||
using ::testing::StrEq;
|
||||
using ::testing::Ge;
|
||||
using ::testing::Gt;
|
||||
using ::testing::Lt;
|
||||
using ::testing::StrEq;
|
||||
using ::testing::Test;
|
||||
using wvcdm::CdmResponseType;
|
||||
|
||||
@@ -58,41 +58,45 @@ TEST_F(WvContentDecryptionModuleMetricsTest, EngineOnlyMetrics) {
|
||||
EXPECT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.GetProvisioningRequest(
|
||||
cert_type, cert_authority, kDefaultCdmIdentifier,
|
||||
kEmptyServiceCertificate, &request,
|
||||
&provisioning_server_url));
|
||||
kEmptyServiceCertificate, &request, &provisioning_server_url));
|
||||
|
||||
drm_metrics::WvCdmMetrics metrics;
|
||||
ASSERT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.GetMetrics(kDefaultCdmIdentifier, &metrics));
|
||||
|
||||
// 100 is an arbitrary high value that shouldn't ever occur.
|
||||
EXPECT_THAT(
|
||||
metrics.engine_metrics().level3_oemcrypto_initialization_error()
|
||||
.int_value(), Lt(100));
|
||||
EXPECT_THAT(
|
||||
metrics.engine_metrics().level3_oemcrypto_initialization_error()
|
||||
.int_value(), Ge(0));
|
||||
EXPECT_THAT(metrics.engine_metrics()
|
||||
.level3_oemcrypto_initialization_error()
|
||||
.int_value(),
|
||||
Lt(100));
|
||||
EXPECT_THAT(metrics.engine_metrics()
|
||||
.level3_oemcrypto_initialization_error()
|
||||
.int_value(),
|
||||
Ge(0));
|
||||
EXPECT_THAT(
|
||||
metrics.engine_metrics().oemcrypto_initialization_mode().int_value(),
|
||||
Lt(100));
|
||||
EXPECT_THAT(
|
||||
metrics.engine_metrics().oemcrypto_initialization_mode().int_value(),
|
||||
Ge(0));
|
||||
EXPECT_THAT(
|
||||
metrics.engine_metrics().previous_oemcrypto_initialization_failure()
|
||||
.int_value(), Lt(100));
|
||||
EXPECT_THAT(
|
||||
metrics.engine_metrics().previous_oemcrypto_initialization_failure()
|
||||
.int_value(), Ge(0));
|
||||
EXPECT_THAT(metrics.engine_metrics()
|
||||
.previous_oemcrypto_initialization_failure()
|
||||
.int_value(),
|
||||
Lt(100));
|
||||
EXPECT_THAT(metrics.engine_metrics()
|
||||
.previous_oemcrypto_initialization_failure()
|
||||
.int_value(),
|
||||
Ge(0));
|
||||
ASSERT_THAT(metrics.engine_metrics()
|
||||
.cdm_engine_get_provisioning_request_time_us().size(), Eq(1));
|
||||
.cdm_engine_get_provisioning_request_time_us()
|
||||
.size(),
|
||||
Eq(1));
|
||||
EXPECT_THAT(metrics.engine_metrics()
|
||||
.cdm_engine_get_provisioning_request_time_us(0)
|
||||
.operation_count(),
|
||||
Eq(1u));
|
||||
Eq(1u));
|
||||
}
|
||||
|
||||
|
||||
TEST_F(WvContentDecryptionModuleMetricsTest, EngineAndSessionMetrics) {
|
||||
CdmSessionId session_id;
|
||||
wvcdm::CdmKeySystem key_system("com.widevine");
|
||||
@@ -112,36 +116,38 @@ TEST_F(WvContentDecryptionModuleMetricsTest, EngineAndSessionMetrics) {
|
||||
|
||||
// Spot check some metric values.
|
||||
// Validate engine-level metrics.
|
||||
EXPECT_TRUE(metrics.engine_metrics()
|
||||
.has_level3_oemcrypto_initialization_error());
|
||||
EXPECT_TRUE(
|
||||
metrics.engine_metrics().has_level3_oemcrypto_initialization_error());
|
||||
EXPECT_TRUE(metrics.engine_metrics().has_oemcrypto_initialization_mode());
|
||||
EXPECT_TRUE(metrics.engine_metrics()
|
||||
.has_previous_oemcrypto_initialization_failure());
|
||||
EXPECT_TRUE(
|
||||
metrics.engine_metrics().has_previous_oemcrypto_initialization_failure());
|
||||
ASSERT_THAT(metrics.engine_metrics().cdm_engine_open_session().size(), Eq(1));
|
||||
EXPECT_THAT(metrics.engine_metrics().cdm_engine_open_session(0).count(),
|
||||
Eq(1));
|
||||
EXPECT_THAT(metrics.engine_metrics()
|
||||
.cdm_engine_open_session(0).attributes().error_code(),
|
||||
Eq(CdmResponseType::NEED_PROVISIONING));
|
||||
.cdm_engine_open_session(0)
|
||||
.attributes()
|
||||
.error_code(),
|
||||
Eq(CdmResponseType::NEED_PROVISIONING));
|
||||
|
||||
// Validate a session-level metric.
|
||||
ASSERT_THAT(metrics.session_metrics().size(), Eq(1));
|
||||
EXPECT_THAT(
|
||||
metrics.session_metrics(0).cdm_session_life_span_ms().double_value(),
|
||||
Gt(0.0))
|
||||
<< "Unexpected failure with session_metrics: "
|
||||
<< wvcdm::b2a_hex(serialized_metrics);
|
||||
<< "Unexpected failure with session_metrics: "
|
||||
<< wvcdm::b2a_hex(serialized_metrics);
|
||||
}
|
||||
|
||||
TEST_F(WvContentDecryptionModuleMetricsTest,
|
||||
DifferentCdmIdentifiersHaveDifferentMetrics) {
|
||||
CdmSessionId session_id;
|
||||
wvcdm::CdmKeySystem key_system("com.widevine");
|
||||
CdmIdentifier identifiers[] = { kDefaultCdmIdentifier,
|
||||
{ "foo", "bar", "baz", 7 },
|
||||
// Note that this has all the same parameters
|
||||
// as the one above except for the unique_id.
|
||||
{ "foo", "bar", "baz", 8 }};
|
||||
CdmIdentifier identifiers[] = {kDefaultCdmIdentifier,
|
||||
{"foo", "bar", "baz", 7},
|
||||
// Note that this has all the same parameters
|
||||
// as the one above except for the unique_id.
|
||||
{"foo", "bar", "baz", 8}};
|
||||
const int cdm_engine_count = 3;
|
||||
|
||||
// Force Unprovision.
|
||||
@@ -153,7 +159,7 @@ TEST_F(WvContentDecryptionModuleMetricsTest,
|
||||
// To make sure we can detect different engine metrics,
|
||||
// make the open session call a different number of times for
|
||||
// each identifier.
|
||||
for (int j = 0; j <= i; j ++) {
|
||||
for (int j = 0; j <= i; j++) {
|
||||
EXPECT_EQ(CdmResponseType::NEED_PROVISIONING,
|
||||
decryptor_.OpenSession(key_system, nullptr, identifiers[i],
|
||||
nullptr, &session_id));
|
||||
@@ -163,8 +169,7 @@ TEST_F(WvContentDecryptionModuleMetricsTest,
|
||||
for (int i = 0; i < cdm_engine_count; i++) {
|
||||
drm_metrics::WvCdmMetrics metrics;
|
||||
metrics.Clear();
|
||||
ASSERT_EQ(wvcdm::NO_ERROR,
|
||||
decryptor_.GetMetrics(identifiers[i], &metrics));
|
||||
ASSERT_EQ(wvcdm::NO_ERROR, decryptor_.GetMetrics(identifiers[i], &metrics));
|
||||
std::string serialized_metrics;
|
||||
ASSERT_TRUE(metrics.SerializeToString(&serialized_metrics));
|
||||
|
||||
@@ -174,20 +179,22 @@ TEST_F(WvContentDecryptionModuleMetricsTest,
|
||||
// of the identifier
|
||||
EXPECT_THAT(metrics.engine_metrics().cdm_engine_open_session(0).count(),
|
||||
Eq(i + 1));
|
||||
EXPECT_THAT(
|
||||
metrics.engine_metrics()
|
||||
.cdm_engine_open_session(0).attributes().error_code(),
|
||||
Eq(CdmResponseType::NEED_PROVISIONING));
|
||||
EXPECT_THAT(metrics.engine_metrics()
|
||||
.cdm_engine_open_session(0)
|
||||
.attributes()
|
||||
.error_code(),
|
||||
Eq(CdmResponseType::NEED_PROVISIONING));
|
||||
|
||||
// Spot check a session-level metric.
|
||||
ASSERT_THAT(metrics.session_metrics().size(), Eq(i + 1))
|
||||
<< "Unexpected failure with session_metrics: "
|
||||
<< wvcdm::b2a_hex(serialized_metrics);
|
||||
EXPECT_THAT(metrics.session_metrics(0)
|
||||
.cdm_session_life_span_ms().double_value(), Gt(0.0))
|
||||
EXPECT_THAT(
|
||||
metrics.session_metrics(0).cdm_session_life_span_ms().double_value(),
|
||||
Gt(0.0))
|
||||
<< "Unexpected failure with session_metrics: "
|
||||
<< wvcdm::b2a_hex(serialized_metrics);
|
||||
}
|
||||
}
|
||||
|
||||
} // wvcdm namespace
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user