am 5f227dd8: Avoid throwing exceptions when sessions are closed

* commit '5f227dd85d5407620cd68c17caae6e1949cd06c9':
  Avoid throwing exceptions when sessions are closed
This commit is contained in:
Rahul Frias
2015-05-22 22:23:41 +00:00
committed by Android Git Automerger
2 changed files with 15 additions and 2 deletions

View File

@@ -139,9 +139,9 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
status_t WVDrmPlugin::closeSession(const Vector<uint8_t>& sessionId) {
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
CdmResponseType res = mCDM->CloseSession(cdmSessionId);
mCDM->CloseSession(cdmSessionId);
mCryptoSessions.erase(cdmSessionId);
return mapAndNotifyOfCdmResponseType(sessionId, res);
return android::OK;
}
status_t WVDrmPlugin::getKeyRequest(

View File

@@ -220,6 +220,19 @@ TEST_F(WVDrmPluginTest, ClosesSessions) {
ASSERT_EQ(OK, res);
}
TEST_F(WVDrmPluginTest, ClosesSessionWithoutReturningError) {
StrictMock<MockCDM> cdm;
StrictMock<MockCrypto> crypto;
WVDrmPlugin plugin(&cdm, &crypto);
EXPECT_CALL(cdm, CloseSession(cdmSessionId))
.WillOnce(Return(SESSION_NOT_FOUND_1));
status_t res = plugin.closeSession(sessionId);
ASSERT_EQ(OK, res);
}
TEST_F(WVDrmPluginTest, GeneratesKeyRequests) {
StrictMock<MockCDM> cdm;
StrictMock<MockCrypto> crypto;