Added mutex protection for session_property_set_. am: 381f879ff7
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/19561012 Change-Id: Iec56b526fd95cafbd09aae9894796c959924f48a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -142,6 +142,7 @@ class Properties {
|
|||||||
static void InitOnce();
|
static void InitOnce();
|
||||||
|
|
||||||
static std::mutex init_mutex_;
|
static std::mutex init_mutex_;
|
||||||
|
static std::mutex session_mutex_;
|
||||||
static bool is_initialized_;
|
static bool is_initialized_;
|
||||||
static bool oem_crypto_use_secure_buffers_;
|
static bool oem_crypto_use_secure_buffers_;
|
||||||
static bool oem_crypto_use_fifo_;
|
static bool oem_crypto_use_fifo_;
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ const char* kSecurityLevelDirs[] = {"L1/", "L3/"};
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
|
using UniqueLock = std::unique_lock<std::mutex>;
|
||||||
|
|
||||||
std::mutex Properties::init_mutex_;
|
std::mutex Properties::init_mutex_;
|
||||||
|
std::mutex Properties::session_mutex_;
|
||||||
bool Properties::is_initialized_ = false;
|
bool Properties::is_initialized_ = false;
|
||||||
bool Properties::oem_crypto_use_secure_buffers_;
|
bool Properties::oem_crypto_use_secure_buffers_;
|
||||||
bool Properties::oem_crypto_use_fifo_;
|
bool Properties::oem_crypto_use_fifo_;
|
||||||
@@ -26,6 +29,7 @@ std::unique_ptr<CdmClientPropertySetMap> Properties::session_property_set_;
|
|||||||
|
|
||||||
bool Properties::AddSessionPropertySet(const CdmSessionId& session_id,
|
bool Properties::AddSessionPropertySet(const CdmSessionId& session_id,
|
||||||
CdmClientPropertySet* property_set) {
|
CdmClientPropertySet* property_set) {
|
||||||
|
UniqueLock lock(session_mutex_);
|
||||||
if (!session_property_set_) {
|
if (!session_property_set_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -37,6 +41,7 @@ bool Properties::AddSessionPropertySet(const CdmSessionId& session_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Properties::RemoveSessionPropertySet(const CdmSessionId& session_id) {
|
bool Properties::RemoveSessionPropertySet(const CdmSessionId& session_id) {
|
||||||
|
UniqueLock lock(session_mutex_);
|
||||||
if (!session_property_set_) {
|
if (!session_property_set_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -45,6 +50,7 @@ bool Properties::RemoveSessionPropertySet(const CdmSessionId& session_id) {
|
|||||||
|
|
||||||
CdmClientPropertySet* Properties::GetCdmClientPropertySet(
|
CdmClientPropertySet* Properties::GetCdmClientPropertySet(
|
||||||
const CdmSessionId& session_id) {
|
const CdmSessionId& session_id) {
|
||||||
|
// Call must obtain |session_mutex_|.
|
||||||
if (session_property_set_) {
|
if (session_property_set_) {
|
||||||
CdmClientPropertySetMap::iterator it =
|
CdmClientPropertySetMap::iterator it =
|
||||||
session_property_set_->find(session_id);
|
session_property_set_->find(session_id);
|
||||||
@@ -57,6 +63,7 @@ CdmClientPropertySet* Properties::GetCdmClientPropertySet(
|
|||||||
|
|
||||||
bool Properties::GetApplicationId(const CdmSessionId& session_id,
|
bool Properties::GetApplicationId(const CdmSessionId& session_id,
|
||||||
std::string* app_id) {
|
std::string* app_id) {
|
||||||
|
UniqueLock lock(session_mutex_);
|
||||||
const CdmClientPropertySet* property_set =
|
const CdmClientPropertySet* property_set =
|
||||||
GetCdmClientPropertySet(session_id);
|
GetCdmClientPropertySet(session_id);
|
||||||
if (property_set == nullptr) {
|
if (property_set == nullptr) {
|
||||||
@@ -68,6 +75,7 @@ bool Properties::GetApplicationId(const CdmSessionId& session_id,
|
|||||||
|
|
||||||
bool Properties::GetServiceCertificate(const CdmSessionId& session_id,
|
bool Properties::GetServiceCertificate(const CdmSessionId& session_id,
|
||||||
std::string* service_certificate) {
|
std::string* service_certificate) {
|
||||||
|
UniqueLock lock(session_mutex_);
|
||||||
const CdmClientPropertySet* property_set =
|
const CdmClientPropertySet* property_set =
|
||||||
GetCdmClientPropertySet(session_id);
|
GetCdmClientPropertySet(session_id);
|
||||||
if (property_set == nullptr) {
|
if (property_set == nullptr) {
|
||||||
@@ -79,6 +87,7 @@ bool Properties::GetServiceCertificate(const CdmSessionId& session_id,
|
|||||||
|
|
||||||
bool Properties::SetServiceCertificate(const CdmSessionId& session_id,
|
bool Properties::SetServiceCertificate(const CdmSessionId& session_id,
|
||||||
const std::string& service_certificate) {
|
const std::string& service_certificate) {
|
||||||
|
UniqueLock lock(session_mutex_);
|
||||||
CdmClientPropertySet* property_set = GetCdmClientPropertySet(session_id);
|
CdmClientPropertySet* property_set = GetCdmClientPropertySet(session_id);
|
||||||
if (property_set == nullptr) {
|
if (property_set == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
@@ -88,6 +97,7 @@ bool Properties::SetServiceCertificate(const CdmSessionId& session_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Properties::UsePrivacyMode(const CdmSessionId& session_id) {
|
bool Properties::UsePrivacyMode(const CdmSessionId& session_id) {
|
||||||
|
UniqueLock lock(session_mutex_);
|
||||||
const CdmClientPropertySet* property_set =
|
const CdmClientPropertySet* property_set =
|
||||||
GetCdmClientPropertySet(session_id);
|
GetCdmClientPropertySet(session_id);
|
||||||
if (property_set == nullptr) {
|
if (property_set == nullptr) {
|
||||||
@@ -97,6 +107,7 @@ bool Properties::UsePrivacyMode(const CdmSessionId& session_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Properties::GetSessionSharingId(const CdmSessionId& session_id) {
|
uint32_t Properties::GetSessionSharingId(const CdmSessionId& session_id) {
|
||||||
|
UniqueLock lock(session_mutex_);
|
||||||
const CdmClientPropertySet* property_set =
|
const CdmClientPropertySet* property_set =
|
||||||
GetCdmClientPropertySet(session_id);
|
GetCdmClientPropertySet(session_id);
|
||||||
if (property_set == nullptr) {
|
if (property_set == nullptr) {
|
||||||
|
|||||||
@@ -52,8 +52,11 @@ void Properties::InitOnce() {
|
|||||||
allow_restore_of_offline_licenses_with_release_ =
|
allow_restore_of_offline_licenses_with_release_ =
|
||||||
kAllowRestoreOfflineLicenseWithRelease;
|
kAllowRestoreOfflineLicenseWithRelease;
|
||||||
delay_oem_crypto_termination_ = kPropertyDelayOemCryptoTermination;
|
delay_oem_crypto_termination_ = kPropertyDelayOemCryptoTermination;
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(session_mutex_);
|
||||||
session_property_set_.reset(new CdmClientPropertySetMap());
|
session_property_set_.reset(new CdmClientPropertySetMap());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Properties::GetCompanyName(std::string* company_name) {
|
bool Properties::GetCompanyName(std::string* company_name) {
|
||||||
if (!company_name) {
|
if (!company_name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user