Added debugOtaKeyboxFallbackDuration property.
[ Cherry-pick of http://ag/16064434 ] [ Merge of http://go/wvgerrit/136330 ] This changes adds a custom debug property for changing the fallback policy used for the system. Depending on the value set, the device will either use a "fast" fallback (30 seconds) or "default" fallback (~1 day with exponential backoff). Setting this property to either "fast" or "default" will end the current fallback if it has been triggered. Bug: 187646550 Test: Android unit tests Change-Id: I5271f96139c1e468242f7fa742668cc791ffcf91
This commit is contained in:
@@ -360,6 +360,16 @@ class CdmEngine {
|
||||
virtual void SetUserId(uint32_t user_id) { user_id_ = user_id; }
|
||||
virtual uint32_t GetUserId() const { return user_id_; }
|
||||
|
||||
// Changes the rules used for calculating the fallback duration
|
||||
// when OTA keybox provisioning fails.
|
||||
// Default rules use fallback duration measured in days, with exponential
|
||||
// backoff.
|
||||
// Fast rules use fallback durations of a few seconds, without exponential
|
||||
// backoff.
|
||||
// This method has no effect if OTA keybox is not required.
|
||||
virtual void SetDefaultOtaKeyboxFallbackDurationRules();
|
||||
virtual void SetFastOtaKeyboxFallbackDurationRules();
|
||||
|
||||
protected:
|
||||
friend class CdmEngineFactory;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "device_files.h"
|
||||
#include "file_store.h"
|
||||
#include "log.h"
|
||||
#include "okp_fallback_policy.h"
|
||||
#include "ota_keybox_provisioner.h"
|
||||
#include "properties.h"
|
||||
#include "string_conversions.h"
|
||||
@@ -2154,4 +2155,26 @@ void CdmEngine::OkpCleanUp() {
|
||||
}
|
||||
okp_provisioner_.reset();
|
||||
}
|
||||
|
||||
void CdmEngine::SetDefaultOtaKeyboxFallbackDurationRules() {
|
||||
OkpCheck();
|
||||
std::unique_lock<std::mutex> lock(okp_mutex_);
|
||||
auto* system_fallback_policy = CryptoSession::GetOkpFallbackPolicy();
|
||||
if (!system_fallback_policy) {
|
||||
LOGW("No system fallback policy available");
|
||||
return;
|
||||
}
|
||||
system_fallback_policy->SetDefaultBackoffDurationRules();
|
||||
}
|
||||
|
||||
void CdmEngine::SetFastOtaKeyboxFallbackDurationRules() {
|
||||
OkpCheck();
|
||||
std::unique_lock<std::mutex> lock(okp_mutex_);
|
||||
auto* system_fallback_policy = CryptoSession::GetOkpFallbackPolicy();
|
||||
if (!system_fallback_policy) {
|
||||
LOGW("No system fallback policy available");
|
||||
return;
|
||||
}
|
||||
system_fallback_policy->SetFastBackoffDurationRules();
|
||||
}
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -188,6 +188,9 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
||||
virtual CdmResponseType GetSessionUserId(const CdmSessionId& session_id,
|
||||
uint32_t* user_id);
|
||||
|
||||
virtual bool SetDefaultOtaKeyboxFallbackDurationRules();
|
||||
virtual bool SetFastOtaKeyboxFallbackDurationRules();
|
||||
|
||||
private:
|
||||
struct CdmInfo {
|
||||
CdmInfo();
|
||||
|
||||
@@ -645,4 +645,19 @@ CdmResponseType WvContentDecryptionModule::GetSessionUserId(
|
||||
*user_id = cdm_engine->GetUserId();
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool WvContentDecryptionModule::SetDefaultOtaKeyboxFallbackDurationRules() {
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(kDefaultCdmIdentifier);
|
||||
if (!cdm_engine) return false;
|
||||
cdm_engine->SetDefaultOtaKeyboxFallbackDurationRules();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WvContentDecryptionModule::SetFastOtaKeyboxFallbackDurationRules() {
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(kDefaultCdmIdentifier);
|
||||
if (!cdm_engine) return false;
|
||||
cdm_engine->SetFastOtaKeyboxFallbackDurationRules();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -689,6 +689,19 @@ status_t WVDrmPlugin::setPropertyString(const String8& name,
|
||||
return mapCdmResponseType(res);
|
||||
} else if (name == "decryptHashSessionId") {
|
||||
mDecryptHashSessionId = value.string();
|
||||
} else if (name == "debugOtaKeyboxFallbackDuration") {
|
||||
bool success = false;
|
||||
if (value == "default") {
|
||||
success = mCDM->SetDefaultOtaKeyboxFallbackDurationRules();
|
||||
} else if (value == "fast") {
|
||||
success = mCDM->SetFastOtaKeyboxFallbackDurationRules();
|
||||
} else {
|
||||
ALOGE("Unknown OTA fallback duration value %s", value.string());
|
||||
return android::BAD_VALUE;
|
||||
}
|
||||
if (!success) {
|
||||
return android::UNKNOWN_ERROR;
|
||||
}
|
||||
} else if (name == "atscMode") {
|
||||
if (value == kEnable) {
|
||||
mPropertySet.set_use_atsc_mode(true);
|
||||
|
||||
@@ -1470,6 +1470,19 @@ Return<Status> WVDrmPlugin::setPropertyString(const hidl_string& propertyName,
|
||||
ALOGE("App requested unknown ATSC mode %s", _value.c_str());
|
||||
return Status::BAD_VALUE;
|
||||
}
|
||||
} else if (name == "debugOtaKeyboxFallbackDuration") {
|
||||
bool success = false;
|
||||
if (value == "default") {
|
||||
success = mCDM->SetDefaultOtaKeyboxFallbackDurationRules();
|
||||
} else if (value == "fast") {
|
||||
success = mCDM->SetFastOtaKeyboxFallbackDurationRules();
|
||||
} else {
|
||||
ALOGE("Unknown OTA fallback duration value %s", _value.c_str());
|
||||
return Status::BAD_VALUE;
|
||||
}
|
||||
if (!success) {
|
||||
return Status::ERROR_DRM_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
ALOGE("App set unknown string property %s", name.c_str());
|
||||
return Status::ERROR_DRM_CANNOT_HANDLE;
|
||||
|
||||
Reference in New Issue
Block a user