Added metrics for production readiness.

[ Merge of http://go/wvgerrit/151749 ]

Extended CryptoSession for recording the result of
OEMCrypto_ProductionReady().

Only OEMCrypto_SUCCESS is considered "production ready".  With the
exception of OEMCrypto_ERROR_NOT_IMPLEMENTED, any other result is
vendor-specific and indicates not being production ready.

Bug: 231655151
Test: metrics_collections_unittest
Change-Id: Ia0e5603d7ee1290238cce63d0194ae1aced424c1
This commit is contained in:
Alex Dale
2022-05-10 17:59:25 -07:00
parent f8146ee716
commit 88a7ff7685
5 changed files with 12 additions and 1 deletions

View File

@@ -2358,6 +2358,7 @@ bool CryptoSession::GetProductionReadiness(
const OEMCryptoResult result = WithOecReadLock("GetProductionReadiness", [&] {
return OEMCrypto_ProductionReady(security_level);
});
metrics_->oemcrypto_production_readiness_.Record(result);
switch (result) {
case OEMCrypto_SUCCESS:
*readiness = kProductionReadinessTrue;
@@ -2367,6 +2368,9 @@ bool CryptoSession::GetProductionReadiness(
break;
case OEMCrypto_ERROR_UNKNOWN_FAILURE:
default: // Other vendor-defined codes indicate not production ready.
LOGD("Not production ready: security_level = %s, result = %d",
RequestedSecurityLevelToString(security_level),
static_cast<int>(result));
*readiness = kProductionReadinessFalse;
break;
}