Source release 19.4.0
This commit is contained in:
@@ -73,6 +73,76 @@ int32_t JsmnAncestorCount(const std::vector<jsmntok_t>& tokens,
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
const char* BoolName(bool value) { return value ? "true" : "false"; }
|
||||
const char* SecurityLevelName(OEMCrypto_Security_Level value) {
|
||||
switch (value) {
|
||||
case OEMCrypto_Level_Unknown:
|
||||
return "OEMCrypto_Level_Unknown";
|
||||
case OEMCrypto_Level1:
|
||||
return "OEMCrypto_Level1";
|
||||
case OEMCrypto_Level2:
|
||||
return "OEMCrypto_Level2";
|
||||
case OEMCrypto_Level3:
|
||||
return "OEMCrypto_Level3";
|
||||
}
|
||||
// Not reachable unless the enum value is invalid
|
||||
return "<INVALID VALUE>";
|
||||
}
|
||||
const char* HDCPCapabilityName(OEMCrypto_HDCP_Capability value) {
|
||||
switch (value) {
|
||||
case HDCP_NONE:
|
||||
return "HDCP_NONE";
|
||||
case HDCP_V1:
|
||||
return "HDCP_V1";
|
||||
case HDCP_V1_0:
|
||||
return "HDCP_V1_0";
|
||||
case HDCP_V1_1:
|
||||
return "HDCP_V1_1";
|
||||
case HDCP_V1_2:
|
||||
return "HDCP_V1_2";
|
||||
case HDCP_V1_3:
|
||||
return "HDCP_V1_3";
|
||||
case HDCP_V1_4:
|
||||
return "HDCP_V1_4";
|
||||
case HDCP_V2:
|
||||
return "HDCP_V2";
|
||||
case HDCP_V2_1:
|
||||
return "HDCP_V2_1";
|
||||
case HDCP_V2_2:
|
||||
return "HDCP_V2_2";
|
||||
case HDCP_V2_3:
|
||||
return "HDCP_V2_3";
|
||||
case HDCP_NO_DIGITAL_OUTPUT:
|
||||
return "HDCP_NO_DIGITAL_OUTPUT";
|
||||
}
|
||||
// Not reachable unless the enum value is invalid
|
||||
return "<INVALID VALUE>";
|
||||
}
|
||||
const char* WatermarkingSupportName(OEMCrypto_WatermarkingSupport value) {
|
||||
switch (value) {
|
||||
case OEMCrypto_WatermarkingError:
|
||||
return "OEMCrypto_WatermarkingError";
|
||||
case OEMCrypto_WatermarkingNotSupported:
|
||||
return "OEMCrypto_WatermarkingNotSupported";
|
||||
case OEMCrypto_WatermarkingConfigurable:
|
||||
return "OEMCrypto_WatermarkingConfigurable";
|
||||
case OEMCrypto_WatermarkingAlwaysOn:
|
||||
return "OEMCrypto_WatermarkingAlwaysOn";
|
||||
}
|
||||
// Not reachable unless the enum value is invalid
|
||||
return "<INVALID VALUE>";
|
||||
}
|
||||
const char* DTCP2CapabiityName(OEMCrypto_DTCP2_Capability value) {
|
||||
switch (value) {
|
||||
case OEMCrypto_NO_DTCP2:
|
||||
return "OEMCrypto_NO_DTCP2";
|
||||
case OEMCrypto_DTCP2_V1:
|
||||
return "OEMCrypto_DTCP2_V1";
|
||||
}
|
||||
// Not reachable unless the enum value is invalid
|
||||
return "<INVALID VALUE>";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void OEMCryptoClientTest::SetUp() {
|
||||
@@ -148,6 +218,11 @@ OEMCryptoResult OEMCryptoClientTest::CopyBuffer(
|
||||
dest_buffer_descriptor, subsample_flags);
|
||||
}
|
||||
|
||||
void OEMCryptoClientTest::RecordWvProperty(const std::string& key,
|
||||
const std::string& value) {
|
||||
RecordProperty("widevine_metadata_oec_" + key, value);
|
||||
}
|
||||
|
||||
const char* HDCPCapabilityAsString(OEMCrypto_HDCP_Capability value) {
|
||||
switch (value) {
|
||||
case HDCP_NONE:
|
||||
@@ -174,9 +249,9 @@ const char* HDCPCapabilityAsString(OEMCrypto_HDCP_Capability value) {
|
||||
return "HDCP version 2.3";
|
||||
case HDCP_NO_DIGITAL_OUTPUT:
|
||||
return "No HDCP device attached/using local display with secure path";
|
||||
default:
|
||||
return "<INVALID VALUE>";
|
||||
}
|
||||
// Not reachable unless the enum value is invalid
|
||||
return "<INVALID VALUE>";
|
||||
}
|
||||
|
||||
// Return a printable string from data. If all the characters are printable,
|
||||
@@ -242,40 +317,55 @@ TEST_F(OEMCryptoClientTest, FreeUnallocatedSecureBufferNoFailure) {
|
||||
*/
|
||||
TEST_F(OEMCryptoClientTest, VersionNumber) {
|
||||
const std::string log_message =
|
||||
"OEMCrypto unit tests for API 19.3. Tests last updated 2024-09-04";
|
||||
"OEMCrypto unit tests for API 19.4. Tests last updated 2024-11-04";
|
||||
cout << " " << log_message << "\n";
|
||||
cout << " " << "These tests are part of Android V." << "\n";
|
||||
LOGI("%s", log_message.c_str());
|
||||
// If any of the following fail, then it is time to update the log message
|
||||
// above.
|
||||
EXPECT_EQ(ODK_MAJOR_VERSION, 19);
|
||||
EXPECT_EQ(ODK_MINOR_VERSION, 3);
|
||||
EXPECT_EQ(ODK_MINOR_VERSION, 4);
|
||||
EXPECT_EQ(kCurrentAPI, static_cast<unsigned>(ODK_MAJOR_VERSION));
|
||||
RecordWvProperty("test_major_version", std::to_string(ODK_MAJOR_VERSION));
|
||||
RecordWvProperty("test_minor_version", std::to_string(ODK_MINOR_VERSION));
|
||||
|
||||
OEMCrypto_Security_Level level = OEMCrypto_SecurityLevel();
|
||||
EXPECT_GT(level, OEMCrypto_Level_Unknown);
|
||||
EXPECT_LE(level, OEMCrypto_Level3);
|
||||
cout << " OEMCrypto Security Level is L" << level << endl;
|
||||
RecordWvProperty("security_level", SecurityLevelName(level));
|
||||
|
||||
uint32_t version = OEMCrypto_APIVersion();
|
||||
uint32_t minor_version = OEMCrypto_MinorAPIVersion();
|
||||
cout << " OEMCrypto API version is " << version << "."
|
||||
<< minor_version << endl;
|
||||
RecordWvProperty("major_version", std::to_string(version));
|
||||
RecordWvProperty("minor_version", std::to_string(minor_version));
|
||||
|
||||
cout << " OEMCrypto Device ID is '" << GetDeviceId() << "'"
|
||||
<< endl;
|
||||
|
||||
if (OEMCrypto_SupportsUsageTable()) {
|
||||
const bool supports_usage_tables = OEMCrypto_SupportsUsageTable();
|
||||
if (supports_usage_tables) {
|
||||
cout << " OEMCrypto supports usage tables" << endl;
|
||||
} else {
|
||||
cout << " OEMCrypto does not support usage tables" << endl;
|
||||
}
|
||||
RecordWvProperty("supports_usage_tables", BoolName(supports_usage_tables));
|
||||
|
||||
if (version >= 15) {
|
||||
const uint32_t tier = OEMCrypto_ResourceRatingTier();
|
||||
cout << " Resource Rating Tier: " << tier << endl;
|
||||
RecordWvProperty("resource_rating_tier", std::to_string(tier));
|
||||
}
|
||||
|
||||
if (version >= 17) {
|
||||
OEMCryptoResult sts = OEMCrypto_ProductionReady();
|
||||
if (sts != OEMCrypto_SUCCESS) {
|
||||
LOGW("Device is not production ready, returns %d", sts);
|
||||
}
|
||||
RecordWvProperty("is_production_ready", BoolName(sts == OEMCrypto_SUCCESS));
|
||||
|
||||
std::string build_info;
|
||||
size_t buf_length = 0;
|
||||
sts = OEMCrypto_BuildInformation(&build_info[0], &buf_length);
|
||||
@@ -287,6 +377,7 @@ TEST_F(OEMCryptoClientTest, VersionNumber) {
|
||||
if (build_info.size() != buf_length) {
|
||||
build_info.resize(buf_length);
|
||||
}
|
||||
RecordWvProperty("build_info", build_info);
|
||||
const std::string comma = ",";
|
||||
const std::string pretty_comma = ",\n ";
|
||||
std::string::size_type pos = 0;
|
||||
@@ -295,9 +386,12 @@ TEST_F(OEMCryptoClientTest, VersionNumber) {
|
||||
pos += pretty_comma.size();
|
||||
}
|
||||
cout << " BuildInformation: " << build_info << endl;
|
||||
|
||||
OEMCrypto_WatermarkingSupport support = OEMCrypto_GetWatermarkingSupport();
|
||||
cout << " WatermarkingSupport: " << support << endl;
|
||||
RecordWvProperty("watermarking_support", WatermarkingSupportName(support));
|
||||
}
|
||||
|
||||
ASSERT_GE(version, 8u);
|
||||
ASSERT_LE(version, kCurrentAPI);
|
||||
}
|
||||
@@ -317,8 +411,9 @@ TEST_F(OEMCryptoClientTest, ResourceRatingAPI15) {
|
||||
TEST_F(OEMCryptoClientTest, ProvisioningDeclaredAPI12) {
|
||||
OEMCrypto_ProvisioningMethod provisioning_method =
|
||||
OEMCrypto_GetProvisioningMethod();
|
||||
cout << " Provisioning method = "
|
||||
<< ProvisioningMethodName(provisioning_method) << endl;
|
||||
const char* const name = ProvisioningMethodName(provisioning_method);
|
||||
cout << " Provisioning method = " << name << endl;
|
||||
RecordWvProperty("provisioning_method", name);
|
||||
ASSERT_NE(OEMCrypto_ProvisioningError, provisioning_method);
|
||||
}
|
||||
|
||||
@@ -331,6 +426,8 @@ TEST_F(OEMCryptoClientTest, CheckHDCPCapabilityAPI09) {
|
||||
static_cast<unsigned int>(current), HDCPCapabilityAsString(current));
|
||||
printf(" Maximum HDCP Capability: 0x%02x = %s.\n",
|
||||
static_cast<unsigned int>(maximum), HDCPCapabilityAsString(maximum));
|
||||
RecordWvProperty("hdcp_current", HDCPCapabilityName(current));
|
||||
RecordWvProperty("hdcp_max", HDCPCapabilityName(maximum));
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoClientTest, CheckSRMCapabilityV13) {
|
||||
@@ -339,11 +436,15 @@ TEST_F(OEMCryptoClientTest, CheckSRMCapabilityV13) {
|
||||
OEMCryptoResult current_result = OEMCrypto_GetCurrentSRMVersion(&version);
|
||||
if (current_result == OEMCrypto_SUCCESS) {
|
||||
printf(" Current SRM Version: %d.\n", version);
|
||||
RecordWvProperty("srm_supported", BoolName(true));
|
||||
RecordWvProperty("srm_version", std::to_string(version));
|
||||
EXPECT_NE(OEMCrypto_SUCCESS, OEMCrypto_GetCurrentSRMVersion(nullptr));
|
||||
} else if (current_result == OEMCrypto_LOCAL_DISPLAY_ONLY) {
|
||||
printf(" Current SRM Status: Local Display Only.\n");
|
||||
RecordWvProperty("srm_supported", BoolName(false));
|
||||
} else {
|
||||
EXPECT_EQ(OEMCrypto_ERROR_NOT_IMPLEMENTED, current_result);
|
||||
RecordWvProperty("srm_supported", BoolName(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,6 +687,9 @@ TEST_F(OEMCryptoClientTest, CheckJsonBuildInformationAPI18) {
|
||||
{"is_debug", JSMN_PRIMITIVE},
|
||||
};
|
||||
|
||||
// The prefix of every field name when logged to RecordWvProperty.
|
||||
const std::string kBuildInfoRecordPrefix = "build_info_";
|
||||
|
||||
// A set of the required fields found when examining the
|
||||
// build information, use to verify all fields are present.
|
||||
std::set<std::string> found_required_fields;
|
||||
@@ -612,11 +716,17 @@ TEST_F(OEMCryptoClientTest, CheckJsonBuildInformationAPI18) {
|
||||
<< "Unexpected required field type: field = " << key
|
||||
<< ", build_info = " << build_info;
|
||||
found_required_fields.insert(key);
|
||||
RecordWvProperty(kBuildInfoRecordPrefix + key,
|
||||
build_info.substr(value_token.start,
|
||||
value_token.end - value_token.start));
|
||||
} else if (kOptionalFields.find(key) != kOptionalFields.end()) {
|
||||
ASSERT_EQ(value_token.type, kOptionalFields.at(key))
|
||||
<< "Unexpected optional field type: field = " << key
|
||||
<< ", build_info = " << build_info;
|
||||
} // Do not validate vendor fields.
|
||||
RecordWvProperty(kBuildInfoRecordPrefix + key,
|
||||
build_info.substr(value_token.start,
|
||||
value_token.end - value_token.start));
|
||||
} // Do not validate or record vendor fields.
|
||||
|
||||
if (key == kSpecialCaseReeKey) {
|
||||
// Store the tokens of the "ree" field for additional validation.
|
||||
@@ -657,6 +767,11 @@ TEST_F(OEMCryptoClientTest, CheckJsonBuildInformationAPI18) {
|
||||
// If no "ree" field tokens, then end here.
|
||||
if (!has_ree_info) return;
|
||||
// Step 4a: Verify "ree" object scheme.
|
||||
|
||||
// The prefix of every REE field name when logged to RecordWvProperty.
|
||||
const std::string kReeBuildInfoRecordPrefix =
|
||||
kBuildInfoRecordPrefix + kSpecialCaseReeKey + "_";
|
||||
|
||||
ASSERT_FALSE(ree_tokens.empty())
|
||||
<< "REE field was specified, but contents were empty: build_info = "
|
||||
<< build_info;
|
||||
@@ -686,7 +801,10 @@ TEST_F(OEMCryptoClientTest, CheckJsonBuildInformationAPI18) {
|
||||
<< "Unexpected optional REE field type: ree_field = " << key
|
||||
<< ", build_info = " << build_info;
|
||||
found_required_fields.insert(key);
|
||||
} // Do not validate vendor fields.
|
||||
RecordWvProperty(kReeBuildInfoRecordPrefix + key,
|
||||
build_info.substr(value_token.start,
|
||||
value_token.end - value_token.start));
|
||||
} // Do not validate or record vendor fields.
|
||||
|
||||
// Skip potential nested tokens.
|
||||
i += JsmnAncestorCount(ree_tokens, i + 1);
|
||||
@@ -722,6 +840,7 @@ TEST_F(OEMCryptoClientTest, CheckMaxNumberOfSessionsAPI10) {
|
||||
OEMCryptoResult sts = OEMCrypto_GetMaxNumberOfSessions(&maximum);
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
printf(" Max Number of Sessions: %zu.\n", maximum);
|
||||
RecordWvProperty("max_number_of_sessions", std::to_string(maximum));
|
||||
size_t required_max = GetResourceValue(kMaxConcurrentSession);
|
||||
ASSERT_GE(maximum, required_max);
|
||||
}
|
||||
@@ -729,6 +848,7 @@ TEST_F(OEMCryptoClientTest, CheckMaxNumberOfSessionsAPI10) {
|
||||
TEST_F(OEMCryptoClientTest, CheckUsageTableSizeAPI16) {
|
||||
const size_t maximum = OEMCrypto_MaximumUsageTableHeaderSize();
|
||||
printf(" Max Usage Table Size: %zu.\n", maximum);
|
||||
RecordWvProperty("max_usage_table_size", std::to_string(maximum));
|
||||
// A maximum of 0 means the table is constrained by dynamic memory allocation.
|
||||
if (maximum > 0) {
|
||||
ASSERT_GE(maximum, RequiredUsageSize());
|
||||
@@ -765,6 +885,7 @@ TEST_F(OEMCryptoClientTest, CheckDTCP2CapabilityAPI17) {
|
||||
"DTCP2 is supported.\n");
|
||||
break;
|
||||
}
|
||||
RecordWvProperty("dtcp2_capability", DTCP2CapabiityName(capability));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user