Load keys before sending OnKeyStatusChange notifications

[ merge of http://go/wvgerrit/17454 ]

When processing a license or renewal, calls to Set/UpdateLicense
update the policy information. A side effect was introduced whereby
updating the policy may cause (expiration, session key state)
notifications to be sent to the listener. Due to the ordering,
the notifications would be sent before the keys were loaded/refreshed,
which caused issues when the notifications were immediately acted upon.
This has now been corrected.

b/27842970

Change-Id: Id81a71ff48edfa9ca0baafc43267995d5a3e80a6
This commit is contained in:
Rahul Frias
2016-04-07 15:58:45 -07:00
parent b76eccf32d
commit 7cb83eb02e
2 changed files with 62 additions and 5 deletions

View File

@@ -549,8 +549,6 @@ CdmResponseType CdmLicense::HandleKeyResponse(
server_url_ = license.policy().renewal_server_url();
}
policy_engine_->SetLicense(license);
if (license.policy().has_renew_with_client_id()) {
renew_with_client_id_ = license.policy().renew_with_client_id();
}
@@ -565,6 +563,7 @@ CdmResponseType CdmLicense::HandleKeyResponse(
it != key_array.end(); ++it) {
loaded_keys_.insert(it->key_id());
}
policy_engine_->SetLicense(license);
}
return resp;
}
@@ -626,8 +625,6 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
return LICENSE_ID_NOT_FOUND;
}
policy_engine_->UpdateLicense(license);
if (license.policy().has_renew_with_client_id()) {
renew_with_client_id_ = license.policy().renew_with_client_id();
}
@@ -651,6 +648,8 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
if (session_->RefreshKeys(signed_response.msg(), signed_response.signature(),
key_array.size(), &key_array[0])) {
policy_engine_->UpdateLicense(license);
return KEY_ADDED;
} else {
return REFRESH_KEYS_ERROR;