Loading media/libaudiofoundation/DeviceDescriptorBase.cpp +41 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ #include <media/DeviceDescriptorBase.h> #include <media/TypeConverter.h> #include <arpa/inet.h> #include <regex> namespace android { DeviceDescriptorBase::DeviceDescriptorBase(audio_devices_t type) : Loading @@ -34,6 +37,31 @@ DeviceDescriptorBase::DeviceDescriptorBase(audio_devices_t type, const std::stri { } namespace { static const std::string SUPPRESSED = "SUPPRESSED"; static const std::regex MAC_ADDRESS_REGEX("([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}"); bool isAddressSensitive(const std::string &address) { if (std::regex_match(address, MAC_ADDRESS_REGEX)) { return true; } sockaddr_storage ss4; if (inet_pton(AF_INET, address.c_str(), &ss4) > 0) { return true; } sockaddr_storage ss6; if (inet_pton(AF_INET6, address.c_str(), &ss6) > 0) { return true; } return false; } } // namespace DeviceDescriptorBase::DeviceDescriptorBase(const AudioDeviceTypeAddr &deviceTypeAddr) : AudioPort("", AUDIO_PORT_TYPE_DEVICE, audio_is_output_device(deviceTypeAddr.mType) ? AUDIO_PORT_ROLE_SINK : Loading @@ -43,6 +71,12 @@ DeviceDescriptorBase::DeviceDescriptorBase(const AudioDeviceTypeAddr &deviceType if (mDeviceTypeAddr.mAddress.empty() && audio_is_remote_submix_device(mDeviceTypeAddr.mType)) { mDeviceTypeAddr.mAddress = "0"; } mIsAddressSensitive = isAddressSensitive(mDeviceTypeAddr.mAddress); } void DeviceDescriptorBase::setAddress(const std::string &address) { mDeviceTypeAddr.mAddress = address; mIsAddressSensitive = isAddressSensitive(address); } void DeviceDescriptorBase::toAudioPortConfig(struct audio_port_config *dstConfig, Loading Loading @@ -130,10 +164,15 @@ void DeviceDescriptorBase::dump(std::string *dst, int spaces, int index, AudioPort::dump(dst, spaces, verbose); } std::string DeviceDescriptorBase::toString() const std::string DeviceDescriptorBase::toString(bool includeSensitiveInfo) const { std::stringstream sstream; sstream << "type:0x" << std::hex << type() << ",@:" << mDeviceTypeAddr.mAddress; sstream << "type:0x" << std::hex << type(); // IP and MAC address are sensitive information. The sensitive information will be suppressed // is `includeSensitiveInfo` is false. sstream << ",@:" << (!includeSensitiveInfo && mIsAddressSensitive ? SUPPRESSED : mDeviceTypeAddr.mAddress); return sstream.str(); } Loading media/libaudiofoundation/include/media/DeviceDescriptorBase.h +10 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ public: audio_devices_t type() const { return mDeviceTypeAddr.mType; } std::string address() const { return mDeviceTypeAddr.mAddress; } void setAddress(const std::string &address) { mDeviceTypeAddr.mAddress = address; } void setAddress(const std::string &address); const AudioDeviceTypeAddr& getDeviceTypeAddr() const { return mDeviceTypeAddr; } // AudioPortConfig Loading @@ -61,7 +61,14 @@ public: void dump(std::string *dst, int spaces, int index, const char* extraInfo = nullptr, bool verbose = true) const; void log() const; std::string toString() const; /** * Return a string to describe the DeviceDescriptor. * * @param includeSensitiveInfo sensitive information will be added when it is true. * @return a string that can be used to describe the DeviceDescriptor. */ std::string toString(bool includeSensitiveInfo = false) const; bool equals(const sp<DeviceDescriptorBase>& other) const; Loading @@ -70,6 +77,7 @@ public: protected: AudioDeviceTypeAddr mDeviceTypeAddr; bool mIsAddressSensitive; uint32_t mEncapsulationModes = 0; uint32_t mEncapsulationMetadataTypes = 0; }; Loading services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h +3 −1 Original line number Diff line number Diff line Loading @@ -248,7 +248,9 @@ public: return String8(""); } std::string toString() const; // Return a string to describe the DeviceVector. The sensitive information will only be // added to the string if `includeSensitiveInfo` is true. std::string toString(bool includeSensitiveInfo = false) const; void dump(String8 *dst, const String8 &tag, int spaces = 0, bool verbose = true) const; Loading services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -516,7 +516,7 @@ void AudioInputDescriptor::dump(String8 *dst) const dst->appendFormat(" Sampling rate: %d\n", mSamplingRate); dst->appendFormat(" Format: %d\n", mFormat); dst->appendFormat(" Channels: %08x\n", mChannelMask); dst->appendFormat(" Devices %s\n", mDevice->toString().c_str()); dst->appendFormat(" Devices %s\n", mDevice->toString(true /*includeSensitiveInfo*/).c_str()); mEnabledEffects.dump(dst, 1 /*spaces*/, false /*verbose*/); dst->append(" AudioRecord Clients:\n"); ClientMapHandler<RecordClientDescriptor>::dump(dst); Loading services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -245,7 +245,7 @@ void AudioOutputDescriptor::dump(String8 *dst) const dst->appendFormat(" Sampling rate: %d\n", mSamplingRate); dst->appendFormat(" Format: %08x\n", mFormat); dst->appendFormat(" Channels: %08x\n", mChannelMask); dst->appendFormat(" Devices: %s\n", devices().toString().c_str()); dst->appendFormat(" Devices: %s\n", devices().toString(true /*includeSensitiveInfo*/).c_str()); dst->appendFormat(" Global active count: %u\n", mGlobalActiveCount); for (const auto &iter : mRoutingActivities) { dst->appendFormat(" Product Strategy id: %d", iter.first); Loading Loading
media/libaudiofoundation/DeviceDescriptorBase.cpp +41 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ #include <media/DeviceDescriptorBase.h> #include <media/TypeConverter.h> #include <arpa/inet.h> #include <regex> namespace android { DeviceDescriptorBase::DeviceDescriptorBase(audio_devices_t type) : Loading @@ -34,6 +37,31 @@ DeviceDescriptorBase::DeviceDescriptorBase(audio_devices_t type, const std::stri { } namespace { static const std::string SUPPRESSED = "SUPPRESSED"; static const std::regex MAC_ADDRESS_REGEX("([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}"); bool isAddressSensitive(const std::string &address) { if (std::regex_match(address, MAC_ADDRESS_REGEX)) { return true; } sockaddr_storage ss4; if (inet_pton(AF_INET, address.c_str(), &ss4) > 0) { return true; } sockaddr_storage ss6; if (inet_pton(AF_INET6, address.c_str(), &ss6) > 0) { return true; } return false; } } // namespace DeviceDescriptorBase::DeviceDescriptorBase(const AudioDeviceTypeAddr &deviceTypeAddr) : AudioPort("", AUDIO_PORT_TYPE_DEVICE, audio_is_output_device(deviceTypeAddr.mType) ? AUDIO_PORT_ROLE_SINK : Loading @@ -43,6 +71,12 @@ DeviceDescriptorBase::DeviceDescriptorBase(const AudioDeviceTypeAddr &deviceType if (mDeviceTypeAddr.mAddress.empty() && audio_is_remote_submix_device(mDeviceTypeAddr.mType)) { mDeviceTypeAddr.mAddress = "0"; } mIsAddressSensitive = isAddressSensitive(mDeviceTypeAddr.mAddress); } void DeviceDescriptorBase::setAddress(const std::string &address) { mDeviceTypeAddr.mAddress = address; mIsAddressSensitive = isAddressSensitive(address); } void DeviceDescriptorBase::toAudioPortConfig(struct audio_port_config *dstConfig, Loading Loading @@ -130,10 +164,15 @@ void DeviceDescriptorBase::dump(std::string *dst, int spaces, int index, AudioPort::dump(dst, spaces, verbose); } std::string DeviceDescriptorBase::toString() const std::string DeviceDescriptorBase::toString(bool includeSensitiveInfo) const { std::stringstream sstream; sstream << "type:0x" << std::hex << type() << ",@:" << mDeviceTypeAddr.mAddress; sstream << "type:0x" << std::hex << type(); // IP and MAC address are sensitive information. The sensitive information will be suppressed // is `includeSensitiveInfo` is false. sstream << ",@:" << (!includeSensitiveInfo && mIsAddressSensitive ? SUPPRESSED : mDeviceTypeAddr.mAddress); return sstream.str(); } Loading
media/libaudiofoundation/include/media/DeviceDescriptorBase.h +10 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,7 @@ public: audio_devices_t type() const { return mDeviceTypeAddr.mType; } std::string address() const { return mDeviceTypeAddr.mAddress; } void setAddress(const std::string &address) { mDeviceTypeAddr.mAddress = address; } void setAddress(const std::string &address); const AudioDeviceTypeAddr& getDeviceTypeAddr() const { return mDeviceTypeAddr; } // AudioPortConfig Loading @@ -61,7 +61,14 @@ public: void dump(std::string *dst, int spaces, int index, const char* extraInfo = nullptr, bool verbose = true) const; void log() const; std::string toString() const; /** * Return a string to describe the DeviceDescriptor. * * @param includeSensitiveInfo sensitive information will be added when it is true. * @return a string that can be used to describe the DeviceDescriptor. */ std::string toString(bool includeSensitiveInfo = false) const; bool equals(const sp<DeviceDescriptorBase>& other) const; Loading @@ -70,6 +77,7 @@ public: protected: AudioDeviceTypeAddr mDeviceTypeAddr; bool mIsAddressSensitive; uint32_t mEncapsulationModes = 0; uint32_t mEncapsulationMetadataTypes = 0; }; Loading
services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h +3 −1 Original line number Diff line number Diff line Loading @@ -248,7 +248,9 @@ public: return String8(""); } std::string toString() const; // Return a string to describe the DeviceVector. The sensitive information will only be // added to the string if `includeSensitiveInfo` is true. std::string toString(bool includeSensitiveInfo = false) const; void dump(String8 *dst, const String8 &tag, int spaces = 0, bool verbose = true) const; Loading
services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -516,7 +516,7 @@ void AudioInputDescriptor::dump(String8 *dst) const dst->appendFormat(" Sampling rate: %d\n", mSamplingRate); dst->appendFormat(" Format: %d\n", mFormat); dst->appendFormat(" Channels: %08x\n", mChannelMask); dst->appendFormat(" Devices %s\n", mDevice->toString().c_str()); dst->appendFormat(" Devices %s\n", mDevice->toString(true /*includeSensitiveInfo*/).c_str()); mEnabledEffects.dump(dst, 1 /*spaces*/, false /*verbose*/); dst->append(" AudioRecord Clients:\n"); ClientMapHandler<RecordClientDescriptor>::dump(dst); Loading
services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -245,7 +245,7 @@ void AudioOutputDescriptor::dump(String8 *dst) const dst->appendFormat(" Sampling rate: %d\n", mSamplingRate); dst->appendFormat(" Format: %08x\n", mFormat); dst->appendFormat(" Channels: %08x\n", mChannelMask); dst->appendFormat(" Devices: %s\n", devices().toString().c_str()); dst->appendFormat(" Devices: %s\n", devices().toString(true /*includeSensitiveInfo*/).c_str()); dst->appendFormat(" Global active count: %u\n", mGlobalActiveCount); for (const auto &iter : mRoutingActivities) { dst->appendFormat(" Product Strategy id: %d", iter.first); Loading