diff --git a/libwvdrmengine/Android.mk b/libwvdrmengine/Android.mk index c6bdb741..0f528b63 100644 --- a/libwvdrmengine/Android.mk +++ b/libwvdrmengine/Android.mk @@ -66,6 +66,7 @@ LOCAL_STATIC_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libcrypto \ + libcutils \ libdl \ liblog \ libstlport \ diff --git a/libwvdrmengine/cdm/Android.mk b/libwvdrmengine/cdm/Android.mk index 04988226..62a79123 100644 --- a/libwvdrmengine/cdm/Android.mk +++ b/libwvdrmengine/cdm/Android.mk @@ -33,6 +33,7 @@ LOCAL_SRC_FILES := \ $(SRC_DIR)/clock.cpp \ $(SRC_DIR)/lock.cpp \ $(SRC_DIR)/log.cpp \ + $(SRC_DIR)/properties.cpp \ $(SRC_DIR)/timer.cpp \ $(SRC_DIR)/wv_content_decryption_module.cpp diff --git a/libwvdrmengine/cdm/core/include/properties.h b/libwvdrmengine/cdm/core/include/properties.h index 132cd174..8bc838ed 100644 --- a/libwvdrmengine/cdm/core/include/properties.h +++ b/libwvdrmengine/cdm/core/include/properties.h @@ -39,7 +39,11 @@ class Properties { static inline bool use_certificates_as_identification() { return use_certificates_as_identification_; } - + static bool GetModelName(std::string& model_name); + static bool GetArchitectureName(std::string& arch_name); + static bool GetDeviceName(std::string& device_name); + static bool GetProductName(std::string& product_name); + static bool GetBuildInfo(std::string& build_info); private: static void set_begin_license_usage_when_received(bool flag) { diff --git a/libwvdrmengine/cdm/core/src/license.cpp b/libwvdrmengine/cdm/core/src/license.cpp index 542d6fe3..9eb9380a 100644 --- a/libwvdrmengine/cdm/core/src/license.cpp +++ b/libwvdrmengine/cdm/core/src/license.cpp @@ -4,6 +4,7 @@ #include +#include "crypto_engine.h" #include "crypto_session.h" #include "log.h" #include "policy_engine.h" @@ -11,6 +12,17 @@ #include "string_conversions.h" #include "wv_cdm_constants.h" +namespace { + std::string kCompanyNameKey = "company_name"; + std::string kCompanyNameValueGoogle = "Google"; + std::string kModelNameKey = "model_name"; + std::string kArchitectureNameKey = "architecture_name"; + std::string kDeviceNameKey = "device_name"; + std::string kProductNameKey = "product_name"; + std::string kBuildInfoKey = "build_info"; + std::string kDeviceIdKey = "device_id"; +} + namespace wvcdm { // Protobuf generated classes. @@ -105,13 +117,45 @@ bool CdmLicense::PrepareKeyRequest(const CdmInitData& init_data, client_id->set_type(ClientIdentification::KEYBOX); client_id->set_token(token_); - ClientIdentification_NameValue client_info; + ClientIdentification_NameValue* client_info; CdmAppParameterMap::const_iterator iter; for (iter = app_parameters.begin(); iter != app_parameters.end(); iter++) { - ClientIdentification_NameValue* client_info = client_id->add_client_info(); + client_info = client_id->add_client_info(); client_info->set_name(iter->first); client_info->set_value(iter->second); } + std::string value; + client_info = client_id->add_client_info(); + client_info->set_name(kCompanyNameKey); + client_info->set_value(kCompanyNameValueGoogle); + if (Properties::GetModelName(value)) { + client_info = client_id->add_client_info(); + client_info->set_name(kModelNameKey); + client_info->set_value(value); + } + if (Properties::GetArchitectureName(value)) { + client_info = client_id->add_client_info(); + client_info->set_name(kArchitectureNameKey); + client_info->set_value(value); + } + if (Properties::GetDeviceName(value)) { + client_info = client_id->add_client_info(); + client_info->set_name(kDeviceNameKey); + client_info->set_value(value); + } + if (Properties::GetProductName(value)) { + client_info = client_id->add_client_info(); + client_info->set_name(kProductNameKey); + client_info->set_value(value); + } + if (Properties::GetBuildInfo(value)) { + client_info = client_id->add_client_info(); + client_info->set_name(kBuildInfoKey); + client_info->set_value(value); + } + + client_info->set_name(kDeviceIdKey); + client_info->set_value(CryptoEngine::GetInstance()->GetDeviceUniqueId()); // Content Identification may be a cenc_id, a webm_id or a license_id LicenseRequest_ContentIdentification* content_id = diff --git a/libwvdrmengine/cdm/src/properties.cpp b/libwvdrmengine/cdm/src/properties.cpp new file mode 100644 index 00000000..5489decb --- /dev/null +++ b/libwvdrmengine/cdm/src/properties.cpp @@ -0,0 +1,42 @@ +// Copyright 2013 Google Inc. All Rights Reserved. + +#include + +#include "cutils/properties.h" +#include "properties.h" + +namespace { + bool GetAndroidProperty(const char* key, std::string& value) { + char val[PROPERTY_VALUE_MAX]; + + if (property_get(key, val, "Unknown") <= 0) + return false; + + value = val; + return true; + } +} + +namespace wvcdm { + +bool Properties::GetModelName(std::string& model_name) { + return GetAndroidProperty("ro.product.model", model_name); +} + +bool Properties::GetArchitectureName(std::string& arch_name) { + return GetAndroidProperty("ro.product.cpu.abi", arch_name); +} + +bool Properties::GetDeviceName(std::string& device_name) { + return GetAndroidProperty("ro.product.device", device_name); +} + +bool Properties::GetProductName(std::string& product_name) { + return GetAndroidProperty("ro.product.name", product_name); +} + +bool Properties::GetBuildInfo(std::string& build_info) { + return GetAndroidProperty("ro.build.fingerprint", build_info); +} + +} // namespace wvcdm diff --git a/libwvdrmengine/mediacrypto/test/Android.mk b/libwvdrmengine/mediacrypto/test/Android.mk index d99ad100..67f52799 100644 --- a/libwvdrmengine/mediacrypto/test/Android.mk +++ b/libwvdrmengine/mediacrypto/test/Android.mk @@ -26,6 +26,7 @@ LOCAL_STATIC_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libcrypto \ + libcutils \ libdl \ liblog \ libstagefright_foundation \ diff --git a/libwvdrmengine/mediadrm/test/Android.mk b/libwvdrmengine/mediadrm/test/Android.mk index a0d5fa9d..59a74b5c 100644 --- a/libwvdrmengine/mediadrm/test/Android.mk +++ b/libwvdrmengine/mediadrm/test/Android.mk @@ -27,6 +27,7 @@ LOCAL_STATIC_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libcrypto \ + libcutils \ libdl \ liblog \ libstlport \