Source release 16.4.0

This commit is contained in:
John W. Bruce
2020-10-09 16:08:56 -07:00
parent 160df9f57a
commit 9d17a531ee
562 changed files with 52913 additions and 37426 deletions

View File

@@ -347,11 +347,6 @@ class CdmEngine {
protected:
friend class CdmEngineFactory;
friend class ParallelCdmTest;
friend class WvCdmEnginePreProvTest;
friend class WvCdmTestBase;
friend class WvGenericCryptoTest;
friend class TestLicenseHolder;
CdmEngine(FileSystem* file_system,
std::shared_ptr<metrics::EngineMetrics> metrics);

View File

@@ -239,6 +239,12 @@ class CdmSession {
// true otherwise.
bool VerifyOfflineUsageEntry();
// On android, we previously permitted a license to be loaded and restored
// in the same session. This method releases resources so that
// CdmSession::Init can safely be invoked before a new license is restored.
// TODO(b/161865160): Investigate whether we can dispense with this scenario.
virtual CdmResponseType ReleaseOfflineResources();
// These setters are for testing only. Takes ownership of the pointers.
void set_license_parser(CdmLicense* license_parser);
void set_crypto_session(CryptoSession* crypto_session);
@@ -294,6 +300,21 @@ class CdmSession {
// license type release and offline related information
CdmKeySetId key_set_id_;
// TODO(b/161865160): Use these variables to cache Init parameters. Remove
// when b/ has been addressed.
// |cdm_client_property_set_| and |event_listener_| point to a data
// member of WVDrmPlugin or WVDrmPlugin itself. It is safe for CdmSession
// to make use of these objects without taking ownership since WVDrmPlugin
// lifetime exceeds CdmSession (WVDrmPlugin indirectly owns CdmSession
// objects). These pointers if set, should be valid till CdmSession
// destruction.
CdmClientPropertySet* cdm_client_property_set_ = nullptr;
CdmSessionId* forced_session_id_ = nullptr;
CdmSessionId forced_session_id_value_;
WvCdmEventListener* event_listener_ = nullptr;
bool has_license_been_loaded_ = false;
bool has_license_been_restored_ = false;
bool mock_license_parser_in_use_;
bool mock_policy_engine_in_use_;

View File

@@ -58,9 +58,9 @@ class CdmLicense {
CdmSession* cdm_session, CdmKeyMessage* signed_request,
std::string* server_url);
virtual CdmResponseType HandleKeyResponse(
const CdmKeyResponse& license_response);
bool is_restore, const CdmKeyResponse& license_response);
virtual CdmResponseType HandleKeyUpdateResponse(
bool is_renewal, const CdmKeyResponse& license_response);
bool is_renewal, bool is_restore, const CdmKeyResponse& license_response);
virtual CdmResponseType HandleEmbeddedKeyData(
const InitializationData& init_data);
@@ -109,7 +109,7 @@ class CdmLicense {
video_widevine::LicenseRequest* license_request);
CdmResponseType HandleContentKeyResponse(
const std::string& msg, const std::string& core_message,
bool is_restore, const std::string& msg, const std::string& core_message,
const std::string& signature, const std::string& mac_key_iv,
const std::string& mac_key, const std::vector<CryptoKey>& key_array,
const video_widevine::License& license);
@@ -118,11 +118,16 @@ class CdmLicense {
// the crypto session. In addition, it also extracts content keys from
// |wrapped_keys_| and loads them for use.
CdmResponseType HandleEntitlementKeyResponse(
const std::string& msg, const std::string& core_message,
bool is_restore, const std::string& msg, const std::string& core_message,
const std::string& signature, const std::string& mac_key_iv,
const std::string& mac_key, const std::vector<CryptoKey>& key_array,
const video_widevine::License& license);
// Prepare to reload a key update message. Some special code is needed to work
// around b/166010609.
// TODO(b/166007195): Remove this.
CdmResponseType PrepareKeyUpdateReload(CdmSession* cdm_session);
CdmResponseType HandleNewEntitledKeys(
const std::vector<WidevinePsshData_EntitledKey>& wrapped_keys);

View File

@@ -56,10 +56,13 @@ class PolicyEngine {
// SetLicense is used in handling the initial license response. It stores
// an exact copy of the policy information stored in the license.
// The license state transitions to kLicenseStateCanPlay if the license
// permits playback.
// License state transitions and notifications may occur if
// |defer_license_state_update| is not set. If set, the license is likely
// being restored and transitions and notifications will be deferred until
// stored playback times are restored.
virtual void SetLicense(const video_widevine::License& license,
bool supports_core_messages);
bool supports_core_messages,
bool defer_license_state_update);
// Used to update the currently loaded entitled content keys.
virtual void SetEntitledLicenseKeys(
@@ -78,9 +81,17 @@ class PolicyEngine {
// UpdateLicense is used in handling a license response for a renewal request.
// The response may only contain any policy fields that have changed. In this
// case an exact copy is not what we want to happen. We also will receive an
// updated license_start_time from the server. The license will transition to
// kLicenseStateCanPlay if the license permits playback.
virtual void UpdateLicense(const video_widevine::License& license);
// updated license_start_time from the server.
// License state transitions and notifications may occur if
// |defer_license_state_update| is not set. If set, the license is likely
// being restored and transitions and notifications will be deferred until
// stored playback times are restored.
virtual void UpdateLicense(const video_widevine::License& license,
bool defer_license_state_update);
// This method updates license state and sends appropriate notifications
// to event listeners.
virtual void UpdateLicenseState(int64_t current_time);
// Used for notifying the Policy Engine of resolution changes
virtual void NotifyResolution(uint32_t width, uint32_t height);
@@ -101,6 +112,9 @@ class PolicyEngine {
int64_t GetPlaybackStartTime();
int64_t GetLastPlaybackTime();
int64_t GetGracePeriodEndTime();
// This method will also update license state and sends appropriate
// notifications to event listeners.
void RestorePlaybackTimes(int64_t playback_start_time,
int64_t last_playback_time,
int64_t grace_period_end_time);
@@ -153,6 +167,7 @@ class PolicyEngine {
void SetSecurityLevelForTest(CdmSecurityLevel security_level);
LicenseState license_state_;
int64_t license_state_update_deadline_;
// This is the license id field from server response. This data gets passed
// back to the server in each renewal request. When we get a renewal response

View File

@@ -84,6 +84,8 @@ class PolicyTimersV16 : public PolicyTimers {
return GetRentalDurationRemaining(current_time);
};
bool HasRenewalDelayExpired(int64_t current_time) override;
protected:
// Gets the clock time that the license expires based on whether we have
// started playing. This takes into account GetHardLicenseExpiryTime.

View File

@@ -34,7 +34,7 @@ using CdmProvisioningResponse = std::string;
using CdmUsageTableHeader = std::string;
using CdmUsageEntry = std::string;
enum CdmKeyRequestType {
enum CdmKeyRequestType : uint32_t {
kKeyRequestTypeUnknown,
kKeyRequestTypeInitial,
kKeyRequestTypeRenewal,
@@ -43,13 +43,13 @@ enum CdmKeyRequestType {
kKeyRequestTypeUpdate,
};
enum CdmOfflineLicenseState {
enum CdmOfflineLicenseState : int32_t {
kLicenseStateActive,
kLicenseStateReleasing,
kLicenseStateUnknown,
};
enum CdmResponseType {
enum CdmResponseType : int32_t {
NO_ERROR = 0,
UNKNOWN_ERROR = 1,
KEY_ADDED = 2,
@@ -414,13 +414,15 @@ enum CdmResponseType {
SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE = 359,
LICENSE_USAGE_ENTRY_MISSING = 360,
LOAD_USAGE_ENTRY_INVALID_SESSION = 361,
RESTORE_OFFLINE_LICENSE_ERROR_3 = 362,
NO_SRM_VERSION = 363,
// Don't forget to add new values to
// * core/test/test_printers.cpp.
// * android/include/mapErrors-inl.h
// * android/include_hidl/mapErrors-inl.h
};
enum CdmKeyStatus {
enum CdmKeyStatus : int32_t {
kKeyStatusKeyUnknown,
kKeyStatusUsable,
kKeyStatusExpired,
@@ -431,7 +433,7 @@ enum CdmKeyStatus {
};
using CdmKeyStatusMap = std::map<KeyId, CdmKeyStatus>;
enum CdmLicenseType {
enum CdmLicenseType : int32_t {
kLicenseTypeOffline,
kLicenseTypeStreaming,
kLicenseTypeRelease,
@@ -445,48 +447,51 @@ enum CdmLicenseType {
// on code review comments from go/wvgerrit/41860 this license type should not
// be added. This type can be removed once it is no longer needed by
// GenerateKeyRequest.
kLicenseTypeEmbeddedKeyData
kLicenseTypeEmbeddedKeyData,
};
enum CdmLicenseKeyType { kLicenseKeyTypeContent, kLicenseKeyTypeEntitlement };
enum CdmLicenseKeyType : int32_t {
kLicenseKeyTypeContent,
kLicenseKeyTypeEntitlement,
};
enum SecurityLevel { kLevelDefault, kLevel3 };
enum SecurityLevel : uint32_t { kLevelDefault, kLevel3 };
enum CdmSecurityLevel {
enum CdmSecurityLevel : int32_t {
kSecurityLevelUninitialized,
kSecurityLevelL1,
kSecurityLevelL2,
kSecurityLevelL3,
kSecurityLevelUnknown
kSecurityLevelUnknown,
};
enum CdmCertificateType {
enum CdmCertificateType : int32_t {
kCertificateWidevine,
kCertificateX509,
};
enum CdmHlsMethod {
enum CdmHlsMethod : int32_t {
kHlsMethodNone,
kHlsMethodAes128,
kHlsMethodSampleAes,
};
enum CdmCipherMode {
enum CdmCipherMode : int32_t {
kCipherModeCtr,
kCipherModeCbc,
};
enum CdmEncryptionAlgorithm {
enum CdmEncryptionAlgorithm : int32_t {
kEncryptionAlgorithmUnknown,
kEncryptionAlgorithmAesCbc128
kEncryptionAlgorithmAesCbc128,
};
enum CdmSigningAlgorithm {
enum CdmSigningAlgorithm : int32_t {
kSigningAlgorithmUnknown,
kSigningAlgorithmHmacSha256
kSigningAlgorithmHmacSha256,
};
enum CdmClientTokenType {
enum CdmClientTokenType : int32_t {
kClientTokenKeybox,
kClientTokenDrmCert,
kClientTokenOemCert,
@@ -499,13 +504,13 @@ enum CdmClientTokenType {
// persisted in non-secure storage but are loaded and unloaded from
// the TEE during use (OEMCrypto v13+)
// kUnknownUsageSupport - usage support type is uninitialized or unavailable
enum CdmUsageSupportType {
enum CdmUsageSupportType : int32_t {
kNonSecureUsageSupport,
kUsageEntrySupport,
kUnknownUsageSupport,
};
enum CdmUsageEntryStorageType {
enum CdmUsageEntryStorageType : int32_t {
kStorageLicense,
kStorageUsageInfo,
kStorageTypeUnknown,
@@ -545,7 +550,7 @@ struct CdmUsageEntryInfo {
}
};
enum CdmKeySecurityLevel {
enum CdmKeySecurityLevel : int32_t {
kKeySecurityLevelUnset,
kSoftwareSecureCrypto,
kSoftwareSecureDecode,