From b77a30bf3d908323499703e66eb6d8e122c93503 Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Wed, 12 Jan 2022 16:15:05 -0800 Subject: [PATCH] Better error code checking for missing device ID. [ Merge of http://go/wvgerrit/143370 ] [ Cherry-pick off http://ag/16624952 ] Devices without a keybox may not have access to a device ID if the OEM uses the device ID from the keybox as its source of truth. For devices which have lost their keybox, OEMCrypto_GetDeviceID() was assumed to return ERROR_KEYBOX_INVALID if that was the case; however, Qualcomm's implementation was returning ERROR_NO_DEVICEID. Given that both error codes are appropriate, the CDM has been updated to accept both as an indication that the device ID cannot be retrieved, and that the null device ID should be returned. Bug: 190504842 Bug: 214113125 Test: Manual test Change-Id: I8fb8a1bddfe895062b707b51fcadffd983adb40e --- libwvdrmengine/cdm/core/src/crypto_session.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libwvdrmengine/cdm/core/src/crypto_session.cpp b/libwvdrmengine/cdm/core/src/crypto_session.cpp index 9442a5b7..937455fa 100644 --- a/libwvdrmengine/cdm/core/src/crypto_session.cpp +++ b/libwvdrmengine/cdm/core/src/crypto_session.cpp @@ -679,8 +679,14 @@ CdmResponseType CryptoSession::GetInternalDeviceUniqueId( const bool use_null_device_id = WithStaticFieldReadLock( "GetInternalDeviceUniqueId() use_null_device_id", [&] { if (requested_security_level_ != kLevelDefault) return false; - return sts == OEMCrypto_ERROR_KEYBOX_INVALID && - needs_keybox_provisioning_; + if (!needs_keybox_provisioning_) return false; + if (sts != OEMCrypto_ERROR_KEYBOX_INVALID && + sts != OEMCrypto_ERROR_NO_DEVICEID) { + // Logging other error for debugging, but null device + // ID should still be returned. + LOGE("Unexpected error: sts = %d", sts); + } + return true; }); if (use_null_device_id) { LOGD("Using null device ID");