From 985eaacfb9c82adc34cf4c8828a7667769d66676 Mon Sep 17 00:00:00 2001 From: Matt Feddersen Date: Mon, 25 Mar 2024 11:56:10 -0700 Subject: [PATCH 1/5] Update ODK version to 19.1 [ Merge of http://go/wvgerrit/195352 ] PiperOrigin-RevId: 618915151 Merged from https://widevine-internal-review.googlesource.com/195050 Change-Id: Ieff901a961c3f965497b62a655c3ddb536e112a0 --- .../oemcrypto/odk/include/core_message_features.h | 4 ++-- libwvdrmengine/oemcrypto/odk/include/odk_structs.h | 4 ++-- libwvdrmengine/oemcrypto/odk/src/core_message_features.cpp | 2 +- libwvdrmengine/oemcrypto/odk/src/odk_timer.c | 3 +++ libwvdrmengine/oemcrypto/odk/test/odk_test.cpp | 7 +++++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libwvdrmengine/oemcrypto/odk/include/core_message_features.h b/libwvdrmengine/oemcrypto/odk/include/core_message_features.h index e4d6a0e3..b2dda6a9 100644 --- a/libwvdrmengine/oemcrypto/odk/include/core_message_features.h +++ b/libwvdrmengine/oemcrypto/odk/include/core_message_features.h @@ -26,9 +26,9 @@ struct CoreMessageFeatures { // This is the published version of the ODK Core Message library. The default // behavior is for the server to restrict messages to at most this version - // number. The default is 19.0. + // number. The default is 19.1. uint32_t maximum_major_version = 19; - uint32_t maximum_minor_version = 0; + uint32_t maximum_minor_version = 1; bool operator==(const CoreMessageFeatures &other) const; bool operator!=(const CoreMessageFeatures &other) const { diff --git a/libwvdrmengine/oemcrypto/odk/include/odk_structs.h b/libwvdrmengine/oemcrypto/odk/include/odk_structs.h index 5f93e356..3335f95d 100644 --- a/libwvdrmengine/oemcrypto/odk/include/odk_structs.h +++ b/libwvdrmengine/oemcrypto/odk/include/odk_structs.h @@ -16,10 +16,10 @@ extern "C" { /* The version of this library. */ #define ODK_MAJOR_VERSION 19 -#define ODK_MINOR_VERSION 0 +#define ODK_MINOR_VERSION 1 /* ODK Version string. Date changed automatically on each release. */ -#define ODK_RELEASE_DATE "ODK v19.0 2024-03-22" +#define ODK_RELEASE_DATE "ODK v19.1 2024-03-25" /* The lowest version number for an ODK message. */ #define ODK_FIRST_VERSION 16 diff --git a/libwvdrmengine/oemcrypto/odk/src/core_message_features.cpp b/libwvdrmengine/oemcrypto/odk/src/core_message_features.cpp index 65a6d2f3..4143d140 100644 --- a/libwvdrmengine/oemcrypto/odk/src/core_message_features.cpp +++ b/libwvdrmengine/oemcrypto/odk/src/core_message_features.cpp @@ -33,7 +33,7 @@ CoreMessageFeatures CoreMessageFeatures::DefaultFeatures( features.maximum_minor_version = 4; // 18.4 break; case 19: - features.maximum_minor_version = 0; // 19.0 + features.maximum_minor_version = 1; // 19.1 break; default: features.maximum_minor_version = 0; diff --git a/libwvdrmengine/oemcrypto/odk/src/odk_timer.c b/libwvdrmengine/oemcrypto/odk/src/odk_timer.c index 57e4f431..c76fc5ab 100644 --- a/libwvdrmengine/oemcrypto/odk/src/odk_timer.c +++ b/libwvdrmengine/oemcrypto/odk/src/odk_timer.c @@ -276,6 +276,9 @@ OEMCryptoResult ODK_InitializeSessionValues(ODK_TimerLimits* timer_limits, case 18: nonce_values->api_minor_version = 4; break; + case 19: + nonce_values->api_minor_version = 1; + break; default: nonce_values->api_minor_version = 0; break; diff --git a/libwvdrmengine/oemcrypto/odk/test/odk_test.cpp b/libwvdrmengine/oemcrypto/odk/test/odk_test.cpp index 41996d9f..420b25fd 100644 --- a/libwvdrmengine/oemcrypto/odk/test/odk_test.cpp +++ b/libwvdrmengine/oemcrypto/odk/test/odk_test.cpp @@ -1275,7 +1275,7 @@ std::vector TestCases() { {16, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 16, 5}, {17, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 17, 2}, {18, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 18, 4}, - {19, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 19, 0}, + {19, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 19, 1}, // Here are some known good versions. Make extra sure they work. {ODK_MAJOR_VERSION, 16, 3, 16, 3}, {ODK_MAJOR_VERSION, 16, 4, 16, 4}, @@ -1287,13 +1287,16 @@ std::vector TestCases() { {ODK_MAJOR_VERSION, 18, 3, 18, 3}, {ODK_MAJOR_VERSION, 18, 4, 18, 4}, {ODK_MAJOR_VERSION, 19, 0, 19, 0}, + {ODK_MAJOR_VERSION, 19, 1, 19, 1}, {0, 16, 3, 16, 3}, {0, 16, 4, 16, 4}, {0, 16, 5, 16, 5}, {0, 17, 1, 17, 1}, {0, 17, 2, 17, 2}, - {0, 18, 3, 18, 3}, // Change to 19 when the default version is updated. + {0, 18, 3, 18, 3}, {0, 18, 4, 18, 4}, + {0, 19, 0, 19, 0}, + {0, 19, 1, 19, 1}, }; return test_cases; } From 1c6ec56725f7bfec01790ab3f826d3f4a3387647 Mon Sep 17 00:00:00 2001 From: Vicky Min Date: Wed, 1 May 2024 23:33:11 +0000 Subject: [PATCH 2/5] Update DecryptZeroSizeSubSample test to accept success or error Bug: 338010108 Merged from https://widevine-internal-review.googlesource.com/198002 Change-Id: I52c72a5c1a287e8556a243b6072faf23ce4bbdad (cherry picked from commit 8b806d128e450ab0bf9cba17e21b5ed5ff97c277) --- libwvdrmengine/oemcrypto/test/oemcrypto_decrypt_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_decrypt_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_decrypt_test.cpp index 6e7a49a9..b9868d02 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_decrypt_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_decrypt_test.cpp @@ -544,7 +544,7 @@ TEST_P(OEMCryptoSessionTestsDecryptTests, DecryptZeroSizeSubSample) { ASSERT_NO_FATAL_FAILURE(LoadLicense()); ASSERT_NO_FATAL_FAILURE(MakeBuffers()); ASSERT_NO_FATAL_FAILURE(EncryptData()); - ASSERT_NO_FATAL_FAILURE(TestDecryptCENC()); + ASSERT_NO_FATAL_FAILURE(DecryptCENC()); } // There are probably no frames this small, but we should handle them anyway. From 1f3c38d6a355b01456d86172021465e650e54fb6 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Sun, 28 Apr 2024 22:26:36 -0700 Subject: [PATCH 3/5] Update request url The test server for UAT and for the SDKs now accept the same url format for renewals. Bug: 328763985 Change-Id: I1a58412047735efa26da7986bf19fa9a7fbaf374 --- .../cdm/core/test/license_holder.cpp | 22 +++++++------------ libwvdrmengine/cdm/core/test/license_holder.h | 6 ++--- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/libwvdrmengine/cdm/core/test/license_holder.cpp b/libwvdrmengine/cdm/core/test/license_holder.cpp index 0e9837b7..c8c93f23 100644 --- a/libwvdrmengine/cdm/core/test/license_holder.cpp +++ b/libwvdrmengine/cdm/core/test/license_holder.cpp @@ -83,7 +83,7 @@ void LicenseHolder::FailReloadLicense() { } void LicenseHolder::GenerateAndPostRenewalRequest( - const std::string& policy_id) { + const std::string& renewal_policy_id) { event_listener_.set_renewal_needed(false); CdmKeyRequest request; const CdmResponseType result = @@ -92,7 +92,7 @@ void LicenseHolder::GenerateAndPostRenewalRequest( if (config_.dump_golden_data()) { MessageDumper::DumpRenewalRequest(request); } - const std::string url = MakeUrl(config_.renewal_server(), policy_id); + const std::string url = MakeUrl(config_.renewal_server(), renewal_policy_id); request_in_flight_.reset(new UrlRequest(url)); ASSERT_TRUE(request_in_flight_->is_connected()) << "Failed for " << content_id(); @@ -117,7 +117,7 @@ void LicenseHolder::LoadRenewal() { } void LicenseHolder::GenerateAndPostReleaseRequest( - const std::string& policy_id) { + const std::string& release_policy_id) { event_listener_.set_renewal_needed(false); CdmKeyRequest request; CdmAppParameterMap empty_app_parameters; @@ -134,7 +134,7 @@ void LicenseHolder::GenerateAndPostReleaseRequest( // TODO (b/295956275) vickymin: write DumpReleaseRequest function // MessageDumper::DumpReleaseRequest(request); } - const std::string url = MakeUrl(config_.renewal_server(), policy_id); + const std::string url = MakeUrl(config_.renewal_server(), release_policy_id); request_in_flight_.reset(new UrlRequest(url)); ASSERT_TRUE(request_in_flight_->is_connected()) << "Failed for " << content_id(); @@ -262,22 +262,16 @@ void LicenseHolder::GenerateKeyRequest(const InitializationData& init_data, } std::string LicenseHolder::MakeUrl(const std::string& server_url, - const std::string& policy_id) { + const std::string& renewal_policy_id) { // For tests, we want to specify the policy, but the UAT server only allows us // to set the content id as the video_id. So each policy is matched to a // single license with the same name. The local license server, on the other // hand, wants to see the policy id in the url. So we have to guess which // format to use based on the name of the server. const std::string path = server_url + config_.client_auth(); - std::string video_query; - if (!policy_id.empty()) { - if (path.find("proxy.uat") != std::string::npos) { - // This is uat or uat-nightly. Set the video_id. - video_query = "video_id=" + policy_id; - } else { - // This is probably a local license server. Set the policy. - video_query = "policy=" + policy_id; - } + if (!renewal_policy_id.empty()) { + const std::string video_query = + "video_id=" + content_id() + "&renewal_policy=" + renewal_policy_id; // If there is already a parameter, then we don't need to add another // question mark. return path + ((path.find('?') == std::string::npos) ? '?' : '&') + diff --git a/libwvdrmengine/cdm/core/test/license_holder.h b/libwvdrmengine/cdm/core/test/license_holder.h index 405af278..93606be2 100644 --- a/libwvdrmengine/cdm/core/test/license_holder.h +++ b/libwvdrmengine/cdm/core/test/license_holder.h @@ -69,13 +69,13 @@ class LicenseHolder { // Attempt to reload a license, but expect a failure. void FailReloadLicense(); // Generate the renewal request, and send it to the server. - void GenerateAndPostRenewalRequest(const std::string& policy_id); + void GenerateAndPostRenewalRequest(const std::string& renewal_policy_id); // Fetch the renewal response. This can add a few seconds of latency. void FetchRenewal(); // Load the renewal response that was fetched in FetchRenewal(). void LoadRenewal(); // Generate the release request, and send it to the server. - void GenerateAndPostReleaseRequest(const std::string& policy_id); + void GenerateAndPostReleaseRequest(const std::string& release_policy_id); // Fetch the release response. This can add a few seconds of latency. void FetchRelease(); // Load the release response that was fetched in FetchRelease(). @@ -137,7 +137,7 @@ class LicenseHolder { // Generate a URL for the specified policy. The license request should be sent // to this url. std::string MakeUrl(const std::string& server_url, - const std::string& policy_id); + const std::string& renewal_policy_id); // Fetch the key response from the server. void GetKeyResponse(const CdmKeyRequest& key_request); }; From d53caaade2e7788e1f8ee82f6cb860ad1c40fbf3 Mon Sep 17 00:00:00 2001 From: Vicky Min Date: Tue, 23 Apr 2024 18:41:50 +0000 Subject: [PATCH 4/5] Skip entitlement session test that is only supported on CAS devices Bug: 335398236 Merged from https://widevine-internal-review.googlesource.com/197432 (cherry picked from commit a35129440254c91a261903e499e3f2417425cfb0) (cherry picked from commit 87d58f48d62dbc4cdbb6c2af1c5a7bda2e209efa) Change-Id: I7f67dfbc8725cbe0a67d8eda082fa184286d2e84 --- libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 051fb054..ab245cee 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -635,6 +635,9 @@ TEST_P(OEMCryptoLicenseTest, EntitledKeySessionsAPI17) { if (wvoec::global_features.api_version < 17) { GTEST_SKIP() << "Test for versions 17 and up only."; } + if (!global_features.supports_cas) { + GTEST_SKIP() << "OEMCrypto does not support CAS"; + } license_messages_.set_license_type(OEMCrypto_EntitlementLicense); ASSERT_NO_FATAL_FAILURE(license_messages_.SignAndVerifyRequest()); ASSERT_NO_FATAL_FAILURE(license_messages_.CreateDefaultResponse()); From d926fb31ec0b16890164831bc1b343da011a805b Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Mon, 1 Apr 2024 17:14:05 -0700 Subject: [PATCH 5/5] Address missing dependencies or executables [ Merge of http://go/wvgerrit/195850 ] Since Widevine device builds now include APEX prebuilts, shared library dependencies for the prebuilts are in are in /apex/com.google.android.widevine/lib[64] rather than /system/lib[64] or /vendor/lib[64]. When tests are run not all the dependencies are present. These changes include * Statically linking missing dependencies * Adding /apex/com.google.android.widevine/lib[64] to the shared library path * Searching for some of the test executables in /data/nativetest[64]/vendor/ Bug: 329888778 Bug: 329891889 Bug: 329891175 Bug: 329891049 Test: ./build_and_run_all_unit_tests.sh Change-Id: I067685cedc7701c4e6502bdac98b53e22b61ad1e --- libwvdrmengine/build_all_unit_tests.sh | 6 +++++- libwvdrmengine/mediacrypto/test/Android.mk | 5 ++++- libwvdrmengine/mediadrm/test/Android.mk | 10 ++++++++-- libwvdrmengine/oemcrypto/test/common.mk | 2 +- libwvdrmengine/run_all_unit_tests.sh | 6 ++++-- libwvdrmengine/test/unit/Android.mk | 16 +++++++++++++++- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/libwvdrmengine/build_all_unit_tests.sh b/libwvdrmengine/build_all_unit_tests.sh index 8cf8ed97..cf0904e6 100755 --- a/libwvdrmengine/build_all_unit_tests.sh +++ b/libwvdrmengine/build_all_unit_tests.sh @@ -98,7 +98,11 @@ fi # If that fails, an error message will be printed. try_adb_push() { # android-tests.zip requires /data/nativetest, we should use the same - if [ -f $OUT/data/nativetest/$1 ]; then + if [ -f $OUT/data/nativetest64/$1 ]; then + test_file=$OUT/data/nativetest64/$1 + elif [ -f $OUT/data/nativetest64/vendor/$1/$1 ]; then + test_file=$OUT/data/nativetest64/vendor/$1/$1 + elif [ -f $OUT/data/nativetest/$1 ]; then test_file=$OUT/data/nativetest/$1 elif [ -f $OUT/data/nativetest/vendor/$1/$1 ]; then test_file=$OUT/data/nativetest/vendor/$1/$1 diff --git a/libwvdrmengine/mediacrypto/test/Android.mk b/libwvdrmengine/mediacrypto/test/Android.mk index f1ab4070..37c3d9ba 100644 --- a/libwvdrmengine/mediacrypto/test/Android.mk +++ b/libwvdrmengine/mediacrypto/test/Android.mk @@ -25,11 +25,15 @@ LOCAL_STATIC_LIBRARIES := \ libcdm_protos \ libcdm_utils \ libjsmn \ + libjsoncpp \ libgmock \ libgmock_main \ libgtest \ + libwvaidl \ + libwvdrmcryptoplugin_aidl \ libwvlevel3 \ libwv_odk \ + libPlatformProperties \ LOCAL_SHARED_LIBRARIES := \ android.hardware.drm-V1-ndk \ @@ -41,7 +45,6 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libprotobuf-cpp-lite \ libutils \ - libwvaidl \ wv_media_drm_flags_c_lib \ LOCAL_HEADER_LIBRARIES := \ diff --git a/libwvdrmengine/mediadrm/test/Android.mk b/libwvdrmengine/mediadrm/test/Android.mk index 7bfc43bf..490f73da 100644 --- a/libwvdrmengine/mediadrm/test/Android.mk +++ b/libwvdrmengine/mediadrm/test/Android.mk @@ -22,14 +22,20 @@ LOCAL_C_INCLUDES := \ LOCAL_STATIC_LIBRARIES := \ libcdm \ + libcdm_utils \ + libcutils \ libcdm_protos \ libcdm_utils \ libjsmn \ + libjsoncpp \ libgmock \ libgmock_main \ libgtest \ + libwvaidl \ + libwvdrmdrmplugin_aidl \ libwvlevel3 \ libwv_odk \ + libPlatformProperties \ LOCAL_SHARED_LIBRARIES := \ android.hardware.drm-V1-ndk \ @@ -40,7 +46,6 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libprotobuf-cpp-lite \ libutils \ - libwvaidl \ wv_media_drm_flags_c_lib \ LOCAL_HEADER_LIBRARIES := \ @@ -92,6 +97,8 @@ LOCAL_STATIC_LIBRARIES := \ libgtest \ libgtest_main \ libjsmn \ + libwvaidl \ + libwvdrmdrmplugin_aidl \ libwvlevel3 \ libwv_odk \ @@ -101,7 +108,6 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libprotobuf-cpp-lite \ libutils \ - libwvaidl \ LOCAL_C_INCLUDES += \ external/protobuf/src \ diff --git a/libwvdrmengine/oemcrypto/test/common.mk b/libwvdrmengine/oemcrypto/test/common.mk index 9c0b3515..8f8b7d7e 100644 --- a/libwvdrmengine/oemcrypto/test/common.mk +++ b/libwvdrmengine/oemcrypto/test/common.mk @@ -49,6 +49,7 @@ LOCAL_C_INCLUDES += \ LOCAL_STATIC_LIBRARIES := \ libcdm \ + libcppbor \ libjsmn \ libgmock \ libgtest \ @@ -62,7 +63,6 @@ LOCAL_STATIC_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \ libbase \ - libcppbor \ libcrypto \ libdl \ libbinder_ndk \ diff --git a/libwvdrmengine/run_all_unit_tests.sh b/libwvdrmengine/run_all_unit_tests.sh index 1aa1c84d..7e894b14 100755 --- a/libwvdrmengine/run_all_unit_tests.sh +++ b/libwvdrmengine/run_all_unit_tests.sh @@ -27,7 +27,8 @@ elif [ 0 -eq `expr index "$GTEST_FILTER" "-"` ]; then fi # The Android supplement allows for installation in these paths: -OEC_PATHS=/system/lib64:/system/lib/:/vendor/lib64:/vendor/lib:/system/lib64/vndk-R:/system/lib/vndk-R +OEC_PATHS=/apex/com.google.android.widevine/lib64:/apex/com.google.android.widevine/lib: +OEC_PATHS+=/system/lib64:/system/lib/:/vendor/lib64:/vendor/lib:/system/lib64/vndk-R:/system/lib/vndk-R # Execute a command in "adb shell" and capture the result. adb_shell_run() { @@ -49,7 +50,8 @@ adb_shell_run() { # to load. We must reverse the library path in this case so we don't attempt # to load 64-bit libraries with the 32-bit liboemcrypto.so. if ! adb $SERIAL_NUM shell ls /vendor/lib64/liboemcrypto.so &> /dev/null; then - OEC_PATHS=/system/lib:/system/lib64/:/vendor/lib:/vendor/lib64:/system/lib/vndk-R:/system/lib64/vndk-R + OEC_PATHS=/apex/com.google.android.widevine/lib:/apex/com.google.android.widevine/lib64: + OEC_PATHS+=/system/lib:/system/lib64/:/vendor/lib:/vendor/lib64:/system/lib/vndk-R:/system/lib64/vndk-R fi adb $SERIAL_NUM shell "LD_LIBRARY_PATH=$OEC_PATHS GTEST_FILTER=$GTEST_FILTER $@ $test_file" \|\| echo "$adb_error" | tee "$tmp_log" ! grep -Fq "$adb_error" "$tmp_log" diff --git a/libwvdrmengine/test/unit/Android.mk b/libwvdrmengine/test/unit/Android.mk index 1e96aa10..d4ac155d 100644 --- a/libwvdrmengine/test/unit/Android.mk +++ b/libwvdrmengine/test/unit/Android.mk @@ -19,18 +19,32 @@ LOCAL_C_INCLUDES := \ vendor/widevine/libwvdrmengine/oemcrypto/include \ LOCAL_STATIC_LIBRARIES := \ + libaidlcommonsupport \ libgtest \ libgtest_main \ + libjsmn \ + libjsoncpp \ + libcdm \ + libcdm_protos \ + libcdm_utils \ + libwvdrmcryptoplugin_aidl \ + libwvdrmdrmplugin_aidl \ + libwvlevel3 \ + libwv_odk \ + libwvaidl \ + libPlatformProperties \ LOCAL_SHARED_LIBRARIES := \ android.hardware.drm-V1-ndk \ libbase \ libbinder_ndk \ libcrypto \ + libcutils \ libdl \ liblog \ + libprotobuf-cpp-lite \ libutils \ - libwvaidl \ + wv_media_drm_flags_c_lib \ LOCAL_HEADER_LIBRARIES := \ libstagefright_foundation_headers \