diff --git a/libwvdrmengine/cdm/core/include/properties.h b/libwvdrmengine/cdm/core/include/properties.h index 5141041f..8acf750c 100644 --- a/libwvdrmengine/cdm/core/include/properties.h +++ b/libwvdrmengine/cdm/core/include/properties.h @@ -49,7 +49,7 @@ class Properties { static bool GetDeviceName(std::string* device_name); static bool GetProductName(std::string* product_name); static bool GetBuildInfo(std::string* build_info); - static bool GetOsVersion(std::string* os_version); + static bool GetWVCdmVersion(std::string* version); static bool GetDeviceFilesBasePath(CdmSecurityLevel security_level, std::string* base_path); static bool GetFactoryKeyboxPath(std::string* keybox); diff --git a/libwvdrmengine/cdm/core/src/license.cpp b/libwvdrmengine/cdm/core/src/license.cpp index 1aacd692..0069e667 100644 --- a/libwvdrmengine/cdm/core/src/license.cpp +++ b/libwvdrmengine/cdm/core/src/license.cpp @@ -25,7 +25,7 @@ std::string kDeviceNameKey = "device_name"; std::string kProductNameKey = "product_name"; std::string kBuildInfoKey = "build_info"; std::string kDeviceIdKey = "device_id"; -std::string kOsVersionKey = "os_version"; +std::string kWVCdmVersionKey = "widevine_cdm_version"; const unsigned char kServiceCertificateCAPublicKey[] = { 0x30, 0x82, 0x01, 0x8a, 0x02, 0x82, 0x01, 0x81, 0x00, 0xb4, 0xfe, 0x39, 0xc3, 0x65, 0x90, 0x03, 0xdb, 0x3c, 0x11, 0x97, 0x09, 0xe8, 0x68, 0xcd, @@ -261,9 +261,9 @@ bool CdmLicense::PrepareKeyRequest(const InitializationData& init_data, client_info->set_name(kDeviceIdKey); client_info->set_value(value); } - if (Properties::GetOsVersion(&value)) { + if (Properties::GetWVCdmVersion(&value)) { client_info = client_id->add_client_info(); - client_info->set_name(kOsVersionKey); + client_info->set_name(kWVCdmVersionKey); client_info->set_value(value); } diff --git a/libwvdrmengine/cdm/src/properties_android.cpp b/libwvdrmengine/cdm/src/properties_android.cpp index b91df4d8..97567742 100644 --- a/libwvdrmengine/cdm/src/properties_android.cpp +++ b/libwvdrmengine/cdm/src/properties_android.cpp @@ -18,6 +18,8 @@ const char kL2Dir[] = "/L2/"; const char kL3Dir[] = "/L3/"; const char kFactoryKeyboxPath[] = "/factory/wv.keys"; +const char kWVCdmVersion[] = "v3.0.0-android"; + bool GetAndroidProperty(const char* key, std::string* value) { char val[PROPERTY_VALUE_MAX]; if (!key) { @@ -88,12 +90,13 @@ bool Properties::GetBuildInfo(std::string* build_info) { return GetAndroidProperty("ro.build.fingerprint", build_info); } -bool Properties::GetOsVersion(std::string* os_version) { - if (!os_version) { - LOGW("Properties::GetOsVersion: Invalid parameter"); +bool Properties::GetWVCdmVersion(std::string* version) { + if (!version) { + LOGW("Properties::GetWVCdmVersion: Invalid parameter"); return false; } - return GetAndroidProperty("ro.build.version.release", os_version); + *version = kWVCdmVersion; + return true; } bool Properties::GetDeviceFilesBasePath(CdmSecurityLevel security_level, diff --git a/libwvdrmengine/cdm/test/request_license_test.cpp b/libwvdrmengine/cdm/test/request_license_test.cpp index f569bb34..0c3e6164 100644 --- a/libwvdrmengine/cdm/test/request_license_test.cpp +++ b/libwvdrmengine/cdm/test/request_license_test.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -1908,6 +1909,22 @@ INSTANTIATE_TEST_CASE_P(Cdm, WvCdmDecryptionTest, &switch_key_encrypted_sub_samples[0], &partial_encrypted_sub_samples[0])); +TEST(VersionNumberTest, VersionNumberChangeCanary) { + char release_number[PROPERTY_VALUE_MAX]; + ASSERT_GT(property_get("ro.build.version.release", release_number, "Unknown"), + 0); + EXPECT_STREQ("MNC", release_number) << + "The Android version number has changed. You need to update this test " + "and also possibly update the Widevine version number in " + "properties_android.cpp."; + + std::string widevine_version; + ASSERT_TRUE(Properties::GetWVCdmVersion(&widevine_version)); + EXPECT_EQ("v3.0.0-android", widevine_version) << + "The Widevine CDM version number has changed. Did you forget to update " + "this test after changing it?"; +} + } // namespace wvcdm void show_menu(char* prog_name) {