Similar change is merged to widevine internal tool: ag/22824076 Some mandatory device info fields like manufacturer can be empty string when returned from TEE on devices which have not been provisioned with attestation IDs. The extraction tool also needs to check for empty string in the response, and if so, populates the field with Android property values. Test: extracting device info from new Pixel EVT 1.1 and uploading Bug: 276958001 Change-Id: I055ee0994d9dbbbf9c0c0875670a449a56a3e29e
102 lines
2.5 KiB
C++
102 lines
2.5 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine License
|
|
// Agreement.
|
|
|
|
#include <android-base/properties.h>
|
|
#include <unistd.h>
|
|
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
#include "log.h"
|
|
#include "properties.h"
|
|
|
|
namespace {
|
|
|
|
bool GetAndroidProperty(const char* key, std::string* value) {
|
|
if (!key) {
|
|
LOGW("GetAndroidProperty: Invalid property key parameter");
|
|
return false;
|
|
}
|
|
|
|
if (!value) {
|
|
LOGW("GetAndroidProperty: Invalid property value parameter");
|
|
return false;
|
|
}
|
|
|
|
*value = android::base::GetProperty(key, "");
|
|
|
|
return value->size() > 0;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
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) {
|
|
if (!company_name) {
|
|
LOGW("Properties::GetCompanyName: Invalid parameter");
|
|
return false;
|
|
}
|
|
return GetAndroidProperty("ro.product.manufacturer", company_name);
|
|
}
|
|
|
|
bool Properties::GetModelName(std::string* model_name) {
|
|
if (!model_name) {
|
|
LOGW("Properties::GetModelName: Invalid parameter");
|
|
return false;
|
|
}
|
|
return GetAndroidProperty("ro.product.model", model_name);
|
|
}
|
|
|
|
bool Properties::GetArchitectureName(std::string* arch_name) {
|
|
if (!arch_name) {
|
|
LOGW("Properties::GetArchitectureName: Invalid parameter");
|
|
return false;
|
|
}
|
|
return GetAndroidProperty("ro.product.cpu.abi", arch_name);
|
|
}
|
|
|
|
bool Properties::GetDeviceName(std::string* device_name) {
|
|
if (!device_name) {
|
|
LOGW("Properties::GetDeviceName: Invalid parameter");
|
|
return false;
|
|
}
|
|
return GetAndroidProperty("ro.product.device", device_name);
|
|
}
|
|
|
|
bool Properties::GetProductName(std::string* product_name) {
|
|
if (!product_name) {
|
|
LOGW("Properties::GetProductName: Invalid parameter");
|
|
return false;
|
|
}
|
|
return GetAndroidProperty("ro.product.name", product_name);
|
|
}
|
|
|
|
bool Properties::GetBuildInfo(std::string* build_info) {
|
|
if (!build_info) {
|
|
LOGW("Properties::GetBuildInfo: Invalid parameter");
|
|
return false;
|
|
}
|
|
return GetAndroidProperty("ro.build.fingerprint", build_info);
|
|
}
|
|
|
|
bool Properties::GetOEMCryptoPath(std::string* library_name) {
|
|
if (!library_name) {
|
|
LOGW("Properties::GetOEMCryptoPath: Invalid parameter");
|
|
return false;
|
|
}
|
|
*library_name = "liboemcrypto.so";
|
|
return true;
|
|
}
|
|
|
|
} // namespace wvcdm
|