Merge "Factory extraction tool: Use device info from OS property when TEE returns empty" into udc-dev am: 9c42689506 am: 7256ccc161

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/22816864

Change-Id: Ic167c44103ff37b5c57cb0f0f6ab3719ea69e5bc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Cong Lin
2023-04-26 04:07:39 +00:00
committed by Automerger Merge Worker
3 changed files with 52 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ namespace wvcdm {
// This class gives device information/meta data. // This class gives device information/meta data.
class Properties { class Properties {
public: public:
static bool GetBrandName(std::string* brand_name);
static bool GetCompanyName(std::string* company_name); static bool GetCompanyName(std::string* company_name);
static bool GetModelName(std::string* model_name); static bool GetModelName(std::string* model_name);
static bool GetArchitectureName(std::string* arch_name); static bool GetArchitectureName(std::string* arch_name);

View File

@@ -87,6 +87,11 @@ bool WidevineProvisioner::TryAddVerifiedDeviceInfo(
for (size_t i = 0; i < verified_device_info_map->size(); i++) { for (size_t i = 0; i < verified_device_info_map->size(); i++) {
auto& [key_item, value_item] = (*verified_device_info_map)[i]; auto& [key_item, value_item] = (*verified_device_info_map)[i];
LOGI("Found device info %s", key_item->asTstr()->value().data()); LOGI("Found device info %s", key_item->asTstr()->value().data());
if (value_item != nullptr && value_item->asTstr() != nullptr &&
value_item->asTstr()->value().empty()) {
LOGI("Value is empty. Skip");
continue;
}
device_info_map.add(key_item->clone(), value_item->clone()); device_info_map.add(key_item->clone(), value_item->clone());
} }
return true; return true;
@@ -96,7 +101,22 @@ bool WidevineProvisioner::GetDeviceInfoCommon(cppbor::Map& device_info_map) {
if (!TryAddVerifiedDeviceInfo(device_info_map)) return false; if (!TryAddVerifiedDeviceInfo(device_info_map)) return false;
// Add device information from OS properties if the verified device info is // Add device information from OS properties if the verified device info is
// not present // not present
if (device_info_map.get("manufacturer") == nullptr) { if (device_info_map.get("brand") == nullptr ||
device_info_map.get("brand")->asTstr()->value().empty()) {
std::string brand_name;
if (!wvcdm::Properties::GetBrandName(&brand_name) || brand_name.empty()) {
LOGE("Failed to get brand name.");
return false;
}
device_info_map.add(cppbor::Tstr("brand"), cppbor::Tstr(brand_name));
LOGI("use OS property brand: %s", brand_name.data());
} else {
LOGI("use verified brand: %s",
device_info_map.get("brand")->asTstr()->value().data());
}
if (device_info_map.get("manufacturer") == nullptr ||
device_info_map.get("manufacturer")->asTstr()->value().empty()) {
std::string company_name; std::string company_name;
if (!wvcdm::Properties::GetCompanyName(&company_name) || if (!wvcdm::Properties::GetCompanyName(&company_name) ||
company_name.empty()) { company_name.empty()) {
@@ -105,18 +125,28 @@ bool WidevineProvisioner::GetDeviceInfoCommon(cppbor::Map& device_info_map) {
} }
device_info_map.add(cppbor::Tstr("manufacturer"), device_info_map.add(cppbor::Tstr("manufacturer"),
cppbor::Tstr(company_name)); cppbor::Tstr(company_name));
LOGI("use OS property manufacturer: %s", company_name.data());
} else {
LOGI("use verified manufacture: %s",
device_info_map.get("manufacturer")->asTstr()->value().data());
} }
if (device_info_map.get("model") == nullptr) { if (device_info_map.get("model") == nullptr ||
device_info_map.get("model")->asTstr()->value().empty()) {
std::string model_name; std::string model_name;
if (!wvcdm::Properties::GetModelName(&model_name) || model_name.empty()) { if (!wvcdm::Properties::GetModelName(&model_name) || model_name.empty()) {
LOGE("Failed to get model name."); LOGE("Failed to get model name.");
return false; return false;
} }
device_info_map.add(cppbor::Tstr("model"), cppbor::Tstr(model_name)); device_info_map.add(cppbor::Tstr("model"), cppbor::Tstr(model_name));
LOGI("use OS property model: %s", model_name.data());
} else {
LOGI("use verified model: %s",
device_info_map.get("model")->asTstr()->value().data());
} }
if (device_info_map.get("device") == nullptr) { if (device_info_map.get("device") == nullptr ||
device_info_map.get("device")->asTstr()->value().empty()) {
std::string device_name; std::string device_name;
if (!wvcdm::Properties::GetDeviceName(&device_name) || if (!wvcdm::Properties::GetDeviceName(&device_name) ||
device_name.empty()) { device_name.empty()) {
@@ -124,9 +154,14 @@ bool WidevineProvisioner::GetDeviceInfoCommon(cppbor::Map& device_info_map) {
return false; return false;
} }
device_info_map.add(cppbor::Tstr("device"), cppbor::Tstr(device_name)); device_info_map.add(cppbor::Tstr("device"), cppbor::Tstr(device_name));
LOGI("use OS property device: %s", device_name.data());
} else {
LOGI("use verified device: %s",
device_info_map.get("device")->asTstr()->value().data());
} }
if (device_info_map.get("product") == nullptr) { if (device_info_map.get("product") == nullptr ||
device_info_map.get("product")->asTstr()->value().empty()) {
std::string product_name; std::string product_name;
if (!wvcdm::Properties::GetProductName(&product_name) || if (!wvcdm::Properties::GetProductName(&product_name) ||
product_name.empty()) { product_name.empty()) {
@@ -134,6 +169,10 @@ bool WidevineProvisioner::GetDeviceInfoCommon(cppbor::Map& device_info_map) {
return false; return false;
} }
device_info_map.add(cppbor::Tstr("product"), cppbor::Tstr(product_name)); device_info_map.add(cppbor::Tstr("product"), cppbor::Tstr(product_name));
LOGI("use OS property product: %s", product_name.data());
} else {
LOGI("use verified product: %s",
device_info_map.get("product")->asTstr()->value().data());
} }
std::string arch_name; std::string arch_name;

View File

@@ -33,6 +33,14 @@ bool GetAndroidProperty(const char* key, std::string* value) {
namespace wvcdm { namespace wvcdm {
bool Properties::GetBrandName(std::string* brand_name) {
if (!brand_name) {
LOGW("Properties::GetBrandName: Invalid parameter");
return false;
}
return GetAndroidProperty("ro.product.brand", brand_name);
}
bool Properties::GetCompanyName(std::string* company_name) { bool Properties::GetCompanyName(std::string* company_name) {
if (!company_name) { if (!company_name) {
LOGW("Properties::GetCompanyName: Invalid parameter"); LOGW("Properties::GetCompanyName: Invalid parameter");