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

Commit f1bde882 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ia5abebad,I9c96ff82

* changes:
  Improve AudioPolicyManager dump, Part 3
  Improve AudioPolicyManager dump, Part 2
parents 9507f034 0f413b26
Loading
Loading
Loading
Loading
+18 −32
Original line number Diff line number Diff line
@@ -70,48 +70,34 @@ const DeviceTypeSet& getAudioDeviceOutAllBleSet() {
    return audioDeviceOutAllBleSet;
}

bool deviceTypesToString(const DeviceTypeSet &deviceTypes, std::string &str) {
std::string deviceTypesToString(const DeviceTypeSet &deviceTypes) {
    if (deviceTypes.empty()) {
        str = "Empty device types";
        return true;
        return "Empty device types";
    }
    bool ret = true;
    for (auto it = deviceTypes.begin(); it != deviceTypes.end();) {
        std::string deviceTypeStr;
        ret = audio_is_output_device(*it) ?
              OutputDeviceConverter::toString(*it, deviceTypeStr) :
              InputDeviceConverter::toString(*it, deviceTypeStr);
        if (!ret) {
            break;
        }
        str.append(deviceTypeStr);
        if (++it != deviceTypes.end()) {
            str.append(" , ");
    std::stringstream ss;
    for (auto it = deviceTypes.begin(); it != deviceTypes.end(); ++it) {
        if (it != deviceTypes.begin()) {
            ss << ", ";
        }
        const char* strType = audio_device_to_string(*it);
        if (strlen(strType) != 0) {
            ss << strType;
        } else {
            ss << "unknown type:0x" << std::hex << *it;
        }
    if (!ret) {
        str = "Unknown values";
    }
    return ret;
    return ss.str();
}

std::string dumpDeviceTypes(const DeviceTypeSet &deviceTypes) {
    std::string ret;
    for (auto it = deviceTypes.begin(); it != deviceTypes.end();) {
    std::stringstream ss;
        ss << "0x" << std::hex << (*it);
        ret.append(ss.str());
        if (++it != deviceTypes.end()) {
            ret.append(" , ");
    for (auto it = deviceTypes.begin(); it != deviceTypes.end(); ++it) {
        if (it != deviceTypes.begin()) {
            ss << ", ";
        }
        ss << "0x" << std::hex << (*it);
    }
    return ret;
}

std::string toString(const DeviceTypeSet& deviceTypes) {
    std::string ret;
    deviceTypesToString(deviceTypes, ret);
    return ret;
    return ss.str();
}

} // namespace android
+5 −2
Original line number Diff line number Diff line
@@ -100,7 +100,10 @@ void AudioDeviceTypeAddr::reset() {

std::string AudioDeviceTypeAddr::toString(bool includeSensitiveInfo) const {
    std::stringstream sstream;
    sstream << "type:0x" << std::hex << mType;
    sstream << audio_device_to_string(mType);
    if (sstream.str().empty()) {
        sstream << "unknown type:0x" << std::hex << mType;
    }
    // IP and MAC address are sensitive information. The sensitive information will be suppressed
    // is `includeSensitiveInfo` is false.
    sstream << ", @:"
+1 −1
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ void AudioProfileVector::dump(std::string *dst, int spaces) const
{
    dst->append(base::StringPrintf("%*s- Profiles (%zu):\n", spaces - 2, "", size()));
    for (size_t i = 0; i < size(); i++) {
        const std::string prefix = base::StringPrintf("%*s%zu. ", spaces + 1, "", i + 1);
        const std::string prefix = base::StringPrintf("%*s %zu. ", spaces, "", i + 1);
        dst->append(prefix);
        std::string profileStr;
        at(i)->dump(&profileStr, prefix.size());
+4 −8
Original line number Diff line number Diff line
@@ -110,27 +110,23 @@ status_t DeviceDescriptorBase::setEncapsulationMetadataTypes(uint32_t encapsulat
    return NO_ERROR;
}

void DeviceDescriptorBase::dump(std::string *dst, int spaces, int index,
void DeviceDescriptorBase::dump(std::string *dst, int spaces,
                                const char* extraInfo, bool verbose) const
{
    const std::string prefix = base::StringPrintf("%*s %d. ", spaces, "", index + 1);
    dst->append(prefix);
    if (mId != 0) {
        dst->append(base::StringPrintf("Port ID: %d; ", mId));
    }
    if (extraInfo != nullptr) {
        dst->append(base::StringPrintf("%s; ", extraInfo));
    }
    dst->append(base::StringPrintf("%s (%s)\n",
                    audio_device_to_string(mDeviceTypeAddr.mType),
    dst->append(base::StringPrintf("{%s}\n",
                    mDeviceTypeAddr.toString(true /*includeSensitiveInfo*/).c_str()));

    dst->append(base::StringPrintf(
                    "%*sEncapsulation modes: %u, metadata types: %u\n",
                    static_cast<int>(prefix.size()), "",
                    "%*sEncapsulation modes: %u, metadata types: %u\n", spaces, "",
                    mEncapsulationModes, mEncapsulationMetadataTypes));

    AudioPort::dump(dst, prefix.size(), nullptr, verbose);
    AudioPort::dump(dst, spaces, nullptr, verbose);
}

std::string DeviceDescriptorBase::toString(bool includeSensitiveInfo) const
+4 −2
Original line number Diff line number Diff line
@@ -131,14 +131,16 @@ static inline DeviceTypeSet deviceTypesFromBitMask(audio_devices_t types) {
    return deviceTypes;
}

bool deviceTypesToString(const DeviceTypeSet& deviceTypes, std::string &str);
std::string deviceTypesToString(const DeviceTypeSet& deviceTypes);

std::string dumpDeviceTypes(const DeviceTypeSet& deviceTypes);

/**
 * Return human readable string for device types.
 */
std::string toString(const DeviceTypeSet& deviceTypes);
inline std::string toString(const DeviceTypeSet& deviceTypes) {
    return deviceTypesToString(deviceTypes);
}


} // namespace android
Loading