Convert getDevicesForStream to return a DeviceTypeSet

As a pre-requisite for switching from 'int' to
'AudioDeviceDescription' in the framework AIDL interfaces,
get rid of the usage of 'int' as a mask of 'audio_devices_t'
values. This is needed because 'AudioDeviceDescription'
can't be coerced into an int directly, and interpreting
a mask of multiple 'audio_devices_t' values is ambiguous
due to presence of multi-bit device types.

Note that at the Java layer the returned DeviceTypeSet
is still collapsed into a single integer value. This needs
to be addressed separately.

Bug: 188932434
Test: check audio on device
Change-Id: I1bc2a28ac2e1037a38b7be7967349b33845f88de
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index 640f547..3ac4eee 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -1259,19 +1259,19 @@
     return result.value_or(PRODUCT_STRATEGY_NONE);
 }
 
-audio_devices_t AudioSystem::getDevicesForStream(audio_stream_type_t stream) {
+DeviceTypeSet AudioSystem::getDevicesForStream(audio_stream_type_t stream) {
     const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
-    if (aps == 0) return AUDIO_DEVICE_NONE;
+    if (aps == 0) return DeviceTypeSet{};
 
-    auto result = [&]() -> ConversionResult<audio_devices_t> {
+    auto result = [&]() -> ConversionResult<DeviceTypeSet> {
         media::AudioStreamType streamAidl = VALUE_OR_RETURN(
                 legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
-        int32_t resultAidl;
+        std::vector<int32_t> resultAidl;
         RETURN_IF_ERROR(statusTFromBinderStatus(
                 aps->getDevicesForStream(streamAidl, &resultAidl)));
-        return aidl2legacy_int32_t_audio_devices_t(resultAidl);
+        return convertContainer<DeviceTypeSet>(resultAidl, aidl2legacy_int32_t_audio_devices_t);
     }();
-    return result.value_or(AUDIO_DEVICE_NONE);
+    return result.value_or(DeviceTypeSet{});
 }
 
 status_t AudioSystem::getDevicesForAttributes(const AudioAttributes& aa,