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