Merge "openSession_1_1 should return error for wrong security level" into rvc-dev am: fae5d3f7a9 am: a352d99c43 am: 3550602f92

Change-Id: I0d6d8c3f65d6fa3143bb28d58c9c170cdedea13d
This commit is contained in:
Automerger Merge Worker
2020-03-12 23:58:53 +00:00
2 changed files with 4 additions and 2 deletions

View File

@@ -333,13 +333,15 @@ Return<void> WVDrmPlugin::openSession_1_1(
status = openSessionCommon(sessionId); status = openSessionCommon(sessionId);
hidl_vec<uint8_t> hSessionId = toHidlVec(sessionId); hidl_vec<uint8_t> hSessionId = toHidlVec(sessionId);
if (Status::OK == status) { if (Status::OK == status) {
SecurityLevel currentSecurityLevel = SecurityLevel::UNKNOWN;
Return<void> hResult = getSecurityLevel(hSessionId, [&](Status status, SecurityLevel hSecurityLevel) { Return<void> hResult = getSecurityLevel(hSessionId, [&](Status status, SecurityLevel hSecurityLevel) {
currentSecurityLevel = hSecurityLevel;
if (Status::OK != status || requestedLevel != hSecurityLevel) { if (Status::OK != status || requestedLevel != hSecurityLevel) {
ALOGE("Failed to open session with the requested security level=%d", requestedLevel); ALOGE("Failed to open session with the requested security level=%d", requestedLevel);
if (Status::OK != closeSession(hSessionId)) sessionId.clear(); if (Status::OK != closeSession(hSessionId)) sessionId.clear();
} }
}); });
if (!hResult.isOk()) { if (!hResult.isOk() || (requestedLevel != currentSecurityLevel)) {
status = Status::ERROR_DRM_INVALID_STATE; status = Status::ERROR_DRM_INVALID_STATE;
} }
} }

View File

@@ -402,7 +402,7 @@ TEST_F(WVDrmPluginTest, OpensSessions_1_1) {
plugin.openSession_1_1(android::hardware::drm::V1_1::SecurityLevel::SW_SECURE_CRYPTO, plugin.openSession_1_1(android::hardware::drm::V1_1::SecurityLevel::SW_SECURE_CRYPTO,
[&](Status status, hidl_vec<uint8_t> hSessionId) { [&](Status status, hidl_vec<uint8_t> hSessionId) {
ASSERT_EQ(Status::OK, status); ASSERT_EQ(Status::ERROR_DRM_INVALID_STATE, status);
sessionId.clear(); sessionId.clear();
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size()); sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
}); });