MediaMetrics: Fix inaccurate attribution of thread device

CreatePatch metric was overwriting the input and output device
before endIntervalGroup was called.

Use a separate last device field to send the device associated with
the endIntervalGroup.

Fix an issue with multiple devices that the '|' was not embedded
in the device string.

Test: adb shell dumpsys media.metrics
Bug: 247029889
Bug: 247907183
Merged-In: I659d9643782ff03ce5b196cce9f2e9d09c4e609c
Change-Id: I659d9643782ff03ce5b196cce9f2e9d09c4e609c
diff --git a/services/mediametrics/include/mediametricsservice/StringUtils.h b/services/mediametrics/include/mediametricsservice/StringUtils.h
index a91d37b..78c25ff 100644
--- a/services/mediametrics/include/mediametricsservice/StringUtils.h
+++ b/services/mediametrics/include/mediametricsservice/StringUtils.h
@@ -217,4 +217,14 @@
     return { key, "" };
 }
 
+std::pair<std::string /* external statsd */, std::string /* internal */>
+parseOutputDevicePairs(const std::string& outputDevicePairs);
+
+std::pair<std::string /* external statsd */, std::string /* internal */>
+parseInputDevicePairs(const std::string& inputDevicePairs);
+
+inline bool hasBluetoothOutputDevice(std::string_view devices) {
+    return devices.find("AUDIO_DEVICE_OUT_BLUETOOTH") != std::string::npos;
+}
+
 } // namespace android::mediametrics::stringutils