Files
ce_cdm/factory_upload_tool/ce/properties_ce.cpp
John "Juce" Bruce f11df1e144 Source release 17.1.1
2022-11-29 12:54:04 -08:00

88 lines
2.2 KiB
C++

// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
#include "properties_ce.h"
#include "log.h"
#include "properties.h"
#include "wv_factory_extractor.h"
// This anonymous namespace is shared between both the widevine namespace and
// wvcdm namespace objects below.
namespace {
widevine::ClientInfo client_info_;
bool GetValue(const std::string& source, std::string* output) {
if (!output) {
LOGE("Null output");
return false;
}
*output = source;
return source.size() != 0;
}
} // namespace
namespace widevine {
// static
bool PropertiesCE::SetClientInfo(const ClientInfo& client_info) {
if (client_info.product_name.empty() || client_info.company_name.empty() ||
client_info.device_name.empty() || client_info.model_name.empty() ||
client_info.arch_name.empty() || client_info.build_info.empty()) {
return false;
}
client_info_ = client_info;
return true;
}
// static
ClientInfo PropertiesCE::GetClientInfo() { return client_info_; }
} // namespace widevine
namespace wvcdm {
// static
bool Properties::GetCompanyName(std::string* company_name) {
return GetValue(client_info_.company_name, company_name);
}
// static
bool Properties::GetModelName(std::string* model_name) {
return GetValue(client_info_.model_name, model_name);
}
// static
bool Properties::GetArchitectureName(std::string* arch_name) {
return GetValue(client_info_.arch_name, arch_name);
}
// static
bool Properties::GetDeviceName(std::string* device_name) {
return GetValue(client_info_.device_name, device_name);
}
// static
bool Properties::GetProductName(std::string* product_name) {
return GetValue(client_info_.product_name, product_name);
}
// static
bool Properties::GetBuildInfo(std::string* build_info) {
return GetValue(client_info_.build_info, build_info);
}
// static
bool Properties::GetOEMCryptoPath(std::string* path) {
if (path == nullptr) return false;
// Using an environment variable is useful for testing.
const char* env_path = getenv("LIBOEMCRYPTO_PATH");
if (env_path) {
*path = std::string(env_path);
} else {
*path = "liboemcrypto.so";
}
return true;
}
} // namespace wvcdm