Sync up to v117

This commit is contained in:
AndyCGYan 2019-08-11 08:06:43 +00:00
parent b71d406ba3
commit 04c4a9e1b3
5 changed files with 265 additions and 0 deletions

View File

@ -0,0 +1,25 @@
From 7e4a00ff86ca1be573a06e2f358d4783bc15d5bc Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 5 Aug 2019 17:27:18 +0200
Subject: [PATCH 09/11] Enable debug
---
.../audiopolicy/common/managerdefinitions/src/Serializer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 380e2f82b..59385fb76 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "APM::Serializer"
-//#define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
#include "Serializer.h"
#include <media/convert.h>
--
2.17.1

View File

@ -0,0 +1,25 @@
From ded09326e6e4aa9ca3c6f7a7dfbdd36b22bc4af6 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 5 Aug 2019 17:27:47 +0200
Subject: [PATCH 10/11] Fix use-after-free (object on stack)
---
.../audiopolicy/common/managerdefinitions/src/Serializer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 59385fb76..1c5967141 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -326,7 +326,7 @@ status_t DevicePortTraits::deserialize(_xmlDoc *doc, const _xmlNode *root, PtrEl
ALOGW("%s: bad type %08x", __FUNCTION__, type);
return BAD_VALUE;
}
- deviceDesc = new Element(type, String8(name.c_str()));
+ deviceDesc = new Element(type, String8(strdup(name.c_str())));
string address = getXmlAttribute(root, Attributes::address);
if (!address.empty()) {
--
2.17.1

View File

@ -0,0 +1,127 @@
From 91ab9729aa4f4ca4d2a017062408795051a24059 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 5 Aug 2019 18:09:50 +0200
Subject: [PATCH 11/11] Fix BT in-call on CAF devices
See https://github.com/phhusson/treble_experimentations/issues/374
In Qualcomm's BSP audio_policy_configuration.xml, one route is missing,
from primary output and telephony to BT SCO.
Add it if we detect telephony and bt sco, but no such route.
---
.../managerdefinitions/src/Serializer.cpp | 91 +++++++++++++++++++
1 file changed, 91 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 1c5967141..024f122f8 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -424,6 +424,96 @@ status_t RouteTraits::deserialize(_xmlDoc */*doc*/, const _xmlNode *root, PtrEle
return NO_ERROR;
}
+static void fixupQualcommBtScoRoute(RouteTraits::Collection& routes, DevicePortTraits::Collection& devicePorts, HwModule* ctx) {
+ // On many Qualcomm devices, there is a BT SCO Headset Mic => primary input mix
+ // But Telephony Rx => BT SCO Headset route is missing
+ // When we detect such case, add the missing route
+
+ // If we have:
+ // <route type="mix" sink="Telephony Tx" sources="voice_tx"/>
+ // <route type="mix" sink="primary input" sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>
+ // <devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink" />
+ // And no <route type="mix" sink="BT SCO Headset" />
+
+ // Add:
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
+ bool foundBtScoHeadsetDevice = false;
+ for(const auto& device: devicePorts) {
+ if(device->getTagName() == String8("BT SCO Headset")) {
+ foundBtScoHeadsetDevice = true;
+ break;
+ }
+ }
+ if(!foundBtScoHeadsetDevice) {
+ ALOGE("No BT SCO Headset device found, don't patch policy");
+ return;
+ }
+
+ bool foundTelephony = false;
+ bool foundBtScoInput = false;
+ bool foundScoHeadsetRoute = false;
+ for(const auto& route: routes) {
+ ALOGE("Looking at route %d\n", route->getType());
+ if(route->getType() != AUDIO_ROUTE_MIX)
+ continue;
+ auto sink = route->getSink();
+ ALOGE("... With sink %s\n", sink->getTagName().c_str());
+ if(sink->getTagName() == String8("Telephony Tx")) {
+ foundTelephony = true;
+ continue;
+ }
+ if(sink->getTagName() == String8("BT SCO Headset")) {
+ foundScoHeadsetRoute = true;
+ break;
+ }
+ for(const auto& source: route->getSources()) {
+ ALOGE("... With source %s\n", source->getTagName().c_str());
+ if(source->getTagName() == String8("BT SCO Headset Mic")) {
+ foundBtScoInput = true;
+ break;
+ }
+ }
+ }
+ //The route we want to add is already there
+ ALOGE("Done looking for existing routes");
+ if(foundScoHeadsetRoute)
+ return;
+
+ ALOGE("No existing route found... %d %d", foundTelephony ? 1 : 0, foundBtScoInput ? 1 : 0);
+ //We couldn't find the routes we assume are required for the function we want to add
+ if(!foundTelephony || !foundBtScoInput)
+ return;
+ ALOGE("Adding our own.");
+
+ // Add:
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
+ AudioRoute *newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+
+ auto sink = ctx->findPortByTagName(String8("BT SCO Headset"));
+ ALOGE("Got sink %p\n", sink.get());
+ newRoute->setSink(sink);
+
+ AudioPortVector sources;
+ for(const auto& sourceName: {
+ "primary output",
+ "deep_buffer",
+ "compressed_offload",
+ "Telephony Rx"
+ }) {
+ auto source = ctx->findPortByTagName(String8(sourceName));
+ ALOGE("Got source %p\n", source.get());
+ sources.add(source);
+ source->addRoute(newRoute);
+ }
+
+ newRoute->setSources(sources);
+
+ sink->addRoute(newRoute);
+
+ auto ret = routes.add(newRoute);
+ ALOGE("route add returned %zd", ret);
+}
+
const char *const ModuleTraits::childAttachedDevicesTag = "attachedDevices";
const char *const ModuleTraits::childAttachedDeviceTag = "item";
const char *const ModuleTraits::childDefaultOutputDeviceTag = "defaultOutputDevice";
@@ -465,6 +555,7 @@ status_t ModuleTraits::deserialize(xmlDocPtr doc, const xmlNode *root, PtrElemen
RouteTraits::Collection routes;
deserializeCollection<RouteTraits>(doc, root, routes, module.get());
+ fixupQualcommBtScoRoute(routes, devicePorts, module.get());
module->setRoutes(routes);
const xmlNode *children = root->xmlChildrenNode;
--
2.17.1

View File

@ -0,0 +1,44 @@
From 5cc2638b5cf4e386e74301934982756bd485dada Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 5 Aug 2019 21:19:45 +0200
Subject: [PATCH 8/8] Instead of panic-ing to bootloader (useless for us mere
mortals), panic to recovery
Change-Id: If3ff381de845e579814941f89e0a6699c9f8c0e0
---
init/init.cpp | 2 +-
init/log.cpp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/init/init.cpp b/init/init.cpp
index fc58eeabb..168e68042 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -478,7 +478,7 @@ static void InstallRebootSignalHandlers() {
// RebootSystem uses syscall() which isn't actually async-signal-safe, but our only option
// and probably good enough given this is already an error case and only enabled for
// development builds.
- RebootSystem(ANDROID_RB_RESTART2, "bootloader");
+ RebootSystem(ANDROID_RB_RESTART2, "recovery");
};
action.sa_flags = SA_RESTART;
sigaction(SIGABRT, &action, nullptr);
diff --git a/init/log.cpp b/init/log.cpp
index 6198fc25f..759b54117 100644
--- a/init/log.cpp
+++ b/init/log.cpp
@@ -46,9 +46,9 @@ static void InitAborter(const char* abort_message) {
has_aborted = true;
// Do not queue "shutdown" trigger since we want to shutdown immediately and it's not likely
// that we can even run the ActionQueue at this point.
- DoReboot(ANDROID_RB_RESTART2, "reboot", "bootloader", false);
+ DoReboot(ANDROID_RB_RESTART2, "reboot", "recovery", false);
} else {
- RebootSystem(ANDROID_RB_RESTART2, "bootloader");
+ RebootSystem(ANDROID_RB_RESTART2, "recovery");
}
}
--
2.17.1

View File

@ -0,0 +1,44 @@
From b0c0422579e2d2958c59de694d4bdf0af9c4e77f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 29 Jul 2019 18:09:12 +0200
Subject: [PATCH 2/2] Don't fail on FTP conntracking failing
The issue has been seen on some Samsung devices.
See https://github.com/phhusson/treble_experimentations/issues/425
Thanks @zamrih for pin-pointing the issue and validating fix
Change-Id: I3d9c865eb5a4b421f9983210c2ceae62b4906234
---
server/TetherController.cpp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 884b8138..0c0ad68a 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -629,11 +629,17 @@ int TetherController::setForwardRules(bool add, const char *intIface, const char
return -1;
}
+ std::vector<std::string> v4Ftp = {
+ "*raw",
+ StringPrintf("%s %s -p tcp --dport 21 -i %s -j CT --helper ftp",
+ op, LOCAL_RAW_PREROUTING, intIface),
+ "COMMIT",
+ };
+ if(iptablesRestoreFunction(V4, Join(v4Ftp, '\n'), nullptr) == -1) {
+ ALOGE("Failed adding iptables CT target on FTP.");
+ }
+
std::vector<std::string> v4 = {
- "*raw",
- StringPrintf("%s %s -p tcp --dport 21 -i %s -j CT --helper ftp",
- op, LOCAL_RAW_PREROUTING, intIface),
- "COMMIT",
"*filter",
StringPrintf("%s %s -i %s -o %s -m state --state ESTABLISHED,RELATED -g %s",
op, LOCAL_FORWARD, extIface, intIface, LOCAL_TETHER_COUNTERS_CHAIN),
--
2.17.1