This HAL implementation should be included in the factory image only. BUG: 213415013 Test: manual Change-Id: Icc0cc7f767a647238ce319623e0408ec22531f58
94 lines
2.3 KiB
C++
94 lines
2.3 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::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
|