Prevent renewal license when can_renew is set to false
[ Merge of https://go/wvgerrit/15670 ] b/18459002 Change-Id: Idad43a621750ff01aee61e8d972957f364a698cf
This commit is contained in:
@@ -80,6 +80,8 @@ class PolicyEngine {
|
|||||||
|
|
||||||
bool IsLicenseOrPlaybackDurationExpired(int64_t current_time);
|
bool IsLicenseOrPlaybackDurationExpired(int64_t current_time);
|
||||||
|
|
||||||
|
bool CanRenew() { return policy_.can_renew(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class PolicyEngineTest;
|
friend class PolicyEngineTest;
|
||||||
|
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ enum CdmResponseType {
|
|||||||
LICENSE_REQUEST_SIGNING_ERROR,
|
LICENSE_REQUEST_SIGNING_ERROR,
|
||||||
EMPTY_LICENSE_REQUEST,
|
EMPTY_LICENSE_REQUEST,
|
||||||
SECURE_BUFFER_REQUIRED,
|
SECURE_BUFFER_REQUIRED,
|
||||||
|
LICENSE_RENEWAL_PROHIBITED,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CdmKeyStatus {
|
enum CdmKeyStatus {
|
||||||
|
|||||||
@@ -319,6 +319,11 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
|||||||
return INVALID_PARAMETERS_LIC_2;
|
return INVALID_PARAMETERS_LIC_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_renewal && !policy_engine_->CanRenew()) {
|
||||||
|
LOGE("CdmLicense::PrepareKeyUpdateRequest: license renewal prohibited");
|
||||||
|
return LICENSE_RENEWAL_PROHIBITED;
|
||||||
|
}
|
||||||
|
|
||||||
LicenseRequest license_request;
|
LicenseRequest license_request;
|
||||||
if (is_renewal)
|
if (is_renewal)
|
||||||
license_request.set_type(LicenseRequest::RENEWAL);
|
license_request.set_type(LicenseRequest::RENEWAL);
|
||||||
|
|||||||
@@ -339,6 +339,8 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
|||||||
break;
|
break;
|
||||||
case EMPTY_LICENSE_REQUEST: *os << "EMPTY_LICENSE_REQUEST";
|
case EMPTY_LICENSE_REQUEST: *os << "EMPTY_LICENSE_REQUEST";
|
||||||
break;
|
break;
|
||||||
|
case LICENSE_RENEWAL_PROHIBITED: *os << "LICENSE_RENEWAL_PROHIBITED";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
*os << "Unknown CdmResponseType";
|
*os << "Unknown CdmResponseType";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1380,6 +1380,28 @@ TEST_F(WvCdmRequestLicenseTest, StreamingLicenseRenewal) {
|
|||||||
decryptor_.CloseSession(session_id_);
|
decryptor_.CloseSession(session_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WvCdmRequestLicenseTest, StreamingLicenseRenewalProhibited) {
|
||||||
|
decryptor_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL, &session_id_);
|
||||||
|
std::string key_id = a2bs_hex( // streaming_clip11
|
||||||
|
"000000427073736800000000" // blob size and pssh
|
||||||
|
"EDEF8BA979D64ACEA3C827DCD51D21ED00000023" // Widevine system id
|
||||||
|
"08011a0d7769646576696e655f746573" // pssh data
|
||||||
|
"74221073747265616d696e675f636c69703131");
|
||||||
|
GenerateKeyRequest(key_id, kLicenseTypeStreaming);
|
||||||
|
VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
|
||||||
|
|
||||||
|
std::string license_server;
|
||||||
|
std::string init_data;
|
||||||
|
wvcdm::CdmAppParameterMap app_parameters;
|
||||||
|
wvcdm::CdmKeyRequestType key_request_type;
|
||||||
|
EXPECT_EQ(wvcdm::LICENSE_RENEWAL_PROHIBITED,
|
||||||
|
decryptor_.GenerateKeyRequest(
|
||||||
|
session_id_, key_set_id_, "video/mp4", init_data,
|
||||||
|
kLicenseTypeStreaming, app_parameters, NULL, EMPTY_ORIGIN,
|
||||||
|
&key_msg_, &key_request_type, &license_server));
|
||||||
|
decryptor_.CloseSession(session_id_);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(WvCdmRequestLicenseTest, OfflineLicenseRenewal) {
|
TEST_F(WvCdmRequestLicenseTest, OfflineLicenseRenewal) {
|
||||||
// override default settings unless configured through the command line
|
// override default settings unless configured through the command line
|
||||||
std::string key_id;
|
std::string key_id;
|
||||||
|
|||||||
@@ -176,7 +176,8 @@ enum {
|
|||||||
kLicenseRequestNonceGenerationError = ERROR_DRM_VENDOR_MIN + 161,
|
kLicenseRequestNonceGenerationError = ERROR_DRM_VENDOR_MIN + 161,
|
||||||
kLicenseRequestSigningError = ERROR_DRM_VENDOR_MIN + 162,
|
kLicenseRequestSigningError = ERROR_DRM_VENDOR_MIN + 162,
|
||||||
kEmptyLicenseRequest = ERROR_DRM_VENDOR_MIN + 163,
|
kEmptyLicenseRequest = ERROR_DRM_VENDOR_MIN + 163,
|
||||||
kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 163,
|
kLicenseRenewalProhibited = ERROR_DRM_VENDOR_MIN + 165,
|
||||||
|
kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 165,
|
||||||
|
|
||||||
// Used by crypto test mode
|
// Used by crypto test mode
|
||||||
kErrorTestMode = ERROR_DRM_VENDOR_MAX,
|
kErrorTestMode = ERROR_DRM_VENDOR_MAX,
|
||||||
|
|||||||
@@ -341,6 +341,8 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
|
|||||||
return kLicenseRequestSigningError;
|
return kLicenseRequestSigningError;
|
||||||
case wvcdm::EMPTY_LICENSE_REQUEST:
|
case wvcdm::EMPTY_LICENSE_REQUEST:
|
||||||
return kEmptyLicenseRequest;
|
return kEmptyLicenseRequest;
|
||||||
|
case wvcdm::LICENSE_RENEWAL_PROHIBITED:
|
||||||
|
return kLicenseRenewalProhibited;
|
||||||
case wvcdm::UNKNOWN_ERROR:
|
case wvcdm::UNKNOWN_ERROR:
|
||||||
return android::ERROR_DRM_UNKNOWN;
|
return android::ERROR_DRM_UNKNOWN;
|
||||||
case wvcdm::UNUSED_1:
|
case wvcdm::UNUSED_1:
|
||||||
|
|||||||
Reference in New Issue
Block a user