// 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 #include #include #include #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