Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82043c1f authored by Peter Cai's avatar Peter Cai Committed by Jackeagle
Browse files

APM: Remove A2DP audio ports from the primary HAL



These ports defined in the primary HAL are intended for A2DP offloading,
however they do not work in general on GSIs, and will interfere with
sysbta, the system-side generic bluetooth audio implementation.

Remove them as we parse the policy XML.

Co-authored-by: default avatarPierre-Hugues Husson <phh@phh.me>
Change-Id: I3305594a17285da113167b419543543f0ef71122
Signed-off-by: default avatarNishant Kumar <www.rajsonu13@gmail.com>
parent f41a5cd6
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <libxml/xinclude.h>
#include <media/convert.h>
#include <cutils/properties.h>
#include <system/audio.h>
#include <utils/Log.h>
#include <utils/StrongPointer.h>
#include <utils/Errors.h>
@@ -334,11 +335,8 @@ status_t PolicySerializer::deserializeCollection(const xmlNode *cur,
                            Trait::collectionTag);
                        return status;
                    }
                } else if (mIgnoreVendorExtensions && std::get<status_t>(maybeElement) == NO_INIT) {
                    // Skip a vendor extension element.
                } else {
                    return BAD_VALUE;
                }
                // Ignore elements that failed to parse, e.g. routes with invalid sinks
            }
        }
        if (!xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(Trait::tag))) {
@@ -679,6 +677,7 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
        ALOGE("%s: No %s found", __func__, Attributes::name);
        return BAD_VALUE;
    }

    uint32_t versionMajor = 0, versionMinor = 0;
    std::string versionLiteral = getXmlAttribute(cur, Attributes::version);
    if (!versionLiteral.empty()) {
@@ -704,6 +703,25 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
    if (status != NO_ERROR) {
        return status;
    }
    bool shouldEraseA2DP = name == "primary" && property_get_bool("persist.bluetooth.system_audio_hal.enabled", false);
    if (shouldEraseA2DP) {
        // Having A2DP ports in the primary audio HAL module will interfere with sysbta
        // so remove them here. Note that we do not need to explicitly remove the
        // corresponding routes below, because routes with invalid sinks will be ignored
        auto iter = devicePorts.begin();
        while (iter != devicePorts.end()) {
            auto port = *iter;
            auto type = port->type();
            if (type == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP
                    || type == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES
                    || type == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER) {
                ALOGE("Erasing A2DP device port %s", port->getTagName().c_str());
                iter = devicePorts.erase(iter);
            } else {
                iter++;
            }
        }
    }
    module->setDeclaredDevices(devicePorts);

    RouteTraits::Collection routes;