Squashed merge 3 CLs.
1. "Change CdmResponseType from enum into a struct" Merged from http://go/wvgerrit/163199 Bug: 253271674 2. "Log request information when server returns 401" Bug: 260760387 Bug: 186031735 Merged from http://go/wvgerrit/162798 3. "Specify server version on the command line" Bug: 251599048 Merged from http://go/wvgerrit/158897 Test: build android.hardware.drm-service.widevine Test: Netflix and Play Movies & TV Test: build_and_run_all_unit_tests.sh Bug: 253271674 Change-Id: I70c950acce070609ee0343920ec68e66b058bc23
This commit is contained in:
@@ -85,7 +85,7 @@ CdmResponseType WvContentDecryptionModule::CloseSession(
|
||||
LOGV("Closing session ID: %s", session_id.c_str());
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
// TODO(rfrias): Avoid reusing the error codes from CdmEngine.
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_1;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_1);
|
||||
const CdmResponseType sts = cdm_engine->CloseSession(session_id);
|
||||
if (sts == NO_ERROR) {
|
||||
std::unique_lock<std::mutex> auto_lock(cdms_lock_);
|
||||
@@ -145,7 +145,7 @@ CdmResponseType WvContentDecryptionModule::AddKey(
|
||||
CdmKeySetId* key_set_id) {
|
||||
CdmEngine* cdm_engine = session_id.empty() ? GetCdmForSessionId(*key_set_id)
|
||||
: GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_3;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_3);
|
||||
// Save key_set_id, as CDM will return an empty key_set_id on release
|
||||
CdmKeySetId release_key_set_id;
|
||||
if (session_id.empty() && key_set_id != nullptr) {
|
||||
@@ -166,7 +166,7 @@ CdmResponseType WvContentDecryptionModule::AddKey(
|
||||
CdmResponseType WvContentDecryptionModule::RestoreKey(
|
||||
const CdmSessionId& session_id, const CdmKeySetId& key_set_id) {
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_4;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_4);
|
||||
CdmResponseType sts;
|
||||
sts = cdm_engine->RestoreKey(session_id, key_set_id);
|
||||
return sts;
|
||||
@@ -175,7 +175,7 @@ CdmResponseType WvContentDecryptionModule::RestoreKey(
|
||||
CdmResponseType WvContentDecryptionModule::RemoveKeys(
|
||||
const CdmSessionId& session_id) {
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_5;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_5);
|
||||
CdmResponseType sts = cdm_engine->RemoveKeys(session_id);
|
||||
return sts;
|
||||
}
|
||||
@@ -190,14 +190,14 @@ CdmResponseType WvContentDecryptionModule::QueryStatus(
|
||||
CdmResponseType WvContentDecryptionModule::QuerySessionStatus(
|
||||
const CdmSessionId& session_id, CdmQueryMap* key_info) {
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_8;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_8);
|
||||
return cdm_engine->QuerySessionStatus(session_id, key_info);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::QueryKeyStatus(
|
||||
const CdmSessionId& session_id, CdmQueryMap* key_info) {
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_9;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_9);
|
||||
CdmResponseType sts;
|
||||
sts = cdm_engine->QueryKeyStatus(session_id, key_info);
|
||||
return sts;
|
||||
@@ -206,7 +206,7 @@ CdmResponseType WvContentDecryptionModule::QueryKeyStatus(
|
||||
CdmResponseType WvContentDecryptionModule::QueryOemCryptoSessionId(
|
||||
const CdmSessionId& session_id, CdmQueryMap* response) {
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_10;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_10);
|
||||
return cdm_engine->QueryOemCryptoSessionId(session_id, response);
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ CdmResponseType WvContentDecryptionModule::GetSecureStopIds(
|
||||
std::vector<CdmSecureStopId>* ssids) {
|
||||
if (ssids == nullptr) {
|
||||
LOGE("Secure stop IDs destination not provided");
|
||||
return PARAMETER_NULL;
|
||||
return CdmResponseType(PARAMETER_NULL);
|
||||
}
|
||||
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(identifier);
|
||||
@@ -328,7 +328,7 @@ CdmResponseType WvContentDecryptionModule::DecryptV16(
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) {
|
||||
LOGE("Decrypt session ID not found: %s", session_id.c_str());
|
||||
return SESSION_NOT_FOUND_18;
|
||||
return CdmResponseType(SESSION_NOT_FOUND_18);
|
||||
}
|
||||
|
||||
CdmSessionId local_session_id = session_id;
|
||||
@@ -362,7 +362,7 @@ CdmResponseType WvContentDecryptionModule::DecryptV16(
|
||||
OEMCrypto_FirstSubsample &&
|
||||
parameters.samples[0].subsamples[0].flags &
|
||||
OEMCrypto_LastSubsample))) {
|
||||
return KEY_NOT_FOUND_IN_SESSION;
|
||||
return CdmResponseType(KEY_NOT_FOUND_IN_SESSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,7 +388,7 @@ bool WvContentDecryptionModule::IsValidServiceCertificate(
|
||||
CdmResponseType WvContentDecryptionModule::GetMetrics(
|
||||
std::vector<drm_metrics::WvCdmMetrics>* metrics, bool* full_list_returned) {
|
||||
if (!metrics || !full_list_returned) {
|
||||
return PARAMETER_NULL;
|
||||
return CdmResponseType(PARAMETER_NULL);
|
||||
}
|
||||
std::unique_lock<std::mutex> auto_lock(cdms_lock_);
|
||||
for (auto& key_value_pair : cdms_) {
|
||||
@@ -399,7 +399,7 @@ CdmResponseType WvContentDecryptionModule::GetMetrics(
|
||||
metrics->push_back(metric);
|
||||
} else {
|
||||
LOGD("GetMetrics call failed: cdm identifier=%u, error=%d",
|
||||
identifier.unique_id, status);
|
||||
identifier.unique_id, status.Enum());
|
||||
}
|
||||
}
|
||||
// With no streaming activities, |cdms_| size would be zero,
|
||||
@@ -410,13 +410,14 @@ CdmResponseType WvContentDecryptionModule::GetMetrics(
|
||||
// - metrics && cdms_ sizes can both be zero, returns NO_ERROR
|
||||
// - metrics size <= cdms_, returns NO_ERROR
|
||||
// - metrics is empty, but cdms_ is not, returns UNKNOWN_ERROR
|
||||
return (metrics->empty() && !cdms_.empty()) ? UNKNOWN_ERROR : NO_ERROR;
|
||||
return (metrics->empty() && !cdms_.empty()) ? CdmResponseType(UNKNOWN_ERROR)
|
||||
: CdmResponseType(NO_ERROR);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GetMetrics(
|
||||
const CdmIdentifier& identifier, drm_metrics::WvCdmMetrics* metrics) {
|
||||
if (!metrics) {
|
||||
return PARAMETER_NULL;
|
||||
return CdmResponseType(PARAMETER_NULL);
|
||||
}
|
||||
std::unique_lock<std::mutex> auto_lock(cdms_lock_);
|
||||
return GetMetricsInternal(identifier, metrics);
|
||||
@@ -429,10 +430,11 @@ CdmResponseType WvContentDecryptionModule::GetMetricsInternal(
|
||||
if (it == cdms_.end()) {
|
||||
LOGE("Cdm Identifier not found");
|
||||
// TODO(blueeyes): Add a better error.
|
||||
return UNKNOWN_ERROR;
|
||||
return CdmResponseType(UNKNOWN_ERROR);
|
||||
}
|
||||
return it->second.cdm_engine->GetMetricsSnapshot(metrics) ? NO_ERROR
|
||||
: UNKNOWN_ERROR;
|
||||
return it->second.cdm_engine->GetMetricsSnapshot(metrics)
|
||||
? CdmResponseType(NO_ERROR)
|
||||
: CdmResponseType(UNKNOWN_ERROR);
|
||||
}
|
||||
|
||||
WvContentDecryptionModule::CdmInfo::CdmInfo()
|
||||
@@ -489,7 +491,7 @@ CdmResponseType WvContentDecryptionModule::CloseCdm(
|
||||
if (it == cdms_.end()) {
|
||||
LOGE("Cdm Identifier not found");
|
||||
// TODO(blueeyes): Create a better error.
|
||||
return UNKNOWN_ERROR;
|
||||
return CdmResponseType(UNKNOWN_ERROR);
|
||||
}
|
||||
// Remove any sessions that point to this engine.
|
||||
for (auto session_it = cdm_by_session_id_.begin();
|
||||
@@ -501,7 +503,7 @@ CdmResponseType WvContentDecryptionModule::CloseCdm(
|
||||
}
|
||||
}
|
||||
cdms_.erase(it);
|
||||
return NO_ERROR;
|
||||
return CdmResponseType(NO_ERROR);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::SetDebugIgnoreKeyboxCount(
|
||||
@@ -517,7 +519,7 @@ CdmResponseType WvContentDecryptionModule::SetDecryptHash(
|
||||
const std::string& hash_data, CdmSessionId* id) {
|
||||
if (id == nullptr) {
|
||||
LOGE("Cdm session ID not provided");
|
||||
return PARAMETER_NULL;
|
||||
return CdmResponseType(PARAMETER_NULL);
|
||||
}
|
||||
|
||||
uint32_t frame_number;
|
||||
@@ -531,7 +533,7 @@ CdmResponseType WvContentDecryptionModule::SetDecryptHash(
|
||||
|
||||
if (!cdm_engine) {
|
||||
LOGE("Unable to find CdmEngine");
|
||||
return SESSION_NOT_FOUND_20;
|
||||
return CdmResponseType(SESSION_NOT_FOUND_20);
|
||||
}
|
||||
|
||||
res = cdm_engine->SetDecryptHash(*id, frame_number, hash);
|
||||
@@ -544,7 +546,7 @@ CdmResponseType WvContentDecryptionModule::GetDecryptHashError(
|
||||
|
||||
if (!cdm_engine) {
|
||||
LOGE("Unable to find CdmEngine");
|
||||
return SESSION_NOT_FOUND_20;
|
||||
return CdmResponseType(SESSION_NOT_FOUND_20);
|
||||
}
|
||||
return cdm_engine->GetDecryptHashError(session_id, hash_error_string);
|
||||
}
|
||||
@@ -641,17 +643,17 @@ CdmResponseType WvContentDecryptionModule::SetPlaybackId(
|
||||
LOGV("Setting session ID %s playback ID %s", session_id.c_str(),
|
||||
playback_id.c_str());
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_23;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_23);
|
||||
return cdm_engine->SetPlaybackId(session_id, playback_id);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GetSessionUserId(
|
||||
const CdmSessionId& session_id, uint32_t* user_id) {
|
||||
if (!user_id) return PARAMETER_NULL;
|
||||
if (!user_id) return CdmResponseType(PARAMETER_NULL);
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (!cdm_engine) return SESSION_NOT_FOUND_23;
|
||||
if (!cdm_engine) return CdmResponseType(SESSION_NOT_FOUND_23);
|
||||
*user_id = cdm_engine->GetUserId();
|
||||
return NO_ERROR;
|
||||
return CdmResponseType(NO_ERROR);
|
||||
}
|
||||
|
||||
bool WvContentDecryptionModule::SetDefaultOtaKeyboxFallbackDurationRules() {
|
||||
|
||||
Reference in New Issue
Block a user