43 lines
1.6 KiB
C++
43 lines
1.6 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 2019 Google LLC.
|
|
//
|
|
// This software is licensed under the terms defined in the Widevine Master
|
|
// License Agreement. For a copy of this agreement, please contact
|
|
// widevine-licensing@google.com.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Implements the device info helper function.
|
|
#include "common/device_info_util.h"
|
|
|
|
#include "absl/strings/ascii.h"
|
|
#include "protos/public/device_common.pb.h"
|
|
|
|
namespace widevine {
|
|
bool IsMatchedMakeModel(const std::string& expected_make,
|
|
const std::string& expected_model,
|
|
const std::string& make_from_client,
|
|
const std::string& model_from_client) {
|
|
return absl::AsciiStrToLower(expected_make) ==
|
|
absl::AsciiStrToLower(make_from_client) &&
|
|
absl::AsciiStrToLower(expected_model) ==
|
|
absl::AsciiStrToLower(model_from_client);
|
|
}
|
|
|
|
bool VerifyMakeModel(const ProvisionedDeviceInfo& device_info,
|
|
const std::string& make_from_client,
|
|
const std::string& model_from_client) {
|
|
if (IsMatchedMakeModel(device_info.manufacturer(), device_info.model(),
|
|
make_from_client, model_from_client)) {
|
|
return true;
|
|
}
|
|
for (DeviceModel product_info : device_info.model_info()) {
|
|
if (IsMatchedMakeModel(product_info.manufacturer(),
|
|
product_info.model_name(), make_from_client,
|
|
model_from_client)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
} // namespace widevine
|