Sync up to v213

This commit is contained in:
Andy CrossGate Yan
2020-03-09 03:43:52 +00:00
parent 9fe4d8ccf3
commit 90d7ed3178
6 changed files with 338 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
From 283eb4c984c6e0d878599c9a6fcc4e891cbb24f4 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Thu, 23 Jan 2020 11:13:43 +0800
Subject: [PATCH 13/13] audiopolicy: try again with trimmed audio port name if
not found
* In Spreadtrum BSP, some audio routes may contain ports with extra
spaces at the beginning and the end, causing audiopolicy to refuse to
load and leading to broken audio.
* Fix this by retrying with trimmed port name when not found. Do not
use trimmed name all the time because a white space is a valid
character in port name, and we cannot be sure nobody is using it for
legitimite purposes.
---
.../managerdefinitions/src/Serializer.cpp | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 8bfdb5b0a..4bdb082ba 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -550,6 +550,17 @@ Return<DevicePortTraits::Element> DevicePortTraits::deserialize(const xmlNode *c
return deviceDesc;
}
+char* trim(char * s) {
+ int l = strlen(s);
+
+ if (l > 0) {
+ while (isspace(s[l - 1])) --l;
+ while (*s && isspace(*s)) ++s, --l;
+ }
+
+ return strndup(s, l);
+}
+
Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSerializingCtx ctx)
{
std::string type = getXmlAttribute(cur, Attributes::type);
@@ -590,8 +601,11 @@ Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSer
if (strlen(devTag) != 0) {
sp<AudioPort> source = ctx->findPortByTagName(String8(devTag));
if (source == NULL) {
- ALOGE("%s: no source found with name=%s", __func__, devTag);
- return Status::fromStatusT(BAD_VALUE);
+ source = ctx->findPortByTagName(String8(trim(devTag)));
+ if (source == NULL) {
+ ALOGE("%s: no source found with name=%s", __func__, devTag);
+ return Status::fromStatusT(BAD_VALUE);
+ }
}
sources.add(source);
}
--
2.17.1