summaryrefslogtreecommitdiff
path: root/audio/common/all-versions/default/UuidUtils.cpp
diff options
context:
space:
mode:
authorMikhail Naganov <mnaganov@google.com>2021-01-15 19:05:04 +0000
committerMikhail Naganov <mnaganov@google.com>2021-02-02 18:17:26 +0000
commit5ec48c2d4d7a8ccdea489ad4b34a7cf75480ffcc (patch)
treee1458ca90fba3abd0f427da2f65fc0d52ecc5d35 /audio/common/all-versions/default/UuidUtils.cpp
parent4f5cb710b92fd58338630e2f54f03cac0468b3f8 (diff)
audio: Create libraries for data types in core and effect
Add 'CoreUtils' library similar to 'HidlUtils' for the types specific to the core HAL. Add 'EffectUtils' library similar to 'HidlUtils' for the types specific to the effects HAL. Move into them and de-duplicate code previously scattered across the default HAL implementation and libaudiohal. Add unit tests. Removed 'AUDIO_{INPUT|OUTPUT}_FLAG_NONE' from the list of values in the XSD file to avoid additional complexity due to equivalence of this value to an empty list of flags. Bug: 142480271 Test: m android.hardware.audio@X.0-impl Test: m android.hardware.audio.effect@X.0-impl Test: atest android.hardware.audio@7.0-util_tests Test: atest android.hardware.audio.common@7.0-util_tests Test: atest android.hardware.audio.effect@7.0-util_tests Change-Id: I71a95cbe07fcc162dc6d74ff9665747a17ce5a80
Diffstat (limited to 'audio/common/all-versions/default/UuidUtils.cpp')
-rw-r--r--audio/common/all-versions/default/UuidUtils.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/audio/common/all-versions/default/UuidUtils.cpp b/audio/common/all-versions/default/UuidUtils.cpp
index 85edc7b2f4..6c4c94d415 100644
--- a/audio/common/all-versions/default/UuidUtils.cpp
+++ b/audio/common/all-versions/default/UuidUtils.cpp
@@ -42,6 +42,14 @@ void UuidUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) {
memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
}
+std::string UuidUtils::uuidToString(const audio_uuid_t& halUuid) {
+ char str[64];
+ snprintf(str, sizeof(str), "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", halUuid.timeLow,
+ halUuid.timeMid, halUuid.timeHiAndVersion, halUuid.clockSeq, halUuid.node[0],
+ halUuid.node[1], halUuid.node[2], halUuid.node[3], halUuid.node[4], halUuid.node[5]);
+ return str;
+}
+
} // namespace implementation
} // namespace CPP_VERSION
} // namespace common