Add Property to Access System ID
Adds a new property to the CDM's QueryStatus called QUERY_KEY_SYSTEM_ID that contains the System ID. (as read from OEMCrypto_GetKeyData) Adds a new property to the DrmPlugin (cleverly named "systemId") that allows the app to query for this. Also adds unit tests. Also changes the Device ID getter in crypto_engine.cpp to return a failure instead of an empty ID. Bug: 8621632 Merge of https://widevine-internal-review.googlesource.com/#/c/5010/ from widevine cdm repository to android repository. Change-Id: I8f309af18487c499e8ce25e829059e45623ea4dc
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "cdm_engine.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "buffer_reader.h"
|
||||
#include "cdm_session.h"
|
||||
@@ -315,7 +316,19 @@ CdmResponseType CdmEngine::QueryStatus(CdmQueryMap* key_info) {
|
||||
return KEY_ERROR;
|
||||
}
|
||||
|
||||
(*key_info)[QUERY_KEY_DEVICE_ID] = crypto_engine->GetDeviceUniqueId();
|
||||
std::string deviceId;
|
||||
bool success = crypto_engine->GetDeviceUniqueId(&deviceId);
|
||||
if (success) {
|
||||
(*key_info)[QUERY_KEY_DEVICE_ID] = deviceId;
|
||||
}
|
||||
|
||||
uint32_t system_id;
|
||||
success = crypto_engine->GetSystemId(&system_id);
|
||||
if (success) {
|
||||
std::ostringstream system_id_stream;
|
||||
system_id_stream << system_id;
|
||||
(*key_info)[QUERY_KEY_SYSTEM_ID] = system_id_stream.str();
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "crypto_engine.h"
|
||||
|
||||
#include <arpa/inet.h> // TODO(fredgc): Add ntoh to wv_cdm_utilities.h
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
@@ -195,7 +196,7 @@ CryptoEngine::SecurityLevel CryptoEngine::GetSecurityLevel() {
|
||||
return kSecurityLevelUnknown;
|
||||
}
|
||||
|
||||
std::string CryptoEngine::GetDeviceUniqueId() {
|
||||
bool CryptoEngine::GetDeviceUniqueId(std::string* deviceId) {
|
||||
std::vector<uint8_t> id;
|
||||
size_t idLength = 32;
|
||||
|
||||
@@ -204,10 +205,29 @@ std::string CryptoEngine::GetDeviceUniqueId() {
|
||||
OEMCryptoResult sts = OEMCrypto_GetDeviceID(&id[0], &idLength);
|
||||
|
||||
if (OEMCrypto_SUCCESS != sts) {
|
||||
return std::string();
|
||||
return false;
|
||||
}
|
||||
|
||||
return std::string(reinterpret_cast<const char*>(&id[0]));
|
||||
*deviceId = reinterpret_cast<const char*>(&id[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CryptoEngine::GetSystemId(uint32_t* systemId) {
|
||||
uint8_t buf[72];
|
||||
size_t buflen = 72;
|
||||
|
||||
OEMCryptoResult sts = OEMCrypto_GetKeyData(buf, &buflen);
|
||||
|
||||
if (OEMCrypto_SUCCESS != sts) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decode 32-bit int encoded as network-byte-order byte array starting at
|
||||
// index 4.
|
||||
uint32_t* id = reinterpret_cast<uint32_t*>(&buf[4]);
|
||||
|
||||
*systemId = ntohl(*id);
|
||||
return true;
|
||||
}
|
||||
|
||||
}; // namespace wvcdm
|
||||
|
||||
@@ -154,8 +154,11 @@ bool CdmLicense::PrepareKeyRequest(const CdmInitData& init_data,
|
||||
client_info->set_value(value);
|
||||
}
|
||||
|
||||
client_info->set_name(kDeviceIdKey);
|
||||
client_info->set_value(CryptoEngine::GetInstance()->GetDeviceUniqueId());
|
||||
if (CryptoEngine::GetInstance()->GetDeviceUniqueId(&value)) {
|
||||
client_info = client_id->add_client_info();
|
||||
client_info->set_name(kDeviceIdKey);
|
||||
client_info->set_value(value);
|
||||
}
|
||||
|
||||
// Content Identification may be a cenc_id, a webm_id or a license_id
|
||||
LicenseRequest_ContentIdentification* content_id =
|
||||
|
||||
Reference in New Issue
Block a user