Added state to CertificateProvisioning.
[ Cherry-pick of v19 http://go/wvgerrit/219310 ] [ Merge of http://go/wvgerrit/219453 ] To enable the CDM to determine between OEM vs DRM responses, a state variable was needed in CertificateProvisioning. Previously, the presence/absence of the OEM certificate in the file system was used; however, if two apps (or single app with multiple origins) attempts provisioning simultaneously, the later response would trigger unexpected failures. The main functional changes this provides is that a more informative error will be returned to the app if they provide a provisioning response without ever creating a provisioning request; and that if multiple clients attempted first-stage provisioning simultaneously, fewer errors will occur. Bug: 391469176 Test: run_prov40_tests Change-Id: I51a118ce73aa809bad6ecee640139a92d8518575
This commit is contained in:
@@ -72,6 +72,28 @@ class CertificateProvisioning {
|
||||
// |default_url| by GetProvisioningRequest().
|
||||
static void GetProvisioningServerUrl(std::string* default_url);
|
||||
|
||||
enum State {
|
||||
// Freshly created, not yet initialized.
|
||||
kUninitialized,
|
||||
// A successful call to Init() has been made.
|
||||
kInitialized,
|
||||
// Has generated a DRM request; apps are allowed generate
|
||||
// another one even if a response has not been received.
|
||||
kDrmRequestSent,
|
||||
// Has received (and successfully loaded) a DRM response.
|
||||
kDrmResponseReceived,
|
||||
// Has generated an OEM (Prov 4.0) request; apps are allowed
|
||||
// generate another one even if a response has not been
|
||||
// received.
|
||||
kOemRequestSent,
|
||||
// Has received (and successfully loaded) an OEM response.
|
||||
kOemResponseReceived,
|
||||
};
|
||||
static const char* StateToString(State state);
|
||||
|
||||
// State setter for testing only.
|
||||
void SetStateForTesting(State state) { state_ = state; }
|
||||
|
||||
private:
|
||||
#if defined(UNIT_TEST)
|
||||
friend class CertificateProvisioningTest;
|
||||
@@ -122,6 +144,9 @@ class CertificateProvisioning {
|
||||
CdmResponseType CloseSessionOnError(CdmResponseType status);
|
||||
void CloseSession();
|
||||
|
||||
// Tracks the state of CertificateProvisioning.
|
||||
State state_ = kUninitialized;
|
||||
|
||||
std::unique_ptr<CryptoSession> crypto_session_;
|
||||
CdmCertificateType cert_type_;
|
||||
std::unique_ptr<ServiceCertificate> service_certificate_;
|
||||
|
||||
@@ -465,6 +465,7 @@ enum CdmResponseEnum : int32_t {
|
||||
GET_DEVICE_INFORMATION_ERROR = 398,
|
||||
GET_DEVICE_SIGNED_CSR_PAYLOAD_ERROR = 399,
|
||||
GET_TOKEN_FROM_EMBEDDED_CERT_ERROR = 400,
|
||||
PROVISIONING_UNEXPECTED_RESPONSE_ERROR = 402,
|
||||
// Don't forget to add new values to
|
||||
// * core/src/wv_cdm_types.cpp
|
||||
// * android/include/mapErrors-inl.h
|
||||
|
||||
Reference in New Issue
Block a user