android_device_A-Team/patches/MediaProfiles.patch
2026-07-24 16:32:02 -05:00

66 lines
3.7 KiB
Diff

From d79a845a63486dec9a536126722c8ecf2f8b6e0b Mon Sep 17 00:00:00 2001
From: Pranav Vashi <neobuddy89@gmail.com>
Date: Sat, 1 Apr 2023 19:50:59 +0530
Subject: [PATCH] MediaProfiles: Check before overriding media settings xml
* Some devices copy init.qti.media.rc or such qcom scripts which makes MediaProfiles
to select platform specific xml without checking if that xml is present.
* Issue highlighted by @Electimon
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
---
media/libmedia/MediaProfiles.cpp | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp
index 199c226fbf..9bdfd74a1c 100644
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -978,7 +978,8 @@ MediaProfiles::getInstance()
property_get("ro.board.platform", platform, NULL);
if (!strcmp(platform, "msm8953")){
if (property_get("vendor.media.target.version", value, "0") &&
- (atoi(value) == 1)){
+ (atoi(value) == 1) &&
+ checkXmlFile("/vendor/etc/media_profiles_8953_v1.xml")){
strlcpy(value, "/vendor/etc/media_profiles_8953_v1.xml",
PROPERTY_VALUE_MAX);
} else {
@@ -987,7 +988,8 @@ MediaProfiles::getInstance()
}
} else if (!strcmp(platform, "sdm660")) {
property_get("vendor.media.target.version", value, "0");
- if (atoi(value) == 1) {
+ if (atoi(value) == 1 &&
+ checkXmlFile("/vendor/etc/media_profiles_sdm660_v1.xml")) {
strlcpy(value, "/vendor/etc/media_profiles_sdm660_v1.xml",
PROPERTY_VALUE_MAX);
} else {
@@ -996,10 +998,12 @@ MediaProfiles::getInstance()
}
} else if (!strcmp(platform, "bengal")) {
property_get("vendor.sys.media.target.version", value, "0");
- if (atoi(value) == 3) {
+ if (atoi(value) == 3 &&
+ checkXmlFile("/vendor/etc/media_profiles_khaje.xml")) {
strlcpy(value, "/vendor/etc/media_profiles_khaje.xml",
PROPERTY_VALUE_MAX);
- } else if (atoi(value) == 2) {
+ } else if (atoi(value) == 2 &&
+ checkXmlFile("/vendor/etc/media_profiles_scuba.xml")) {
strlcpy(value, "/vendor/etc/media_profiles_scuba.xml",
PROPERTY_VALUE_MAX);
} else {
@@ -1011,8 +1015,10 @@ MediaProfiles::getInstance()
if (property_get("ro.media.xml_variant.codecs", variant, NULL) > 0) {
std::string xmlPath = std::string("/vendor/etc/media_profiles") +
std::string(variant) + std::string(".xml");
- strlcpy(value, xmlPath.c_str(), PROPERTY_VALUE_MAX);
- ALOGI("Profiles xml path: %s", value);
+ if (checkXmlFile(xmlPath.c_str())) {
+ strlcpy(value, xmlPath.c_str(), PROPERTY_VALUE_MAX);
+ ALOGI("Profiles xml path: %s", value);
+ }
}
}
sInstance = createInstanceFromXmlFile(value);