From 06c1343153162655faade26070eb87980d2e44c3 Mon Sep 17 00:00:00 2001 From: Jeffrey Kardatzke Date: Wed, 14 Sep 2022 12:26:11 -0700 Subject: [PATCH] libwvdrmengine: Limit custom property check to ChromeOS We added custom properties that are only used on ChromeOS and to avoid having to bloat the sepolicy for all of Android we are adding a check here so that we only query the properties on ChromeOS based on the bertha hardware property. Bug: b:237492145 Test: Access denied message is gone w/ ExoPlayer Change-Id: I3a5781ad980dfae2e16501b655386287b5e245b7 (cherry picked from commit 890f71ef367aed683a89892000e40d0e0ca6fbdd) (cherry picked from commit 4379b0545a2ae866ba9fc315551a5534fa163924) --- libwvdrmengine/cdm/src/properties_android.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/libwvdrmengine/cdm/src/properties_android.cpp b/libwvdrmengine/cdm/src/properties_android.cpp index eb807aca..b6a16f5b 100644 --- a/libwvdrmengine/cdm/src/properties_android.cpp +++ b/libwvdrmengine/cdm/src/properties_android.cpp @@ -21,6 +21,7 @@ const char kL1Dir[] = "/L1/"; const char kL2Dir[] = "/L2/"; const char kL3Dir[] = "/L3/"; const char kFactoryKeyboxPath[] = "/factory/wv.keys"; +const char kChromeOsHardware[] = "bertha"; bool GetAndroidProperty(const char* key, std::string* value) { if (!key) { @@ -63,8 +64,12 @@ bool Properties::GetCompanyName(std::string* company_name) { LOGW("Properties::GetCompanyName: Invalid parameter"); return false; } - if (GetAndroidProperty("ro.product.cdm.manufacturer", company_name)) + std::string hardware; + if (GetAndroidProperty("ro.hardware", &hardware) && + hardware == kChromeOsHardware && + GetAndroidProperty("ro.product.cdm.manufacturer", company_name)) { return true; + } return GetAndroidProperty("ro.product.manufacturer", company_name); } @@ -73,7 +78,12 @@ bool Properties::GetModelName(std::string* model_name) { LOGW("Properties::GetModelName: Invalid parameter"); return false; } - if (GetAndroidProperty("ro.product.cdm.model", model_name)) return true; + std::string hardware; + if (GetAndroidProperty("ro.hardware", &hardware) && + hardware == kChromeOsHardware && + GetAndroidProperty("ro.product.cdm.model", model_name)) { + return true; + } return GetAndroidProperty("ro.product.model", model_name); } @@ -94,7 +104,12 @@ bool Properties::GetDeviceName(std::string* device_name) { LOGW("Properties::GetDeviceName: Invalid parameter"); return false; } - if (GetAndroidProperty("ro.product.cdm.device", device_name)) return true; + std::string hardware; + if (GetAndroidProperty("ro.hardware", &hardware) && + hardware == kChromeOsHardware && + GetAndroidProperty("ro.product.cdm.device", device_name)) { + return true; + } return GetAndroidProperty("ro.product.device", device_name); }