Filter out key set IDs based on ATSC mode.
[ Merge of http://go/wvgerrit/187610 ] [ Partial cherry-pick of http://ag/25096961 ] Certain GTS tests do not fully consider restrictions on ATSC devices. In particular, GTS assumes if there are any key set IDs returned to the app via the MediaDrm API, then the device must already be provisioned. ATSC license are special in that they may be available, but the CDM is not provisioned while outside of ATCS mode. To work around this assumption made by GTS, we filter out ATSC licenses returned by getOfflineLicenseKeySetIds() when the device is not in ATSC mode, and filter out non-ATSC license when it is in ATSC mode. This is only a soft enforcement mechanism as calling the API with a valid ATSC license while outside ATSC mode (or a non-TSC license in ATSC mode) will continue to result in the failures experienced by certain OEMs. Bug: 301910628 Bug: 291181955 Bug: 296300842 Bug: 302612540 Test: MediaDrmParameterizedTests GTS on oriole Change-Id: Idb1853a7b7c93c7f22bc4db530ec26f20402dbb7
This commit is contained in:
@@ -160,6 +160,18 @@ bool isRootOrShell() {
|
||||
return (uid == AID_ROOT || uid == AID_SHELL);
|
||||
}
|
||||
|
||||
bool IsAtscKeySetId(const CdmKeySetId& keySetId) {
|
||||
if (keySetId.empty()) return false;
|
||||
// Pre-installed licenses might not perfectly match ATSC_KEY_SET_ID_PREFIX.
|
||||
// If "atsc" is in the license name, then it is safe to assume
|
||||
// it is an ATSC license.
|
||||
return keySetId.find("atsc") != std::string::npos ||
|
||||
keySetId.find("ATSC") != std::string::npos;
|
||||
}
|
||||
|
||||
bool IsNotAtscKeySetId(const CdmKeySetId& keySetId) {
|
||||
return !IsAtscKeySetId(keySetId);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
WVDrmPlugin::WVDrmPlugin(const android::sp<WvContentDecryptionModule>& cdm,
|
||||
@@ -947,39 +959,53 @@ Status WVDrmPlugin::unprovisionDevice() {
|
||||
|
||||
::ndk::ScopedAStatus WVDrmPlugin::getOfflineLicenseKeySetIds(
|
||||
vector<::aidl::android::hardware::drm::KeySetId>* _aidl_return) {
|
||||
vector<vector<uint8_t>> keySetIds;
|
||||
vector<KeySetId> keySetIdsVec;
|
||||
|
||||
_aidl_return->clear();
|
||||
CdmIdentifier identifier;
|
||||
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
const auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
|
||||
if (status != Status::OK) {
|
||||
*_aidl_return = keySetIdsVec;
|
||||
return toNdkScopedAStatus(status);
|
||||
}
|
||||
|
||||
vector<CdmSecurityLevel> levels = {wvcdm::kSecurityLevelL1,
|
||||
wvcdm::kSecurityLevelL3};
|
||||
const std::vector<CdmSecurityLevel> levels = {wvcdm::kSecurityLevelL1,
|
||||
wvcdm::kSecurityLevelL3};
|
||||
|
||||
std::vector<CdmKeySetId> allKeySetIds;
|
||||
CdmResponseType res(wvcdm::UNKNOWN_ERROR);
|
||||
|
||||
bool success = false;
|
||||
for (auto level : levels) {
|
||||
vector<CdmKeySetId> cdmKeySetIds;
|
||||
res = mCDM->ListStoredLicenses(level, identifier, &cdmKeySetIds);
|
||||
std::vector<CdmKeySetId> levelKeySetIds;
|
||||
res = mCDM->ListStoredLicenses(level, identifier, &levelKeySetIds);
|
||||
|
||||
if (isCdmResponseTypeSuccess(res)) {
|
||||
keySetIds.clear();
|
||||
for (auto id : cdmKeySetIds) {
|
||||
keySetIds.push_back(StrToVector(id));
|
||||
}
|
||||
KeySetId kid;
|
||||
for (auto id : keySetIds) {
|
||||
kid.keySetId = id;
|
||||
keySetIdsVec.push_back(kid);
|
||||
if (!isCdmResponseTypeSuccess(res)) continue;
|
||||
success = true;
|
||||
if (levelKeySetIds.empty()) continue;
|
||||
if (allKeySetIds.empty()) {
|
||||
allKeySetIds = std::move(levelKeySetIds);
|
||||
} else {
|
||||
allKeySetIds.reserve(allKeySetIds.size() + levelKeySetIds.size());
|
||||
for (CdmKeySetId& keySetId : levelKeySetIds) {
|
||||
allKeySetIds.push_back(std::move(keySetId));
|
||||
}
|
||||
}
|
||||
}
|
||||
*_aidl_return = keySetIdsVec;
|
||||
return toNdkScopedAStatus(mapCdmResponseType(res));
|
||||
|
||||
if (!success) {
|
||||
// Return whatever the last error was.
|
||||
return toNdkScopedAStatus(mapCdmResponseType(res));
|
||||
}
|
||||
|
||||
// Filter out key sets based on ATSC mode.
|
||||
const auto isAllowedKeySetId =
|
||||
mPropertySet.use_atsc_mode() ? IsAtscKeySetId : IsNotAtscKeySetId;
|
||||
std::vector<KeySetId> keySetIds;
|
||||
for (const CdmKeySetId& keySetId : allKeySetIds) {
|
||||
if (isAllowedKeySetId(keySetId)) {
|
||||
keySetIds.push_back(KeySetId{StrToVector(keySetId)});
|
||||
}
|
||||
}
|
||||
|
||||
*_aidl_return = std::move(keySetIds);
|
||||
return toNdkScopedAStatus(mapCdmResponseType(wvcdm::NO_ERROR));
|
||||
}
|
||||
|
||||
::ndk::ScopedAStatus WVDrmPlugin::getOfflineLicenseState(
|
||||
|
||||
Reference in New Issue
Block a user